Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a vb journal to set wcs to view

Status
Not open for further replies.

multicaduser

Industrial
Jan 29, 2013
261
Still moving grip programs to journals, and I'm stuck on two problems. One, how to set the wcs to current view, and second, getting the current view scale. Storing and resetting the current wcs is a piece of cake but to set the wcs to current view is eluding me. Recording a journal creates a static array and is no help in how to do it automatically.

The view scale is being used to scale a note to a readable size for the geometry, and the wcs orientation is to place it normal to the screen. The geometry referenced may be as small as a thimble or as large as a truck tire, and all this is being done in a component not an assembly.

A poke in the right direction for these two questions would be appreciated.

NX 12.0.1.7 Windows 10
 
Replies continue below

Recommended for you

Below is some old code I have that returns the view matrix and scale. The view matrix can be assigned to the WCS for orientation. If the note that you are adding is temporary information for the user, you can use a "temporary text" object. IIRC, these will maintain the size and orientation on screen as the user zooms & rotates the view; but they will disappear when the view is refreshed.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Dim theUI As UI = UI.GetUI()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

        lw.Open()

        Dim viewMatrix As Matrix3x3
        viewMatrix = theSession.Parts.Work.Views.WorkView.Matrix
        lw.WriteLine(viewMatrix.ToString)

        Dim viewPt As Point3d = theSession.Parts.Work.Views.WorkView.AbsoluteOrigin
        lw.WriteLine(viewPt.ToString)

        lw.WriteLine("view scale: " & theSession.Parts.Work.Views.WorkView.Scale.ToString)

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        '----Other unload options-------
        'Unloads the image when the NX session terminates
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module

www.nxjournaling.com
 
Thank you cowski, that was awesome, one simple line and it's done.

pmiNoteBuilder1.Style.LetteringStyle.GeneralTextSize = (.125/theSession.Parts.Work.Views.WorkView.Scale)

NX 12.0.1.7 Windows 10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor