ulink2rle
Electrical
- Feb 17, 2017
- 1
I have tried to search for sample code or something that can guide me to the solution but I have not be able to. If you can please help me. What is would like to do is very similar to the problem of getting the location of the cursor on the monitor screen but instead it is the location of a part (in an assembly and I am viewing the assembly on monitor). Ideally, I would like to have a list of locations for all the parts but if someone can guide me to find location of just 1 part, I will very appreciate.
Edited 1: I have some functions that may be able to help me. However, how can I assign the value to "aView"? I guess it must be an active view of my work space
Edited 1: I have some functions that may be able to help me. However, how can I assign the value to "aView"? I guess it must be an active view of my work space
Code:
Function MapView2Abs(ByVal aView As View, ByVal loc As Point3d)
Dim vmx As Matrix3x3 = aView.Matrix
Dim vw() As Double = {0, 0, 0, vmx.Xx, vmx.Xy, vmx.Xz, vmx.Yx, vmx.Yy, vmx.Yz}
Dim abs() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
Dim mx(11) As Double
Dim irc As Integer
Dim c() As Double = {loc.X, loc.Y, loc.Z}
ufs.Trns.CreateCsysMappingMatrix(vw, abs, mx, irc)
ufs.Trns.MapPosition(c, mx)
MapView2Abs = New Point3d(c(0), c(1), c(2))
End Function
Function Reverse(ByVal forward As Point3d)
Reverse = New Point3d(-forward.X, -forward.Y, -forward.Z)
End Function
Function MapAbs2View(ByVal aView As View, ByVal loc As Point3d)
Dim vmx As Matrix3x3 = aView.Matrix
Dim origin_abs As Point3d = MapView2Abs(aView, Reverse(aView.Origin))
Dim vw() As Double = {origin_abs.X, origin_abs.Y, origin_abs.Z, _
vmx.Xx, vmx.Xy, vmx.Xz, vmx.Yx, vmx.Yy, vmx.Yz}
Dim abs() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
Dim mx(11) As Double
Dim irc As Integer
Dim c() As Double = {loc.X, loc.Y, loc.Z}
ufs.Trns.CreateCsysMappingMatrix(abs, vw, mx, irc)
ufs.Trns.MapPosition(c, mx)
MapAbs2View = New Point3d(c(0), c(1), c(2))
End Function