In my project I’m projecting model points onto a View
. Using View.ModelToViewTransform
typically is all that is required. However, as I’m debugging some features that rely on the positions of Vertex
s, I’m discovering something strange with Vertex.GetPoint()
. It seems to return a spurious value, i.e., the position it returns matches none of the start or end coordinates of any Edge
s connected to it. Is there some extra transform in play for a Vertex
? It would seem to me that GetPoint
for a vertex and GetCurveParams3.StartPoint
for an edge would both return “irreducible” coordinates.
With some testing I verified that Start/EndPoint do yield reliable model coordinates, but GetPoint does not. If you move the View
around on the Sheet
, it will yield different results. The docs don’t seem to hint at any transform intervening between model coordinates and GetPoint
, but there must be one, or else it’s a flawed and useless value.
I guess you got Vertex with GetVisibleEntities2 (swViewEntityType_e.swViewEntityType_Vertex), don’t use it, it’s wrong, I’ve had the same problem, Get the Edge with swViewEntityType_Edge, and then get the Vertex with GetStartVertex and GetEndVertex
@AmenJlili missing a transform is what I’ve suspected but I can’t find anywhere that indicates what that transform would be! Docs for GetPoint
simply say “Array of three doubles representing the x, y, and z coordinates of the point”.
As for a repo, I suppose I might if I get time, but code is ultra minimal. Open a drawing in SWX. In a barebones standalone, simply get visible entities and select the first vertex. If you print GetPoint, you’ll see that its coordinates don’t match model coordinates. (One way to double check this is to print the coordinates of the start/end points of this Vertex’s Edges. None of them will match the coordinates of the Vertex itself. You can also see that GetPoint results will change if you drag the View around a bit and run the standalone again.
I have a solution that works, at least in the scenarios that I’m concerned with.
GetPoint is still useless without knowing whether there’s an undocumented transform, or just an error, and that still bugs me.
But you can get the true model coordinates of the Vertex by cycling through its GetEdges
, and examining their CurveParams->Start/EndPoints, and finding a coordinate set that is common. These are true model coordinates, and can be safely used with View.ModelToViewTransform to project model coordinates into Sheet space.
transform1 = view => ModelToViewTransform;
transform2 = view => GetSketch => ModelToSketchTransform;
Pt = pt => transform1 => transform2