polygon selection effector
-
On 18/04/2017 at 03:15, xxxxxxxx wrote:
Hi,guys.
I try to create an selection effector with plain effector(as in the screenshot).I don't know how to delete xpresso tag when Idelete an polygon selection from taglist.In other words,I want to keep the counts of xpresso tags equel to the counts of taglist all the time.This is my first question.I know how to add xpresso tags according to the polygon selection in the taglist,but the xpresso tags can't be update,but I delete some xpresso tags,they can be update,I don't know how to fix it,This is my second question.
Thanks in advanced!
import c4d def main() : plain = op.GetObject() taglist = plain[c4d.ID_USERDATA,1] xptag = plain.GetTag(c4d.Texpresso,0) cnt = taglist.GetObjectCount() if len(plain.GetTags()) <= cnt-1: for i in xrange(1,cnt) : xptag1 = plain.MakeTag(c4d.Texpresso,xptag) xptag.CopyTo(xptag1,0) for i in xrange(cnt) : seltag = taglist.ObjectFromIndex(doc,i) plain.GetTag(c4d.Texpresso,i)[c4d.ID_USERDATA,1] = seltag
Thank you!
Best wishes!
Ching. -
On 19/04/2017 at 02:51, xxxxxxxx wrote:
Hi Ching,
you are not allowed to modify the scene (in this case adding a new tag) from a tag's Execute() function (and the main() function of the Python tag is basically the same, it's called during evaluation of the scene). See also the Important Threading Information on this topic.
So you will need to do the creation (and deletion) of tags in main thread, easiest to do it is in message function. Declare a message() function next to your main() function in the Python tag. Now, you have several options, like having a button to sync selection tags and xpresso tags or to react on changes of your InExcludeList.
It would roughly look like so:
def message(msgType, data) : # react to parameter change if msgType == c4d.MSG_DESCRIPTION_POSTSETPARAMETER: # check for your InEx user data ID: if data['descid'][0].id == c4d.ID_USERDATA and data['descid'][1].id == ID_UD_INEX: # react on change of the InExList pass # or react to a button elif msgType == c4d.MSG_DESCRIPTION_COMMAND: # check for your button's user data ID: if data['id'][0].id == c4d.ID_USERDATA and data['id'][1].id == ID_UD_BUTTON: # react to button press pass
-
On 22/04/2017 at 01:38, xxxxxxxx wrote:
Thanks Andreas. but the problem is still not fixed.
-
On 25/04/2017 at 05:59, xxxxxxxx wrote:
Hi Ching,
which problem specifically?