×
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

Printing A Single Sheet

Printing A Single Sheet

Printing A Single Sheet

(OP)
I am trying to create some custom commands for printing based off journals I have recorded for the different situations.
The problem I am having is that when I recorded the journal the sheet printed fine but when I rerun the journal the sheet borders do not fill the paper.
I am still very new to both NX and journaling, any help would be greatly appreciated.
Below is the code I am using.
Thanks,
Kevin




' NX 7.5.5.4
' Journal created on Mon Oct 07 06:06:23 2013 Eastern Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Assemblies
Imports NXOpen.Drawings
Imports NXOpen.Annotations

Module NXJournal
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main


Dim displayPart As Part = theSession.Parts.Display
Dim drawingSheet1 As Drawings.DrawingSheet

' ----------------------------------------------
'Menu: View->Operation->Fit
' ----------------------------------------------
workPart.Views.WorkView.Fit()

'-----------------------------------------------
'Adding "Date" Label
'-----------------------------------------------
Dim letteringPreferences1 As LetteringPreferences
letteringPreferences1 = theSession.Parts.Work.Annotations.Preferences.GetLetteringPreferences()
Dim stringArray1(0) As String
Dim point3d1 As Point3d


Dim Annotations_Lettering1 As Annotations.Lettering
Annotations_Lettering1.size = 0.0625
Annotations_Lettering1.CharacterSpaceFactor = 1
Annotations_Lettering1.AspectRatio = 1
Annotations_Lettering1.LineSpaceFactor = 1
Annotations_Lettering1.cfw.color = 2
Annotations_Lettering1.cfw.font = 1
Annotations_Lettering1.cfw.width = Annotations.LineWidth.Thin
letteringPreferences1.SetGeneralText(Annotations_Lettering1)

theSession.Parts.Work.Annotations.Preferences.SetLetteringPreferences(letteringPreferences1)
Dim userSymbolPreferences1 As UserSymbolPreferences
userSymbolPreferences1 = theSession.Parts.Work.Annotations.NewUserSymbolPreferences(UserSymbolPreferences.SizeType.ScaleAspectRatio, 1, 1)


Dim DateString(0) As String
Dim TimeNote As DateTime

TimeNote = System.DateTime.Now()
DateString = TimeNote.GetDateTimeFormats()


stringArray1(0) = DateString(47)
point3d1 = New Point3d(10.25, 8.4, 0)
Dim note11 As Note
note11 = theSession.Parts.Work.Annotations.CreateNote(stringArray1, point3d1, AxisOrientation.Horizontal, letteringPreferences1, userSymbolPreferences1)


' ----------------------------------------------
' Menu: File->Print...
' ----------------------------------------------
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")

Dim printBuilder1 As PrintBuilder
printBuilder1 = workPart.PlotManager.CreatePrintBuilder()

printBuilder1.Copies = 1

printBuilder1.ThinWidth = 1.0

printBuilder1.NormalWidth = 2.0

printBuilder1.ThickWidth = 3.0

printBuilder1.Output = PrintBuilder.OutputOption.WireframeBlackWhite

printBuilder1.RasterImages = True

theSession.SetUndoMarkName(markId3, "Print Dialog")

Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Print")

Dim sheets1(0) As NXObject
sheets1(0) = drawingSheet1
printBuilder1.SourceBuilder.SetSheets(sheets1)

printBuilder1.PrinterText = "PRINTER NAME HERE"

printBuilder1.Orientation = PrintBuilder.OrientationOption.Landscape

printBuilder1.Paper = PrintBuilder.PaperSize.Letter

Dim paper1 As PrintBuilder.PaperSize
paper1 = printBuilder1.Paper

Dim nXObject1 As NXObject
nXObject1 = printBuilder1.Commit()

theSession.DeleteUndoMark(markId4, Nothing)

theSession.SetUndoMarkName(markId3, "Print")

printBuilder1.Destroy()

theSession.DeleteUndoMark(markId3, Nothing)

' ----------------------------------------------
' Menu: Edit->Delete...
' ----------------------------------------------
Dim notifyOnDelete1 As Boolean
notifyOnDelete1 = theSession.Preferences.Modeling.NotifyOnDelete

theSession.UpdateManager.ClearErrorList()

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

Dim objects1(0) As NXObject
Dim note1 As Annotations.Note = note11

objects1(0) = note1
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)

Dim notifyOnDelete2 As Boolean
notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId1)

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

RE: Printing A Single Sheet

The variable drawingSheet1 is never assigned a value. As a result you will be printing whatever is currently displayed on screen when the journal is run.

www.nxjournaling.com

RE: Printing A Single Sheet

Did you get this to work, or are you still having problems?

www.nxjournaling.com

RE: Printing A Single Sheet

(OP)
cowski,

Sorry for not responding sooner, I keep getting pulled off programming to put out other fires. I will try setting the drawingSheet1 value as soon as I can.
Thank you for your help.
Kevin

RE: Printing A Single Sheet

(OP)
cowski,

Got the value set and it is working as intended.
Thanks again,
Kevin

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