extract separat objects from Polgon-selction-tags
-
On 27/05/2014 at 05:19, xxxxxxxx wrote:
Hi There,
I'm looking for a script like that:
Is there still a possibility to extract separat objects from Polgon-selction-tags of
a imported Object, witch contains many of those Polygon-selection-tags?
It have been a multi-hierarchy-object but this structure is collapsed in to one object.Any one an idea?
It would be very nice to get a script or any thing else for those issues.
Thx
-
On 28/05/2014 at 03:06, xxxxxxxx wrote:
Try this in the Script Manager (select your Polygon Object) :
import c4d is_polyselection = lambda x: x.CheckType(c4d.Tpolygonselection) def main() : if not op or not op.CheckType(c4d.Opolygon) : c4d.gui.MessageDialog('Please select a Polygon Object') selections = filter(is_polyselection, op.GetTags()) if not selections: return result = [] points = op.GetAllPoints() polys = op.GetAllPolygons() for tag in selections: sel = tag.GetBaseSelect() new_polys = [] for i, v in enumerate(sel.GetAll(len(polys))) : if not v: continue new_polys.append(polys[i]) obj = c4d.PolygonObject(len(points), len(new_polys)) obj.SetAllPoints(points) for i, p in enumerate(new_polys) : obj.SetPolygon(i, p) obj.SetName('%s - %s' % (op.GetName(), tag.GetName())) c4d.utils.SendModelingCommand(c4d.MCOMMAND_OPTIMIZE, [obj]) result.append(obj) root = None if len(result) == 1: root = result[0] else: root = c4d.BaseObject(c4d.Onull) root.SetName(op.GetName()) for obj in result: obj.InsertUnderLast(root) doc.StartUndo() doc.InsertObject(root) doc.AddUndo(c4d.UNDOTYPE_NEW, root) doc.EndUndo() c4d.EventAdd() if __name__ == '__main__': main()
Note that it uses the Optimize Command to remove the points it will not need.
-Niklas
-
On 29/05/2014 at 04:57, xxxxxxxx wrote:
Jihaaaaaa!!!! It works!
I put in your Code in to the Pythonconsole and the result was fine.
Thanks for that amazing script.(Is there still a chance to tune it up with a extra feature to center axis of all the new Objects?)
PS: von wo aus aus BRD kommst du? Die Brücke kommt mir bekannt vor. **** **** ****
-
On 29/05/2014 at 06:01, xxxxxxxx wrote:
Ahh sorry, now I see...
it have to be necessary to optimize/kill all the needless points before.
After that I can center the axes. This I can make in one shot for multible objects.(I have to think before I write)
regards from Cologne
-
On 30/05/2014 at 09:40, xxxxxxxx wrote:
You're welcome.
I'm from Bavaria But the Sidney Harbour Bridge is surely anything but near your location
Cheers,
-Niklas