# Get Points of a selected Edge

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/06/2011 at 14:17, xxxxxxxx wrote:

Hy there,

I have the indexes of the selected Edges of a Polygon. How can I figure out the corresponding Point values of the Edges or the Point Indexes of the Edges ?

I couldn't find any Methods on the PolygonObject/PointObject that would give me that information ...

Maybe I can convert the Edge selection to a Point selection (but it must not destroy the actual Point Selection on the object)?

Thank you,
maxx

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/06/2011 at 15:42, xxxxxxxx wrote:

Check out the Neighbor class in the utils module. Cheers, Seb

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/06/2011 at 16:18, xxxxxxxx wrote:

Hy there,

yes I found the Neighbor class, but it is not really useful in this case. What do I miss?

I got for example a Polygon-Object and I know that point 5 and 7 is selected. How to get the Point indexes so I can retrieve the point-coordinates?

`Neighbor.GetNeighbor`( a , b , poly )
Gets the polygon opposite to poly with respect to the edge from point a to b.
-> Can't use this method for this, got no polygon upfront

`Neighbor.GetPointPolys`( pnt )
Get the polygons that are attached to the given point index.
-> Can't use this method for this, would have to match two sets of polys and find correlating edges, much too complicated for what I want, right ? Edit: actually It is also not possible, as the two sets have no common edge indexes ...

`Neighbor.GetEdgePolys`( a , b )
Get the polygons that neighbor the given edge:
-> Can't use this method either. Now I've got two polygons. Each Polygon has its own edge-indexes. Or do I need to match the correlating point-coordinates? So many calculations just to get the coordinates of a selected edge ?

`Neighbor.GetEdgeCount`()
-> ...

`Neighbor.GetPolyInfo`( poly )

Get a dict that contains neighbor information about the given polygon. One can use this to browse through all available edges using the following code:
-> Here the same, I would need to retrieve the two polygons and go through all the point-coordinates and match them up ..
There must be a simpler way?

Thank you,
maxx

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/06/2011 at 18:47, xxxxxxxx wrote:

What if you use the SendModeling Command to select the points inside your selected edges like this:

``````import c4d
from c4d import gui,utils

def main() :

obj = doc.GetActiveObject()
bc = c4d.BaseContainer()
bc.SetData(c4d.MDATA_CONVERTSELECTION_LEFT, 1)# ConvertSelection's Left "Edges" option in memory
bc.SetData(c4d.MDATA_CONVERTSELECTION_RIGHT, 0)# ConvertSelection's Right "Points" option in memory
bc.SetData(c4d.MDATA_CONVERTSELECTION_TOLERANT, True)# Select the selection->ConvertSelection's "Tolerant" option in memory
utils.SendModelingCommand(c4d.MCOMMAND_CONVERTSELECTION, list = [obj], mode = c4d.MODIFY_ALL, bc=bc, doc = doc)

if __name__=='__main__':
main()
``````

Then use a "for loop" to cycle through those selected points and pick up their ID's and positions?

-ScottA

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 26/06/2011 at 22:03, xxxxxxxx wrote:

Hy Scott,

>> Maybe I can convert the Edge selection to a Point selection (but it must not destroy the actual Point Selection on the object)?

Thank you for the code. If I can't find another way, I will do it in a similar way. As I want to preserve the actual Point-Selection on the Object, I will need to store the Selection and re-apply it after I read out the points (as also reapply the edge selection).

But I am heavily surprised. Such an elementary task needs involving a Command, retrieving a selection, reading it out (and possibly loop again to do so), retrieve the points, writing back the initial selections ... hugh .. what an act ;)

There must be a better way ...

Cheers,
maxx

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/06/2011 at 13:15, xxxxxxxx wrote:

Hy there,

I am afraid, but the solution with converting the selection is no option either. Once it has been converted, I cannot know which Points belong to an edge ...

There must be a way to do this ??

For each selected edge I need the two points (with coordinates) which define them. Such a difficult problem ?

Thanks,
maxx

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/06/2011 at 15:09, xxxxxxxx wrote:

In the C++ docs. There are some edge functions like EdgeIndex().
This might be what you need. But unfortunately these functions are part of the N-GON class. Which is not supported by Python. So All I can offer is work- arounds.

If the SendModeling "convert" code isn't the ticket.
What about creating a spline based on the selected edge using: c4d.CallCommand(1009671)# Edge to Spline?

The new spline will have the same point locations as your edge.
So you can get the positions from that spline using the spline class functions...Then delete it afterwords.
It's clumsy. But it might be the only way to do it.
Without the N-GON class. I don't know if there is any way to directly get at the verts. of edges with Python.

-ScottA

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/06/2011 at 15:35, xxxxxxxx wrote:

Hey Scott,

Probably I'll go this way, desperate measures, making some knots into the snake :)

But if there really is no way, there is something missing in the Python API. No structure around holding Edge information ?

Thank you,
maxx

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/06/2011 at 15:51, xxxxxxxx wrote:

I know it sounds hard to believe.
But no. I don't see any built in functions to handle edge points directly with Python yet.

There's still lots of things that haven't been ported over from C++ yet.
Python in C4D is still very new(has it even been a year yet?). I think Sebastian has done a great job getting so much converted. In such a short period of time.
In fact..I've been known to ask him to stop adding new stuff. And work on the docs for a while.

-ScottA

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/06/2011 at 16:51, xxxxxxxx wrote:

Yes, I also appreciate Sebastians work greatly. I'd never blame him :)
But Maxon could give him another developer, at least, now, where the integration is official ;)

Btw. here is a script from nophoto (on the c4dnetwork) which uses the relation between the polygon and edge-indexes to create a point-selection. In this way I can also determine which point belongs to which edge.

Cheers,
maxx

import c4d
import math

def main() :

EdgeS = op.GetEdgeS() # Alle selektierten Kanten als 'c4d.BaseSelect'
maxEdgeCnt = op.GetPolygonCount()*4 # Die maximal zu erwartende Anzahl von Kanten

# Eine Liste mit den Indizes aller Selektierten Kanten erstellen
EdgeInd = []
for i in xrange(maxEdgeCnt) :
if EdgeS.IsSelected(i) : EdgeInd.append(i)

Polygons = op.GetAllPolygons()
PointS = c4d.BaseSelect()

for edge in EdgeInd:

PolyInd = int(edge/4) # Der Index des Polygons, zu welchem die Kante mit Index 'edge' geh\rt
PolyEdgeInd = edge-4*(PolyInd) # Der Index der Polygonkante

#print str(edge) + ' = Polygon #' + str(PolyInd) + ' > Polygonkante #' + str(PolyEdgeInd)

Polygon = Polygons[PolyInd]

if PolyEdgeInd is 0:
PointS.Select(Polygon.a)
PointS.Select(Polygon.b)

elif PolyEdgeInd is 1:
PointS.Select(Polygon.b)
PointS.Select(Polygon.c)

elif PolyEdgeInd is 2:
PointS.Select(Polygon.c)
PointS.Select(Polygon.d)

elif PolyEdgeInd is 3:
PointS.Select(Polygon.d)
PointS.Select(Polygon.a)

PointS.CopyTo(op.GetPointS())

if __name__=='__main__':
main()

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/06/2011 at 20:52, xxxxxxxx wrote:

Very cool.
I love to see how that kind of stuff is done by hand.

Thanks for sharing that one.

-ScottA