SendModelingCommand -Loop/Ring

On 05/03/2013 at 17:03, xxxxxxxx wrote:

I want to select a ring or a loop with SendModelingCommand.
Unfortunately, the SKD is very confusing here, leaving it up to find out what some do, or not, by trying  😕
http://chicagoc4d.com/C4DPythonSDK/modules/c4d.utils/index.html#c4d.utils.SendModelingCommand
For instance there are many indented and duplicate entries under Untriangulate and ConvertSelection, which obviously don´t seem to have to do anything with it?

Then the tools, which in c4d work not on a selection, but also select it (like loop or ring), don´t seem to take notice of MODELINGCOMMANDMODE_****SELECTION (the same as MODIFY_****SELECTION)?

With the ring loop I got "some" achievment by this:

    bc = c4d.BaseContainer()  
  bc.SetData(c4d.MDATA_RING_EDGE, 22) # Giving an Edge Id for the ring manually  
  bc.SetData(c4d.MDATA_RING_SELECTION, c4d.SELECTION_NEW)  
  
  
  ring = utils.SendModelingCommand(command=c4d.ID_MODELING_RING_TOOL,  
                                  list=[obj],  
                                  mode=c4d.MODELINGCOMMANDMODE_EDGESELECTION,  
                                  bc=bc,  
                                  doc=doc,  
                                  flags=c4d.MODELINGCOMMANDFLAGS_CREATEUNDO)  
  c4d.EventAdd()  
  print ring

But I have to put the edge ID in there manually and got no idea how to find out an edge ID...

Doing the same with Loop Tool just gives me a False feedback, even if I fill out all its options.

   bc2 = c4d.BaseContainer()  
  
  bc2.SetData(c4d.MDATA_LOOP_SEL_STOP_AT_BOUNDS, True)  
  bc2.SetData(c4d.MDATA_LOOP_SEL_SELECT_BOUNDS, False)  
  bc2.SetData(c4d.MDATA_LOOP_SEL_GREEDY_SEARCH, False)  
  bc2.SetData(c4d.MDATA_LOOP_LOOP_EDGE, 11)  
  # bc2.SetData(c4d.MDATA_RING_EDGE, 22)  
  # bc2.SetData(c4d.MDATA_LOOP_SKIP, 0)  
  bc2.SetData(c4d.MDATA_LOOP_SELECTION, c4d.SELECTION_NEW)  
  # bc2.SetData(c4d.MDATA_LOOP_SEL_, 0)  
  
  
  loop = utils.SendModelingCommand(command=c4d.ID_MODELING_LOOP_TOOL,  
                                      list=[obj],  
                                      mode=c4d.MODELINGCOMMANDMODE_EDGESELECTION,  
                                      bc=bc2,  
                                      doc=doc,  
                                      flags=c4d.MODELINGCOMMANDFLAGS_CREATEUNDO)  
  print loop  
  c4d.EventAdd()

On 05/03/2013 at 17:18, xxxxxxxx wrote:

edge ids are being defined under c4d.polygonobject.getedges().

The edges are indexed by 4 * polygon + edge where polygon is the polygon index and edge is the edge index between 0 and 3.

so the polygon with the id 4 will hold edge 4*4+0, +1, +2, (+3). the edge order is the same as
the point order AB, BC, CA or AB, BC, CD, DA.

On 06/03/2013 at 04:27, xxxxxxxx wrote:

Thanks,

for ring selection it kind of works now, but I can´t get a proper undo, it always repeats all the iteration Steps from "for index in select_list:" 😕

    doc = c4d.documents.GetActiveDocument()  
  obj = doc.GetActiveObject()  
  select_list = []  
  neigh = utils.Neighbor()    
  neigh.Init(obj)    
  edgecount = neigh.GetEdgeCount()  
  bs_selected = obj.GetSelectedEdges(neigh, c4d.EDGESELECTIONTYPE_SELECTION)  
  
  doc.StartUndo()  
  doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION, obj)  
  
  for i, index in enumerate(bs_selected.GetAll(edgecount)) :  
      if not index:  
          continue  
      else:  
          select_list.append(i)  
  
  for index in select_list:  
      bc = c4d.BaseContainer()  
      bc.SetData(c4d.MDATA_RING_EDGE, index)    
      bc.SetData(c4d.MDATA_RING_SELECTION, c4d.SELECTION_ADD)  
      # bc.SetData(c4d.MDATA_RING_SKIP, 35)  
  
      utils.SendModelingCommand(command=c4d.ID_MODELING_RING_TOOL,  
                                list=[obj],  
                                mode=c4d.MODELINGCOMMANDMODE_EDGESELECTION,  
                                bc=bc,  
                                doc=doc,  
                                flags=c4d.MODELINGCOMMANDFLAGS_0)  
      doc.EndUndo()  
  c4d.EventAdd()

But ID_MODELING_LOOP_TOOL seems broken, or I´m missing something crucial, anybody got luck with that? It doesn´t do anything besides reporting False...

On 11/03/2013 at 12:15, xxxxxxxx wrote:

Got the ring Undo, by doing it in an isolated Document with a combination of DoUndo...

But could anybody test if the ID_MODELING_LOOP_TOOL __ tool is really broken or me? I´ll report it, if its broken...