On 16/07/2015 at 16:40, xxxxxxxx wrote:
Hi,
I imported a fractured piece of geometry as a single object and would like to turn each chunk into a unique object with a python script. Luckily i have selection tags for each chunk. Unfortunately I dont know how to iterate through those tags and get their polygons split up.
This is what I would like to do:
1. collect all polygon selection tags that are called "name_piece*", (eg name_piece0, name_piece1, ...)
2. grab their polygon selections and run a "split" modeling commmand on each of them
Would be great if someone could show me how to set this up!
________________________________
Here is what I got so far (some of this is from https://plugincafe.maxon.net/topic/6464/6947_load-edge-selection) :
import c4d
from c4d import utils
from c4d import gui
def findTag(obj, tagtype) :
result = []
tags = obj.GetTags()
for tag in tags:
if tag.CheckType(tagtype) :
# if .GetName() == "name_piece*"
result.append(tag)
return result
def main() :
asset_obj = doc.GetActiveObject()
if asset_obj == None:
return
doc.StartUndo()
doc.AddUndo(c4d.UNDOTYPE_CHANGE, asset_obj)
settings0 = c4d.BaseContainer()
res0 = utils.SendModelingCommand(
command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
list = [asset_obj],
mode = c4d.MODELINGCOMMANDMODE_ALL,
bc = settings0,
doc = doc)
if res0:
doc.InsertObject(res0[0])
sel_obj = doc.GetFirstObject()
if sel_obj == None:
return
sel_obj.Remove()
c4d.EventAdd()
# sel_tag = findTag(sel_obj, c4d.Tpolygonselection, name_piece)[0]
doc.EndUndo()
if __name__=='__main__':
main()