Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Printing A Single Sheet

Status
Not open for further replies.

kr7530

Automotive
Joined
Aug 9, 2011
Messages
130
Location
US
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
 
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
 
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
 
cowski,

Got the value set and it is working as intended.
Thanks again,
Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top