×
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

Plot journal

Plot journal

Plot journal

(OP)
I’m working on the journal that will plot current drawing using plot profiles.
My code works only after entering PLOT menu, otherwise it gives an error.
Can someone help me fix this.

CODE

Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Drawings

Public Class Program
    ' class members
    Private Shared theSession As Session
    Private Shared theUI As UI = UI.GetUI
    Private Shared theUfSession As UFSession
    Private Shared lw As ListingWindow

    ' class methods
    Public Shared Function Main(ByVal args As String()) As Integer

        theSession = Session.GetSession()
        theUI = UI.GetUI()
        theUfSession = UFSession.GetUFSession()
        lw = theSession.ListingWindow
        'TODO: Add your application code here 
        lw.Open()

        ' check for existing target work part
        Dim disp_part As Part = theSession.Parts.Display
        If disp_part Is Nothing Then
            lw.WriteLine("No displayed part...exit.")
            Return 1
        End If

        Dim sheetCollection As DrawingSheetCollection = disp_part.DrawingSheets
        Dim sheetArray As DrawingSheet() = sheetCollection.ToArray()
        Dim currentSheet As DrawingSheet = sheetCollection.CurrentDrawingSheet
        If currentSheet Is Nothing Then
            lw.WriteLine("No current drawing sheet found...exit." & vbLf)
            Return 1
        End If

        Dim noteText As String() = New String(2) {}

        Dim sheetNumber As Integer = 0
        For ii As Integer = 0 To sheetArray.Length - 1
            If currentSheet.Name = sheetArray(ii).Name Then
                sheetNumber = ii + 1
                Exit For
            End If
        Next

        Dim jobOpts As UFPlot.JobOptions = Nothing
        Dim bannerOpts As UFPlot.BannerOptions = Nothing
        Dim s As UFSession = UFSession.GetUFSession()
        Dim plot As UFPlot = s.Plot

        Dim ploter As String = "HP DJ 500 Ploter"
        Dim Profile As String = Nothing
        Dim ShSize As String

        ShSize = currentSheet.Length & "x" & currentSheet.Height

        ' lw.WriteLine(ShSize.ToString)


        If ShSize = "210x297" Then

            Profile = "A4"

        ElseIf ShSize = "420x297" Then

            Profile = "A3"


        ElseIf ShSize = "594x420" Then

            Profile = "A2"


        ElseIf ShSize = "841x594" Then

            Profile = "A1"

        ElseIf ShSize = "841x1189" Then

            Profile = "A0"

        End If

        plot.AskDefaultJobOptions(jobOpts)
        plot.AskDefaultBannerOptions(bannerOpts)

        Dim sheet As Tag
        s.Draw.AskCurrentDrawing(sheet)

        Dim JobName As String
        plot.AskDefaultJobName(sheet, JobName)

        plot.Print(sheet, jobOpts, JobName, bannerOpts, ploter, Profile, 1)


    End Function

    Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
        'Unloads the image immediately after execution within NX
        Return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately)
    End Function

End Class 

RE: Plot journal

Are you sure the "ploter" name is spelled correctly? Computers are picky...

www.nxjournaling.com

RE: Plot journal

(OP)
Yes, the ploter name is correct. In NX9 error says: "NXOpen.NXException: SDI Enviroment not setup" whereas NX8.5 error:"Invalid printer for plotting". Journal works only after I open and close PLOT menu.

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