- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Whew, It's alright man. No we're not all printing each thing manually. However, you still need to create a program that can take into account the logic needed. Hard to automate something to auto select the one you want, without telling the program to understand its position.
Below you will see my printing script, you will see that the function of my script is to change the place the main symbol object on the front sheet. It changes these depending on the Shop requested order. If I needed to change the sheet size of any of these, I would just set the variable in the beginning to another size enum and print.
So instead of placing a new symbol, I could make this alternate sheet sizes as it prints each item.
This produces a total of 8 finished job read prints of the drawing. Each with the proper identifier on the front sheet, in the order specified by the managers out in production.
Attached is my printing script:
Sub main()
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet1 As Sheet = oDoc.Sheets.Item(1)
try
Dim oSheet2 As Sheet = oDoc.Sheets.Item(2)
Dim oSheet3 As Sheet = oDoc.Sheets.Item(3)
Dim oSheet4 As Sheet = oDoc.Sheets.Item(4)
catch
end try
Dim PrintManager As DrawingPrintManager = oDoc.PrintManager
PrintManager.Printer = "Drafting"
PrintManager.ScaleMode = kPrintBestFitScale
PrintManager.PaperSize = kPaperSize11x17
'PrintManager.PaperSize = kPaperSizeLetter
PrintManager.PrintRange = kPrintAllSheets
'PrintManager.PrintRange = kPrintCurrentSheet
PrintManager.Orientation = kLandscapeOrientation
Dim CheckedLocations As Boolean = False
Dim iIndex As Integer = 1
Try
If Checked_And_Located = False Then
Call PlaceJobNumber()
Call PlaceMe()
'Call JobNumberDelete() 'Checking to make sure item is deleted after printing.
CheckedLocation = True
Else
MessageBox.Show("You must run and place the items before running the rule")
End If
Catch
MessageBox.Show("Please unselect any check box and run rule.")
End Try
'Added double checking boxes, both must be selected for the rule to print.
If Checked_And_Located = True and Notes_Confirmed = True Then
Call CollectLocations(FirstLoc)
Call DeleteAll()
Call ForemanApply(FirstLoc)
Thread.Sleep(2000)
PrintManager.SubmitPrint
Logger.Info("Print Foreman")
Call DeleteAll()
Call TankAssyApply(FirstLoc)
'Print x3 Of the tank assembly
Do While iIndex <= 3
Thread.Sleep(2000)
PrintManager.SubmitPrint
iIndex = iIndex + 1
Logger.Info("Print tank assy #: " & iIndex)
Loop
Call DeleteAll()
Call ForemanApply(FirstLoc)
Thread.Sleep(2000)
PrintManager.SubmitPrint
Logger.Info("Print Foreman")
Call DeleteAll()
Call TankRoomApply(FirstLoc)
Thread.Sleep(2000)
PrintManager.SubmitPrint
Logger.Info("Print Tank room")
Call DeleteAll()
Call FittingsApply(FirstLoc)
Thread.Sleep(2000)
PrintManager.SubmitPrint
Logger.Info("Print FITTINGS")
Call DeleteAll()
Call TankAssyApply(FirstLoc)
Thread.Sleep(2000)
PrintManager.SubmitPrint
Logger.Info("Print tank assy")
Call DeleteAll
Call JobNumberDelete()
End If
End Sub
Sub FittingsApply(ByVal FirstLoc As Point2d)
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim FittingsSymDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("FITTINGS")
Dim oSheet1 As Sheet = oDoc.Sheets.Item(1)
Try
Dim oSheet2 As Sheet = oDoc.Sheets.Item(2)
Dim oSheet3 As Sheet = oDoc.Sheets.Item(3)
Dim oSheet4 As Sheet = oDoc.Sheets.Item(4)
Catch
MessageBox.Show("Missing sheet from default, notify Jesse")
End Try
Logger.Info("First Location X/Y: " & FirstLoc.X & " " & FirstLoc.Y)
Dim FittingsSym As SketchedSymbol = oSheet1.SketchedSymbols.Add(FittingsSymDef, FirstLoc, Nothing, 1)
End Sub
Sub TankRoomApply(ByVal FirstLoc As Point2d)
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim TankRoomSymDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("TANK ROOM")
Dim oSheet1 As Sheet = oDoc.Sheets.Item(1)
Try
Dim oSheet2 As Sheet = oDoc.Sheets.Item(2)
Dim oSheet3 As Sheet = oDoc.Sheets.Item(3)
Dim oSheet4 As Sheet = oDoc.Sheets.Item(4)
Catch
MessageBox.Show("Missing sheet from default, notify Jesse")
End Try
Logger.Info("First Location X/Y: " & FirstLoc.X & " " & FirstLoc.Y)
Dim TankRoomSym As SketchedSymbol = oSheet1.SketchedSymbols.Add(TankRoomSymDef, FirstLoc, Nothing, 1)
End Sub
Sub TankAssyApply(ByVal FirstLoc As Point2d)
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim TankAssySymDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("TANK ASSY")
Dim oSheet1 As Sheet = oDoc.Sheets.Item(1)
Try
Dim oSheet2 As Sheet = oDoc.Sheets.Item(2)
Dim oSheet3 As Sheet = oDoc.Sheets.Item(3)
Dim oSheet4 As Sheet = oDoc.Sheets.Item(4)
Catch
MessageBox.Show("Missing sheet from default, notify Jesse")
End Try
Logger.Info("First Location X/Y: " & FirstLoc.X & " " & FirstLoc.Y)
Dim TankAssySym As SketchedSymbol = oSheet1.SketchedSymbols.Add(TankAssySymDef, FirstLoc, Nothing, 1)
End Sub
Sub ForemanApply(ByVal FirstLoc As Point2d)
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim ForemanSymDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("FOREMAN")
Dim oSheet1 As Sheet = oDoc.Sheets.Item(1)
Try
Dim oSheet2 As Sheet = oDoc.Sheets.Item(2)
Dim oSheet3 As Sheet = oDoc.Sheets.Item(3)
Dim oSheet4 As Sheet = oDoc.Sheets.Item(4)
Catch
MessageBox.Show("Missing sheet from default, notify Jesse")
End Try
Logger.Info("First Location X/Y: " & FirstLoc.X & " " & FirstLoc.Y)
Dim ForemanSym As SketchedSymbol = oSheet1.SketchedSymbols.Add(ForemanSymDef, FirstLoc, Nothing, 1)
End Sub
Sub PlaceMe()
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim PlaceMeDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("PLACE ME")
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
'Starting / default setting
Dim SymbolPosition As Point2d = oTG.CreatePoint2d(30.5, 9.5)
Dim SymbolPosition1st As Point2d = oTG.CreatePoint2d(34.7, 7.375)
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
Dim oSymbol As SketchedSymbol = Nothing
oSymbol = oSheet.SketchedSymbols.Add(PlaceMeDef, SymbolPosition1st, Nothing, 1)
End Sub
Sub DeleteAll()
'Checks every sheet, then all the sketched symbol objects on that sheet. Deletes any that are named from this rule.
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
For Each oSheet As Sheet In oDoc.Sheets
For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
If oSymbol.Definition.Name = "FOREMAN"
oSymbol.Delete
Else If oSymbol.Definition.Name = "TANK ASSY"
oSymbol.Delete
Else If oSymbol.Definition.Name = "TANK ROOM"
oSymbol.Delete
Else If oSymbol.Definition.Name = "FITTINGS"
oSymbol.Delete
Else If oSymbol.Definition.Name = "PLACE ME"
oSymbol.Delete
End If
Next
Next
End Sub ' THis is fine due to its natural creation
Sub CollectLocations(ByRef FirstLoc As Point2d)
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim i As Integer = 1
Dim iSheet As Integer = 1
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
FirstLoc = Nothing
SecondLoc = Nothing
ThirdLoc = Nothing
FourthLoc = Nothing
'goes through each sheet and sketched symbol object. Grabs the position set by the user, then passes those locations into the real notes to be added at printing.
For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
If oSymbol.Definition.Name = "PLACE ME" Then
FirstLoc = oSymbol.Position
End If
Next
Logger.Info("First Location X/Y: " & FirstLoc.X & " " & FirstLoc.Y)
End Sub
Sub PlaceJobNumber()
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
Dim JobNumberDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("Number")
Dim NumberLoc As Point2d = oTG.CreatePoint2d(30, 16)
Dim UserInput As String = Last_Three_Job_No
Dim PromptedStrings As String() = {UserInput}
'For Each otextbox As Inventor.TextBox In JobNumberDef
' If otextbox.Text.Contains("<Number>") = True Then
' otextbox.Text = UserInput
' End If
'Next
Dim JobNumberSym As SketchedSymbol = oSheet.SketchedSymbols.Add(JobNumberDef, NumberLoc, Nothing, 1, PromptedStrings)
End Sub
Sub JobNumberDelete()
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
If oSymbol.Definition.Name = "Number" = True Then
oSymbol.Delete
End If
Next
End Sub