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.


  • 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:
        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:
            obj = c4d.PolygonObject(len(points), len(new_polys))
            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])
        root = None
        if len(result) == 1:
            root = result[0]
            root = c4d.BaseObject(c4d.Onull)
            for obj in result:
        doc.AddUndo(c4d.UNDOTYPE_NEW, root)
    if __name__ == '__main__':

    Note that it uses the Optimize Command to remove the points it will not need.


  • 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 ;)


Log in to reply