Skip to content

Instantly share code, notes, and snippets.

@fwilleke80
Last active March 7, 2022 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwilleke80/cd5cab475c3a2b83ff49fbd6287b02b2 to your computer and use it in GitHub Desktop.
Save fwilleke80/cd5cab475c3a2b83ff49fbd6287b02b2 to your computer and use it in GitHub Desktop.
This script prints the indices of the selected polygons of the active polygon object to the console.
import c4d
def main():
if op is None:
print("No object selected.")
return True
if op.GetType() != c4d.Opolygon:
print("Selected object is not a PolygonObject.")
return True
polySelection = op.GetPolygonS()
if polySelection is None:
print("Could not get polygon selection!")
return True
if polySelection.GetCount() == 0:
print("No polygons are selected.")
return True
polyCount = op.GetPolygonCount()
selection = polySelection.GetAll(polyCount)
listOfSelectedPolygons = []
for i in range(polyCount):
if (selection[i] == 1):
listOfSelectedPolygons.append(i)
print(len(listOfSelectedPolygons), "Selected polygons:", listOfSelectedPolygons)
return True
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment