SOLVED Create Polygon Selection Tag

Hello, guys!
i have some list of polygons [1, 4, 5] and i need to put these selected values from object in polygon Selection tag (PST), in command lines PST have only commnd GetBaseSelect i need in command like SetBaseSelect

theObject = doc.GetActiveObjects
polySelection = theObject.GetPolygonS()
xmlPolygons = [1, 4, 5]
for xmlPoly in xmlPolygons:
    thePoly = int(xmlPoly) - 1


Hello @djoneeeee,

thank you for reaching out to us. You must instantiate a c4d.SelectionTag and then write that polygon information into it. We have recently provided this example for a point selection tag, your case is almost identical, but you want to create and write to a c4d.Tpolygonselection instead.


@ferdinand hi, thanks for the answer, but I don't understand how this example can help me write polygons to the tag.

I need to select the polygons of the object from the list of polygons and write these polygons to the tag


The example shows you how to do it. The essential information you are likely missing here is that you do not require a SetBaseSelect. When you modify the selection returned by SelectionTag.GetBaseSelect, this will already be reflected in the tag, as the C++ backend method returns a reference/pointer to the selection, not a copy of it.

When you run the script in the quoted topic, you will see that it will create and modify a point selection tag. The only translation work you must do is applying the example to polygons and alter the way the elements are selected, as the example selects them randomly, while you want to use a predefined list.


@ferdinand aaaa i understood, thanks for help megaman)