I managed to parts elements using this script but then I would also like to collect the parted element "parts" in my OUT, somehow I cannot get it right:
I have skipped the standard imports because I think my confusion is between the parameters and the syntax vs API methods.
I tried to use a pre existing codes by
#proposed by Julien Benoit @jbenoit44
#http://aecuandme.wordpress.com/
What I trying to achieve is get elements from the input list and determine if these elements are eligible for creating parts and then create parts from all the ones that return true.
After I would like to collect the parts only (the results) as a list of IDS.
Further, I am looking forward to extend this, so that I can also give a list of curves or lines that it can use to divide the list of parts.
# Make Parts
#feed IN[0] with elements
elts = []
Ids = []
Parts=[]
for i in IN[0]:
elts.append(UnwrapElement(i))
for e in elts:
Ids.append(e.Id)
IDS = List[ElementId](Ids)
# Start transaction of Making Parts
TransactionManager.Instance.EnsureInTransaction(doc)
if PartUtils.AreElementsValidForCreateParts(doc, IDS):
a=PartUtils.CreateParts(doc, IDS)
b=PartUtils.GetAssociatedParts(doc,IDS,True,True)
Parts=[]
for i in b:
Parts.append(doc.GetElement(i).ToDSType(True))
List.append(Parts)
doc.Regenerate()
# End Transaction
TransactionManager.Instance.TransactionTaskDone()
OUT = Parts
I am sure it has something to do with this part:
b=PartUtils.GetAssociatedParts(doc,IDS,True,True)
Parts=[]
for i in b:
Parts.append(doc.GetElement(i).ToDSType(True))
List.append(Parts)
doc.Regenerate()