InputPoint picks vertex for all points except the origin of the group

Im trying to write a text by click on the points of a grouped drawing. However, InputPoint.vertex returns nil if i click on the “origin of the group”. it returns a vertex if the group is open!

I’m not sure but I don’t think the origin counts as a vertex, given that ot isn’t physical geometry.

You can still query the InputBox object for its position, even when it doesn’t snap to a vertex, and use degree_of_freedom? to verify it is snapping to a point, rather than a line or a face.

Well, if there’s no vertex there, why i can select it when the group is open?! why sketchup keeps that special vertex away while the group is close? whats the point? why other points of the group return a vertex?

A vertex isn’t the same as a point. A vertex is what the SketchUp UI refers to as an Endpoint, i.e. a node in a mesh. A vertex has connected edges and possibly also faces. If InputPoint finds a vertex on group and component origins I’d say the API is misusing the class vertex, because technically speaking it isn’t a vertex at all.

I see! its a vertex when group is open and its a point when the group is closed?

I haven’t looked into this myself but in theory it shouldn’t be a vertex in any of the cases. In both cases you should be able to query the InputPoint for the position (point) directly.

A point is a position in space, a vertex is a node in a mesh, and have a position. Unless you want to get a direction from an adjacent edge or normal of an adjacent face, or want to move the vertex, I don’t think the vertex is relevant to you.

What is your use case?

i want to add a text to the origin of a group by picking it. any suggestion?

If the text is always going to be added to the origin of the group, and nothing else, you can use a PickHelper to get the selected group (no matter where on the group the user clicks) and add the text to the origin. For adding text within the definition, use ORIGIN as point (the origin in internal coordinates). If the text is in the same drawing context as the group, you can use group.transformation.origin to gets it origin point in the coordinate space of the parent drawing context.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.