set size for Ocube?



  • On 06/05/2013 at 18:40, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:      Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Is there a way to set the size of a primitive (Ocube)? I can't find any info. The code below will create a cube with default XYZ.

    op = BaseObject::Alloc(Ocube);
    op->SetName("name"));
    doc->InsertObject(op, NULL, NULL);



  • On 06/05/2013 at 19:05, xxxxxxxx wrote:

    and more questions...
    when I make a Oplane how can I have control over its parameters (segments)?



  • On 06/05/2013 at 19:31, xxxxxxxx wrote:

    This is how to change the some of the various options on a cube primitive:

        BaseDocument *doc = GetActiveDocument();  
      BaseObject *op = BaseObject::Alloc(Ocube);  
      op->SetName("My Cube");  
      op->SetParameter(DescID(PRIM_CUBE_LEN), GeData(Vector(100,50,200)), DESCFLAGS_SET_0);  //Sets the X, Y, Z values for the cube's size  
      
      op->SetParameter(DescID(PRIM_CUBE_SUBX), GeData(2), DESCFLAGS_SET_0);           // number of segments is 2  
      op->SetParameter(DescID(PRIM_CUBE_SUBY), GeData(5), DESCFLAGS_SET_0);           // number of segments is 5  
      op->SetParameter(DescID(PRIM_CUBE_SUBZ), GeData(3), DESCFLAGS_SET_0);           // number of segments is 3   
      
      doc->InsertObject(op, NULL, NULL);
    

    For other options. Drag them from the AM into the bottom of the Console window to get their ID's. Then plugin them into a SetParameter() function in the same manner.
    The other primitives work the same way.

    -ScottA



  • On 06/05/2013 at 19:40, xxxxxxxx wrote:

    Yeah! Thanks.

    I just found out about some SetParameter() stuff. But this helps tremendously.

    Peter



  • On 06/05/2013 at 20:12, xxxxxxxx wrote:

    The one's that are the most complicated looking are the ones for setting position, scale, and rotation.
    They are quite ugly and scary looking when you see them for the first time.
    But once you get used to them. They become less scary.

        BaseObject *obj = doc->GetActiveObject();  
      
      GeData d;   //Used to store the values gotten from obj->GetParameter() below  
      obj->GetParameter(DescID(ID_BASEOBJECT_REL_POSITION, VECTOR_X), d, (DTYPE_VECTOR, DESCFLAGS_GET_0)); //Gets the object's X position  
      
      obj->SetParameter(DescID(ID_BASEOBJECT_REL_POSITION, VECTOR_X), GeData(120.0), DESCFLAGS_SET_0);       //Sets the object's X position to 120
    

    -ScottA



  • On 07/05/2013 at 00:02, xxxxxxxx wrote:

    Or use BaseObject::GetMg() / BaseObject::SetMg().



  • On 08/05/2013 at 13:00, xxxxxxxx wrote:

    Thanks so much for the help. Totally forgot about GetMg().



  • On 08/05/2013 at 23:46, xxxxxxxx wrote:

    GetMg() was related to the position, not the size of the cube.


Log in to reply