Why twice why? Click twice to make it work :(
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/03/2010 at 17:56, xxxxxxxx wrote:
User Information:
Cinema 4D Version:Â Â Â 11.5Â
Platform:   Windows ;  Â
Language(s) :Â Â Â C.O.F.F.E.EÂ ;---------
Hi to all,
If i select 2 objects with "SetBit(BIT_ACTIVE);" and then i execute a command , it works..But it doesnt work with some commands, example: the contraints, i have to execute the script again to make it work (??) why? Please helpOther small question:
Its posible to use the "doc->FindObject("Sphere");" if we are not inside "main(doc,op)" ?
**Thanks a lot** and i dont want to abuse asking here so i guess i'll limit myself to 3 questions per week or something
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2010 at 01:08, xxxxxxxx wrote:
For your first question, please provide some code showing the problem.
For the second question, use GetActiveDocument() to obtain the currently active document.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2010 at 01:56, xxxxxxxx wrote:
Thanks Matthias! question 2 solved !!
About question 1, if I select several objects and execute for example the "bind" command, it works, but for this parent constraint i have to press 2 times the execute of the script to make it work.
I can do it manually placing a parent tag, but then im with other problem: i have no idea how to "add a target" like when pressing the "add" button the the constraint attributes, or if is posible to send the command of pressing that button too.
Here is the code i have to press 2 times to make it work:
main(doc,op)
{var b;
var c;var b = doc->FindObject("Cube");
var c = doc->FindObject("Sphere");b->SetBit(BIT_ACTIVE);
c->SetBit(BIT_ACTIVE);CallCommand(1022416); // Add Parent Constraint
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2010 at 06:31, xxxxxxxx wrote:
I cna confirm this. Problem is even if you add manually constraint tags it's tricky to access the target link fields because they are dynamic descriptions.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2010 at 10:55, xxxxxxxx wrote:
Ummm... ok, so how can I make the command to work, because it works if is pressed 2 times, maybe a way to execute it 2 times inside the script ?...
I tried just copy pasting the code 2 times inside the script and some stuff like that but it doesnt work
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2010 at 12:02, xxxxxxxx wrote:
Currently I see no way doing it in COFFEE.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2010 at 14:45, xxxxxxxx wrote:
I used a recursive code by you I think, Matthias
No Undo put in this.GetObject(op) //recursive function of the complete object hierarchy {      while(op)      {      if(op->GetBit(BIT_AOBJ))       {        var pc = AllocTag(1019364); // Make the Constraint Tag            pc#ID_CA_CONSTRAINT_TAG_PARENT = TRUE; // Parent mode on            op->InsertTag(pc); // Add it to active op       }           GetObject(op->GetDown()); //recursion           op = op->GetNext();      } } main(doc,op) { var b = doc->FindObject("Cube"); var c = doc->FindObject("Sphere"); b->SetBit(BIT_ACTIVE); c->SetBit(BIT_ACTIVE); GetObject(doc->GetFirstObject()); // Do the tag adding }
Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2010 at 15:03, xxxxxxxx wrote:
Hi Lennart, that code just adds the tag, but the problem is it doesnt adds the parent target, and also its makig the tag appearing in both objects instead of just one with the other as a parent... this code just enables the "parent" checkbox in the tag, but there are not targets.
If the constraint tag has already a targets slot added, then its posible easily with coffe to asign the target there, but how to add targets slots without pressing the "add" button in the atributes of the tag, by coffee its a mystery to me.
So i tought a easier solution was to just select 2 objs with coffe and execute:Â CallCommand(1022416); _// Add Parent Constraint
_ But there is where i have to click the script 2 times (for some mysterious reason for me) and it works...Posible workaround: (I hope there is another way! )
Maybe a posible solution for at least 1 target is to have the tag already with one slot added, saved in a file, so then its merged into the scene and copied to the objects needed and then assign the parent target by coffe to that available slot................... -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/03/2010 at 07:33, xxxxxxxx wrote:
Oh, I misunderstood your issue.
Please look at the example code here.
It should get you an idea how to set things like thing up.
An important part is to search the API folder of Cinema to
find res documents containing the correct IDs and such.Cheers
Lennart// Add_ParentConstraint_w_2_Objects tcastudios 2010 // Select 2 objects. The first becomes the Parent the second gets the tag main(doc,op) { doc->StartUndo();      // Start Undo var parent = object(); // First active object if(!object()) return; // Nothing selected var slave = parent->SearchNext(BIT_AOBJ); // Next active Object if(!slave) return;                        // Nothing more selected var ct = AllocTag(1019364);                     // Make the Constraint Tag      doc->AddUndo(UNDO_TAG_NEW,ct);              // Add Undo new tag           ct#ID_CA_CONSTRAINT_TAG_PARENT = TRUE; // Set Parent Mode on           slave->InsertTag(ct);                  // Add tag to op, our slave object CallButton(ct,ID_CA_CONSTRAINT_TAG_PARENT_ADD); // Add Target field in constrain tag ct#30001 = parent; // Add our Parent object into the Target field ct#30004 = TRUE;   // Pos ON ct#30005 = TRUE;   // Scale ON ct#30006 = TRUE;   // Rot ON doc->EndUndo();    // End Undo }