PDA

View Full Version : Problem adding module tags in python


Decade
11-27-2010, 11:47 AM
Hi guys.

I know how to add the usual phong, protect, vertex tags etc like this :

doc = documents.GetActiveDocument()
obj = doc.GetActiveObject()
my_tag = c4d.BaseTag(c4d.Tphong)
obj.InsertTag(my_tag)

But whenever I try to add any of the Character tags, like Tcaik, I get an error 'Tcaik is not defined'.
Same with hair tags etc

So my question is how can add tags belonging to the modules ?

Thanks.
http://www.plugincafe.com/forum/forum_images/back_to_top.png (http://www.plugincafe.com/forum/forum_posts.asp?TID=5358#top)

Shake0
11-27-2010, 09:05 PM
hi!
yeah, it seems that python miss some tag_class.
i did a brutal method to check it out
for i in dir(c4d):
print i

not all of them work ...

Scott Ayers
11-27-2010, 11:39 PM
What's really bizzare is that the python console seems to recognize it (" TheObject IK(Tcaik) was added as 'IK' ") as something it understands. Yet it can't actually be called to in the code.

Doing a search in the python docs was a dead end.
So the only way I could find to pull this off is by using the coffee CallCommand() to create the tag.
Then once the tag is created. Python lets you edit it's attributes with python code: import c4d
from c4d import gui

def main():
obj = doc.GetActiveObject()
c4d.CallCommand(1019884) # The Coffee ID that creates the IK tag
ft = obj.GetFirstTag()
ft[c4d.ID_CA_IK_TAG_ENABLE]=0 #turn Use IK off
ft[c4d.ID_CA_IK_TAG_IKFK]= .5 #Set IK/FK to 50%

if __name__=='__main__':
main()

-ScottA

Decade
11-28-2010, 01:37 AM
Thanks for your pointers guys. Really getting any feedback at all is very helpful.
I agree scott, i thought it's quite easy to get at the attributes in the usual way if you can create the damn tag to start with.
It's not the end of the world, for my purposes I'll probably just call the 'setup ik chain' command to generate the tag initially but it seems like a pretty major hole in the python implementation if you can't create any tags from the modules. I'm hoping it's possible & we just don't know how.
Anyway, I'll probably proceed to work around for now, or I may use your workaround, scott, it looks pretty tidy.

donelgreeko
11-28-2010, 01:56 AM
Hi, are you looking for the tag with the ID 1019561? You can define the ID manually in the code:


Tcaik = 1019561
tag = c4d.BaseTag(Tcaik)


How I got the ID? I created the tag manually in C4D and dragged it into the Py console.
Calling IK.GetType() returned the ID of the tag which is 1019561.

Cheers, Sebastian

Decade
11-28-2010, 03:14 AM
Sebastian, thanks, that is hugely useful.
I checked the .H file but it didn't have an ID number, so I assumed there wasn't one.
That GetType() code is going to be so useful for me.
I know the Python docs are currently labelled provisional & I understand that but just a few lines & a tiny code snippet in the docs would be so much help to users like myself who are starting to get it but can be easily stopped in our tracks by something that might seem obvious to a more experienced coder. Anyway, thanks for your help everyone, I learned a lot.

CGTalk Moderation
11-28-2010, 03:14 AM
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.