Solved Face associated with a selection

Hi,

I have a polygon with multiple selections.
For each selection, I want to know the list of faces (presented as a list of indices)

selection.jpg

For a polygon I know how to access each selection:

tag = polygone.GetFirstTag()
while tag:
	if tag.GetType() == c4d.Tpolygonselection:
	print tag.GetName()
	..
	...
	...
	tag = tag.GetNext()

If you can replace the dotted lines with the correct code, thanks

A SelectionTag (no matter what type the selection is) has a method GetBaseSelect which returns a (reference to the contained) c4d.BaseSelect object which in turn contains the needed functions:
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/BaseSelect/index.html

(You may want to have an eye on the API description which can answer these easy questions without the need to write an elaborate question :-) )

Hi,

I think @Cairyn gave the correct answer. You must retrieve the BaseSelect of the tag.

You may also want to read ou forum Guidelines where you can learn how to mark your thread as a question and set them as solved once it's done. Using the tags also help a lot for us to know which language you are using (if no code is provided).

def main():
    tag = op.GetFirstTag()
    polyCount = op.GetPolygonCount()
    while tag:
        if tag.GetType() == c4d.Tpolygonselection:
            bs = tag.GetBaseSelect ()
            states = bs.GetAll(polyCount)
            print (states )
            indices = (pid for pid, item in enumerate(states) if item)
            print (indices)
        tag = tag.GetNext()

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

Thanks for your quick replies

I used GetBaseSelect() which allowed me to have the selected faces for each selection

		list_polygon = obj.GetAllPolygons() 
		dim = len(list_polygon)

		L = []
		tag = obj.GetFirstTag()
		while tag:
			if tag.GetType() == c4d.Tpolygonselection:
				sel = tag.GetBaseSelect()
				L2 = []
				for i in range(0,dim):
					if sel.IsSelected(i):
						L2.append(i)
						
				L.append([tag.GetName(),L2])
			tag = tag.GetNext()	
			
		for item in L:
			print item[0]
			print item[1]