TranslateCoordinates

TranslateCoordinates

Anonymous
Not applicable
400 Views
5 Replies
Message 1 of 6

TranslateCoordinates

Anonymous
Not applicable
I'm trying to break a 3dpolyline with a function i wrote, but when i change the view to 3dorbit, the picked point coordinates change, which is logical but how can you make (maybe convert...) the picked point coordinates to be on the 3dpolyline.

Basicaly I want to get the coordinates on the 3dpolyline in 3dorbit view. Beacuse in 3dorbit view i get totally different coordinates than in normal view (top,bottom,...)

Tnx in advance

Greets
0 Likes
401 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Have you tried translating it to world, I use these 2 functions to save typing.
Function ToUcs(Pt As Variant) As Variant
ToUcs = ThisDrawing.Utility.TranslateCoordinates(Pt, acWorld, acUCS, False)
End Function
Function ToWcs(Pt As Variant) As Variant
ToWcs = ThisDrawing.Utility.TranslateCoordinates(Pt, acUCS, acWorld, False)
End Function

I presume the real problem is that the point you are picking (like that in getentity) is not actually on the object so will never translate. I use a complicated version for lwplines but I think you may need to get Frank O's curve class to find the closest picked point.
0 Likes
Message 3 of 6

Anonymous
Not applicable
And where could i get that?

Thanks for the info btw.

Greets
0 Likes
Message 4 of 6

Anonymous
Not applicable
Another way to do it would be to calculate this point with my own function.

The only problem is that i don't know where to read the direction vector of my current view, and where to get the center coordinate from my view.

P.S. I have been looking at thisdrawing.activeviewport.direction and *.center but this values don't allways refresh when i change view from top to bottom or to something else.

Thank you!
0 Likes
Message 5 of 6

Anonymous
Not applicable
This is part of a lwpolyline class, but like you say there is no refresh
[code]
Private Function PickPointToPolyElevation() As Variant

'Ax+ By + Cz + d = 0 formula for a plane where d=-oLWP.Elevation
'pickpoint is line of sight to a ucs point w/ z=zero
Dim V, n, Dir
Dim newV(2) As Double
Dim Dist As Double
Dim ovpt As AcadViewport
Dim vPt
n = oPline.Normal 'A 3D normal unit vector in WCS. Being a unit vector it's length=1
V = varPick
V = ToWcs(V) 'Get the real v
ThisDrawing.Save 'Updates the viewport
Set ovpt = ThisDrawing.ActiveViewport
Dir = ThisDrawing.ActiveViewport.Direction
Dist = (oPline.Elevation - (V(0) * n(0)) - (V(1) * n(1)) - (V(2) * n(2))) _
/ ((Dir(0) * n(0)) + (Dir(1) * n(1)) + (Dir(2) * n(2)))
newV(0) = V(0) + Dist * Dir(0)
newV(1) = V(1) + Dist * Dir(1)
newV(2) = V(2) + Dist * Dir(2)
PickPointToPolyElevation = newV
'varPick = newV
End Function
[/code]
Notice the use of save. Totally lame as I get an error when refediting. Probably the same when you are in 3dorbit, other than that it works well.
0 Likes
Message 6 of 6

Anonymous
Not applicable
Thanks ThisDrawing.Save works for me
0 Likes