constraint tag in phyton

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  09 September 2012
constraint tag in phyton

Hi everyone,

I am currently doing an Xpresso set-up and have to use the phyton node in it. I am not very familiar with phyton but as far until now I managed everything. Now I am just stucking.

I am creating over the phyton node an object which should have an constraint tag on it and clamped to a point-selection I am reading in over Xpresso.

So far I managed to create the constraint tag, activated the clamp and put it on the locator (a null object) here is the code I used:

constr=c4d.BaseTag(1019364)
constr[c4d.ID_CA_CONSTRAINT_TAG_CLAMP]=1
constr[c4d.ID_CA_CONSTRAINT_TAG_CLAMP_TARGET_COUNT]=1

locator.InsertTag(constr)

But how can I now change the clamp modus to point? I think I can access it over constr[50004] but then I don't know how to change it to point and how to add my point selection into the goal further down.

Would be great if someone could help me and thanks a lot
 
  09 September 2012
I think this is best done with a script, as XPresso will add a new tag upon each refresh.

For this example, the Point Selection tag is loaded into a User Data link on the Null. You can of course access it however you like.

import c4d
   
   def main():
   	constr = c4d.BaseTag(1019364)
   	constr[c4d.ID_CA_CONSTRAINT_TAG_CLAMP] = True
   	constr[50004,1] = c4d.ID_CA_CONSTRAINT_TAG_CLAMP_TO_POINT
   	
   	sel_tag = op[c4d.ID_USERDATA,1]
   	constr[50001] = sel_tag
   	
   	op.InsertTag(constr)
   	
   	c4d.EventAdd()
   
   if __name__=='__main__':
   	main()
 
  09 September 2012
Hey,

thanks a lot for your help :-) Nect time I will post it in the sub-code forum. I started to script it completely without using Xpresso, but I am still not getting it working completely. Would you mind help me again?

I managed to set up the tag and then activate the clamp and then I get an error message. It should be this line:

constr[50004,1] = c4d.ID_CA_CONSTRAINT_TAG_CLAMP_TO_POINT

The error message is: TypeError=_setitem_got_unexpected type 'int'

so I guess it might be the 1, but I don't know what I have to change to make it work. I just don't know enough about phyton yet.

Another thing you said was about the user link data on my null object. I know how to set them up, but then I have to use a phyton tag on this null object so that I can get easily access to them, don't I?
 
  09 September 2012
No worries. Here are the test project and script. Place the script in the preferences folder, in library/scripts and access it via the Script Manager. It should run without errors.

In the previous example the script was executed on the Null, so the User Data was accessed with op[c4d.ID_USERDATA,1]. The script has been updated to find a selection tag by iterating through an object's tag list. First navigate to the object using the GeListNode functions.
 
  09 September 2012
Hey,

thanks a lot for your help :-) I put some of my parts into the script as well, as I have to create some nulls etc. and now it is nearly working :-) You really helped me a lot :-)
 
  09 September 2012
No problem, glad to hear that it's working. Enjoy your explorations into Python.
 
  09 September 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:43 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.