Hi folks, I am actively trying to learn Python for Cinema 4D, and lately I have been struggling with edge selection, specifically the Loop and Ring functions.
I got the code working as expected in r21, but in r25 and 2024 it no longer works, I have been trying to figure out what the problem is, but alas, I have not been able to. I would really appreciate it if you could show me what I am missing
import c4d
from c4d import utils
def select_ring_edge(obj, edge_id):
bc = c4d.BaseContainer()
bc.SetData(c4d.MDATA_RING_EDGE, edge_id)
bc.SetData(c4d.MDATA_RING_SELECTION, c4d.SELECTION_NEW)
result = c4d.utils.SendModelingCommand(
command=c4d.ID_MODELING_RING_TOOL,
list=[obj],
mode=c4d.MODELINGCOMMANDMODE_EDGESELECTION,
bc=bc,
doc=c4d.documents.GetActiveDocument(),
flags=c4d.MODELINGCOMMANDFLAGS_CREATEUNDO
)
c4d.EventAdd()
return result
def main():
doc = c4d.documents.GetActiveDocument()
obj = doc.GetActiveObject()
if obj is None:
c4d.gui.MessageDialog("select obj.")
return
edge_index = 3
result = select_ring_edge(obj, edge_index)
if result:
print("DONE")
else:
print("ERROR")
if __name__ == '__main__':
main()