Last active
March 7, 2022 16:31
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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