THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/07/2012 at 00:08, xxxxxxxx wrote:
I'm trying to write a script which I can use to load edge selections and then convert to splines on each frame. I'd like the script to remove the spline created on the previous frame before creating the new spline.
I'd also like this to work with deforming objects by running current state to object on the object before creating the spline, however I've left this part out for now as I cannot get the basic function to work yet.
I'm unsure how to load the selection from the edge selection tag. From my research I understand that you shouldn't call GUI stuff from within a threaded context and as I'm using a python tag, I guess this is why I am getting the following error (illegal operation, invalid cross-thread call) when I try and use…
The script so far will get the object the tag is attached to, then get the child. If the child is a spline it is removed. Then I iterate through all the tags on the object, if there is an edge selection tag, check the name is 'sketch'. Then I need to load the selection from the tag. Next run edge to spline to create the spline.
I am sure my script is wrong in many ways, but if anyone could help me out with some guidance as to how I might achieve this I'd be very grateful!
Here's the script so far…
import c4d from c4d import utils #Welcome to the world of Python def main() : # get object tag is attached to obj = op.GetObject() # get child object child = obj.GetDown() # If child is spline then remove if child: if child.GetTypeName() == "Spline": child.Remove() #Iterate over all tags on object for tag in obj.GetTags() : if tag.CheckType(c4d.Tedgeselection) : # Determine if tag is edge selection if tag.GetName() == "sketch": # check tag name is sketch source = obj.GetClone() print"select edges here" if c4d.utils.SendModelingCommand(c4d.MCOMMAND_EDGE_TO_SPLINE, [source]) : spline = source.GetDown().GetClone() #Return a clone of the selected splines spline.InsertUnder(obj) return spline