Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to allocate instance of a class

    SDK Help
    0
    10
    797
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 04/02/2004 at 18:03, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.100 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi all
      Can anyone tell me how to allocate instance of a class in C++ SDK. For example in the C.O.F.F.E.E we have this code:
      var object = new(myClass);
      How to translate it into C++?
      Thanks and Regards

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 08/02/2004 at 08:31, xxxxxxxx wrote:

        What do you exactly want to do?
        In C++ there is gNew for allocating classes (if you want to allocate arrays of classes you need to use bNew).
        Usually all Cinema 4D objects have a constructor function to allocate them.
        Example to allocate a Cube object:
        BaseObject* cube = BaseObject::Alloc(Ocube);
        HTH

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 08/02/2004 at 18:11, xxxxxxxx wrote:

          Hi Samir,
          Thanks for the reply, it is working now.
          I have one more question. If i have:
          BaseObject *ObjGrid = BaseObject::Alloc(Oplane);
          then i wanna get the number of points of the plane, I can write: cnt = ObjGrid->GetPointCount in the COFFEE, but when i wanna apply to C++, seems like it does not have function GetPointCount for this object. Do u have any idea about this?
          Best Regards

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 09/02/2004 at 00:02, xxxxxxxx wrote:

            Hi,

            the Oplane for example is a primitive object. therefore it does not offer point, polygon or edge access. That´s why you cannot use GetPointCount() on it. you will need to convert it to a polygonobject first, then you can use GetPointCount() (for the conversion you can use the SendModelingCommand MCOMMAND_CURRENTSTATETOOBJECT search the forum for this and download the SDK Documentation)

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 09/02/2004 at 02:38, xxxxxxxx wrote:

              Hi Samir,
              Thanks for the reply,
              Now I am able to create a plane,
                 BaseObject *ObjGrid = BaseObject::Alloc(Oplane);
                 BaseContainer *conGrid = ObjGrid->GetDataInstance();
                 
                 ObjGrid = GeneratePrimitive(doc, Oplane, (*conGrid), 0.0, TRUE, NULL);
              I have to set the height and width for the plane, If I have the PRIM_PLANE_SUBW and PRIM_PLANE_SUBH in COFFEE, what's the command in C++?
                 
                 conGrid->SetData(PRIM_PLANE_SUBW, XNos);
                 conGrid->SetData(PRIM_PLANE_SUBH, ZNos);
              Can I use the same?
              Thanks and regards

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 09/02/2004 at 05:00, xxxxxxxx wrote:

                BaseObject *ObjGrid = BaseObject::Alloc(Oplane);
                BaseContainer *conGrid = ObjGrid- >GetDataInstance();
                That´s alright so far!
                   
                ObjGrid = GeneratePrimitive(doc, Oplane, (*conGrid), 0.0, TRUE, NULL);
                But this is unnecessary! You already generated the object above. This would have generated it twice. In order edit the settings of an object you can use the BaseContainer. It depends on the type though. The Subdivision W for example is a Real value. So you would set it like this:
                conGrid->SetReal(ID_OF_THE_SETTING, XNos);
                Once again please Read the Documentation!

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 09/02/2004 at 18:35, xxxxxxxx wrote:

                  Thanks for the reply,
                  I have tried it.
                  Now I have one Object:
                  BaseObject *ObjGrid = BaseObject::Alloc(Oplane);
                  BaseContainer *conGrid = ObjGrid- >GetDataInstance();
                  then I have set the height and width for the container
                  _    conGrid->SetReal(PRIM_PLANE_SUBW, XNos);
                     conGrid->SetReal(PRIM_PLANE_SUBH, ZNos);_
                  _   conGrid->SetReal(PRIM_PLANE_WIDTH, (XNos*XWidth));_ _

                  conGrid->SetReal(PRIM_PLANE_HEIGHT, (ZNos*ZWidth));_
                  _    ObjGrid->SetName(vGridName);_
                  _    doc->InsertObject(ObjGrid,NULL,NULL,TRUE); _
                  Until now i am able to create the object
                  When i wanna make it editable by using sendmodelingcommand, as follows
                  _    doc->StartUndo();
                     doc->AddUndo(UNDO_NEW, ObjGrid);
                     ObjGrid->SetRot(Vector(Rot_H, Rot_P, Rot_B)); 
                     
                     ModelingCommandData cd;
                     cd.doc = doc;
                     cd.bc = conGrid;
                     cd.op = ObjGrid;
                     cd.mode = MODIFY_ALL;
                     
                     if (!SendModelingCommand(MCOMMAND_MAKEEDITABLE, cd)) return FALSE;_
                  but this code does not produce a plane anymore. Do u have any idea about this?
                  Thanks and Best regards

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 09/02/2004 at 20:03, xxxxxxxx wrote:

                    cd.bc is the parameters for the modeling command, so you cannot send the conGrid container. (No parameters are necessary for make editable.)
                    Do you mean that SendModelingCommand() returns FALSE? Note that the resulting object is in cd.result1, and isn't automatically inserted into the document unless you set the CREATEUNDO flag in cd.flags.

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 09/02/2004 at 23:30, xxxxxxxx wrote:

                      Hi Mikael,
                      Actually I juz wanna make the object editable automatically after it is inserted.
                      Then I have modified the codes as follows:
                         ModelingCommandData cd;
                         cd.flags = MODELINGCOMMANDFLAG_CREATEUNDO;
                         cd.doc = doc;
                         cd.bc = conGrid;
                         cd.op = ObjGrid;
                         cd.mode = MODIFY_ALL;
                         
                         SendModelingCommand(MCOMMAND_MAKEEDITABLE, cd);
                      I am sorry, i need to set the width and the height for the plane, so do u have any idea how to insert that. Is it correct what i have done? and could u plz show me how to refresh the view so that after inserting the object, I can see the plane directly(What i am getting now that i could not get the plane directly)
                      By using that code, i am able to make it editable now
                      thanks and best regards

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 09/02/2004 at 23:34, xxxxxxxx wrote:

                        sorry, for the refreshing the view should not be a problem now.
                        Thanks and regards
                        Albert

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post