×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to find the location of a Part (Child) on my monitor when an assembly is opened VB.NET

How to find the location of a Part (Child) on my monitor when an assembly is opened VB.NET

How to find the location of a Part (Child) on my monitor when an assembly is opened VB.NET

(OP)
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

CODE --> VB.NET

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 

RE: How to find the location of a Part (Child) on my monitor when an assembly is opened VB.NET

Hi User,

Your approach of finding parts inside assembly based on loaction may not be fool proof.
What if
1. The application you try to build ran in a different screen resolution
2. Your logic might fail when the zoom level of your assembly differs with your actual saved view orientation

I would approach this by getting the part (in need) object using NXOpen / UFunc API's to select.

Thanks,
P M

RE: How to find the location of a Part (Child) on my monitor when an assembly is opened VB.NET

Before you write a bunch of code, I suggest looking at turning on object names (preferences -> visualization -> names/borders -> show object names = work view). Turning this option on will show the component names on screen, making particular components easier to find.

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources