Creating a Constraint Tag

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

On 22/11/2010 at 06:50, xxxxxxxx wrote:

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

---------
Hi!
Can anybody tell me please what I have to do to create a Constraint Tag (PSR)??
Thanks!

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

On 23/11/2010 at 05:32, xxxxxxxx wrote:

Simple example how to create a CA Constraint tag and add a PSR target.

  
Bool MenuTest::Execute(BaseDocument *doc)  
{  
  // constraint object  
  BaseObject *op1 = doc->GetFirstObject();  
  if (!op1) return FALSE;  
  
  // target object  
  BaseObject *op2 = op1->GetNext();  
  if (!op2) return FALSE;  
  
  // create the tag  
  BaseTag *tag = op1->MakeTag(1019364, NULL);  
  if (!tag) return FALSE;  
  
  op1->Message(MSG_UPDATE);  
  
  // enable PSR constraints  
  tag->SetParameter(DescID(ID_CA_CONSTRAINT_TAG_PSR), GeData(TRUE), DESCFLAGS_SET_0);  
  
  // calls the Add button to add a target  
  DescriptionCommand dc;  
  dc.id = DescID(DescLevel(ID_CA_CONSTRAINT_TAG_PSR_ADD, DTYPE_BUTTON, tag->GetType()));  
  
  tag->Message(MSG_DESCRIPTION_COMMAND, (void* )&dc);  
  
  AutoAlloc<BaseLink> link;  
  if (!link) return FALSE;  
  
  link->SetLink(op2);  
    
  // sets the link to the target object; target link IDs start with 10001 for the first target, 10002 for the second and so on  
  tag->SetParameter(DescID(10001), GeData(link), DESCFLAGS_SET_0);  
  
  tag->Message(MSG_UPDATE);  
  
  EventAdd();  
    
  return TRUE;  
}  

cheers,
Matthias

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

On 24/11/2010 at 07:43, xxxxxxxx wrote:

thanks a lot!