M

@zipit said in PolygonObject.SetSelectEdges() and the Neighbor() class, a giant dilemma:
Hi,
edges are globally indexed by polygon_index * 4 + local edge_index (see PolygonObject.GetEdgeS), where the local edge index lies in the interval [0, 3]. So the edge between the points c and d of the polygon with the id 10 would have the index 43. You will have to pass edges in this form to SetSelectEdges, the function will then turn your partial edge selection into a full selection by selecting the corresponding global edge indices of polygons that share the selected edges.
You can also do the same by using the Neighbor class and do it manually by retrieving the polygons attached to an edge defined by two points.
Cheers,
zipit
The whole point of SetSelectedEdges is not to do the 4*PolygonIdx+PolygonEdgeIdx math and have to supply multiple physical edges where a single logical edge from Neighbor will suffice).
Please reread the below quoted portion of my post and especially the part I marked in bold:
SetSelectedEdges(self, e, pSel, ltype)
..., method takes a pSel argument of type BaseSelect.
The help for this method further tells us that:
The edges are indexed uniquely by a Neighbor object, so each
edge has a single index.
This tells us that we should not use the 4*PolygonIdx+PolygonEdgeIdx formula to specify the edge indices for the BaseSelect, but instead refer to the logical edge indices as determined and governed by the Neighbor object after it does its calculations. The problem and crux of the question is that we don't know what those edges are, since they don't seem to be accessible to code that is outside of the Neighbor object. This information seems to be encapsulated within the Neighbor's guts and hidden from the users of the object, making it inadequate for its intended role in this case: The selection of a subset of the logical edge indices from the Neighbor as required by the pSel argument of SetSelectedEdges().
My point with regard to which edge indexes to use is further driven home by the following sample code that appears in the help for BaseSelect.SelectAll() which shows the correct usage of the BaseSelect with the SetSelectedEdges() method and coincides completely with what I am asserting:
def main():
nbr = c4d.utils.Neighbor()
nbr.Init(op) # Initialize neighbor with a polygon object
edges = c4d.BaseSelect()
# Select all edges in the range [0, nbr.GetEdgeCount()-1]
edges.SelectAll(nbr.GetEdgeCount()-1)
# ### Dev Comments
# ### ============
# ### The preceding line clearly demonstrates that Neighbor based
# ### logical indices should be used with the BaseSelect since
# ### nbr.GetEdgeCount() returns the number of Neighbor deduced
# ### logical edges and not the total number of (potential)
# ### physical edges (i.e., which would be 4*num_polys), at least the
# ### the way I understand it.
# Select all edges from our edges selection
op.SetSelectedEdges(nbr, edges, c4d.EDGESELECTIONTYPE_SELECTION)
c4d.EventAdd() # Update Cinema 4D
if __name__ == '__main__':
main()
Note: The Dev Comments portion in the above code was added by me to point out what can be deduced from the line of significance in the sample code from the help documentation.