Solved! Go to Solution.
Solved by dg2405. Go to Solution.
Is the PDF Creator listed as a printer? There should be options under the Printer Preferences to turn off Prompt for Filename. You can then Apply that to the printer and when you create through the Task Scheduler, it shouldn't ask.
I'm only assuming here. I use Adobe PDF to print and it has this option...
Hi everybody,
thank you for your responses. I figured out that for my situation the be best way is to use Vault-->'Pack and Go' with attached files. By using 'Pack and Go' i can assure that i get the latest drawing version of every part. For PDF-creating i use the Autodesk Scheduling tool and set up a print job to PDF-Creator with 'Autosave' enabled.
So i am able to get about 200 drawings in pdf in like 15 minutes with just a few clicks.
Resurrecting old thread -
Trying out Porter, does nearly what we need, is there a solution that does the same but without an inventor install?
I tried to run this code as an External iLogic Rule and got most of the way through fixing the errors before I realised my mistake. Here is the (fixed) code if anyone would rather have it as an iLogic rule. I have also added the option to print more than one copy at a time.
Sub Main() Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MsgBox("This is NOT an assembly document!", vbExclamation) Exit Sub End If MsgBox("Any .idw files directly referencing " & oAsmDoc.FullFileName & " will not be printed. Print them manually", vbExclamation, "Assembly idw warning") MsgBox("Only idw files that exist on the local drive will be printed. Ensure all .idw files have been downloaded from Vault", vbExclamation, "Vault warning") Dim numCopies As Integer numCopies = InputBox("How many copies of each .idw?", "Copies", 1) Dim oPrintMgr As PrintManager oPrintMgr = ThisApplication.ActiveDocument.PrintManager If MsgBox("Using printer " & oPrintMgr.Printer & ", printing "& numCopies &" copy/s, A4 paper, landscape, B&W. Do you want to continue?", vbYesNo + vbQuestion, "Print Setup Summary") = vbNo Then Exit Sub End If Dim oDrgPrintMgr As DrawingPrintManager dirPath = Left(oAsmDoc.FullFileName, Len(oAsmDoc.FullFileName) - Len(oAsmDoc.DisplayName)) Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document numFiles = 0 For Each oRefDoc In oRefDocs idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) -3) & "idw" Dim fileExists As Boolean If Dir(idwPathName) <> "" Then fileExists = True Else fileExists = False If fileExists Then numFiles = numFiles + 1 Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.Documents.Open(idwPathName, True) oDrawDoc.Activate oDrawDoc = ThisApplication.ActiveDocument oDrgPrintMgr = oDrawDoc.PrintManager oDrgPrintMgr.AllColorsAsBlack = True oDrgPrintMgr.ScaleMode = kPrintBestFitScale oPrintMgr = ThisApplication.ActiveDocument.PrintManager ' Printer setup, default printer oPrintMgr.ColorMode = kPrintDefaultColorMode ' Set to default oPrintMgr.PrintRange = kPrintAllSheets 'Prints all sheets in the idw oPrintMgr.NumberOfCopies = numCopies oPrintMgr.Orientation = kLandscapeOrientation ' Set to print using landscape orientation. oPrintMgr.PaperSize = kPaperSizeA4 'Set the paper size. oPrintMgr.SubmitPrint ' Submit the print. oDrawDoc.Close (True) End If Next MsgBox(numFiles & " idw files have been sent to the printer.",,"Print Summary") End Sub
Here is some code which uses Vault to get all assembly-related drawings and print them. Some lines of the code are specific to our company and are not necessary:
AddReference "Autodesk.Connectivity.WebServices.dll"
Imports ACW = Autodesk.Connectivity.WebServices
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
AddReference "Autodesk.DataManagement.Client.Framework.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase
Public Class ThisRule
Dim idwcounter As Integer = 0
Sub Main()
Dim oApp As Inventor.Application = ThisApplication
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim asmfullfilename As String = oAsmDoc.FullFileName
Dim asmfilename As String = RToBackSlash(oAsmDoc.FullFileName)
'Vault-Addin deaktivieren
Dim vaultAddin As ApplicationAddIn = oApp.ApplicationAddIns.ItemById("{48B682BC-42E6-4953-84C5-3D253B52E77B}")
Dim dsAddin As ApplicationAddIn = oApp.ApplicationAddIns.ItemById("{3AD251E3-02DD-4B8C-8882-86C97C80E00C}")
'iLogic Auto-Regeln deaktivieren
Try 'Wenn Datei nicht gefunden wird kommt sonst Fehler
Rename("C:\Vault-Workspace\Preferences\ilogic Regeln\RulesOnEvents.xml", "C:\Vault-Workspace\Preferences\ilogic Regeln\RulesOnEvents_NotActive.xml")
Catch
End Try
vaultAddin.Deactivate()
dsAddin.Deactivate()
'Baugruppe schließen
oAsmDoc.Close(True)
'Alle Zeichnungen aus dem Vault abrufen
'Auf Vault-Connection zugreifen und ggf. rausgehen
Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then Exit Sub
'Auf ACW-PropertyDefininition Status zugreifen
Dim filePropDefs As ACW.PropDef() = mVltCon.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
Dim ACWNamePropDef As ACW.PropDef
For Each def As ACW.PropDef In filePropDefs
If def.DispName = "Name" Then
ACWNamePropDef = def
Exit For
End If
Next def
'Suchoptionen festlegen
Dim namesucheoptionen As New ACW.SrchCond() With { _
.PropDefId = ACWNamePropDef.Id, _
.PropTyp = ACW.PropertySearchType.SingleProperty, _
.SrchOper = 3, _
.SrchRule = ACW.SearchRuleType.Must, _
.SrchTxt = asmfilename _
}
Dim bookmark As String = String.Empty
Dim status As ACW.SrchStatus = Nothing
Dim results As ACW.File() = mVltCon.WebServiceManager.DocumentService.FindFilesBySearchConditions(New ACW.SrchCond() {namesucheoptionen}, Nothing, Nothing, False, True, bookmark, status)
Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(mVltCon, results(0))
Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(mVltCon)
settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeRelatedDocumentation = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = VDF.Vault.Currency.VersionGatheringOption.Latest
settings.AddFileToAcquire(oFileIteration, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
Dim aquiresults As VDF.Vault.Results.AcquireFilesResults = mVltCon.FileManager.AcquireFiles(settings)
'AsmDoc wieder öffnen
oAsmDoc = oApp.Documents.Open(asmfullfilename,False)
'Alle heruntergeladenen idw's in Liste
Dim idwList As New ArrayList
For Each aquiresult As VDF.Vault.Results.FileAcquisitionResult In aquiresults.FileResults
Dim aquiresultpath As String = aquiresult.LocalPath.FullPath
If UCase(aquiresultpath).Contains(".IDW") Then
If Right(UCase(LWoPoint(aquiresultpath)), 2) = "-Z" _
Or IsNumeric(Right(LWoPoint(aquiresultpath), 2)) = True Then
idwList.Add(aquiresultpath)
End If
End If
Next
'Vars definieren von BOM
Dim oBOM As BOM = oAsmDoc.ComponentDefinition.BOM
Dim oBOMView As BOMView = oBOM.BOMViews("Nur Bauteile")
If oBOMView.BOMRows.Count = 0 Then Exit Sub
Dim oDrwDoc As DrawingDocument
'Zusammenbauzeichnung drucken
For Each idw As String In idwList
If idw.Contains(RPointToBackSlash(oAsmDoc.FullFileName)) Then
idwcounter = idwcounter + 1
oDrwDoc = oApp.Documents.Open(idw, True)
Print(oDrwDoc, True)
oDrwDoc.Close(True)
End If
Next
'Alle Zeichnungen der Einzelteile drucken
GoThruEachBom(oBOMView, idwList)
'AutoRegeln wieder aktivieren
Rename("C:\Vault-Workspace\Preferences\ilogic Regeln\RulesOnEvents_NotActive.xml", "C:\Vault-Workspace\Preferences\ilogic Regeln\RulesOnEvents.xml")
'AsmDoc schließen
oAsmDoc.Close(True)
MessageBox.Show("Es wurden " & idwcounter & " Zeichnungen gedruckt." & vbCrLf & "Wenn Inventor anschließend wieder normal genutzt werden soll, bitte den Inventor schließen und erneut öffnen. Anschließend sind das Vauld- u. DS-Addin wieder geladen.", "Title")
End Sub
Function RToBackSlash(ByVal strText As String) As String
RToBackSlash = Right(strText, Len(strText) - InStrRev(strText, "\"))
End Function
Function RPointToBackSlash(ByVal strText As String) As String
strText = Left(strText, InStrRev(strText, ".") - 1)
RPointToBackSlash = Right(strText, Len(strText) - InStrRev(strText, "\"))
End Function
Function LWoPoint(ByVal strText As String) As String
LWoPoint = Left(strText, InStrRev(strText, ".")-1)
End Function
Function GoThruEachBom(oBomView As BOMView, idwList As ArrayList)
For Each oBomRow As BOMRow In oBomView.BOMRows
Dim oRowDoc As Document = oBomRow.ComponentDefinitions(1).Document
Dim filename As String = RPointToBackSlash(oRowDoc.FullFileName)
For Each idw As String In idwList
If idw.Contains(filename) Then
idwcounter = idwcounter + 1
Dim oDrwDoc As DrawingDocument = ThisApplication.Documents.Open(idw, True)
Dim bezeichnung As String = UCase(oDrwDoc.PropertySets("Design Tracking Properties")("Description").Value)
If bezeichnung.Contains("TISCHPLATTE") _
Or bezeichnung.Contains("GRUNDKÖRPER") _
Or bezeichnung.Contains("DICHTPLATTE") _
Or bezeichnung.Contains("GESTELL") _
Or bezeichnung.Contains("GRUNDPLATTE") Then
System.Threading.Thread.CurrentThread.Sleep(500)
Print(oDrwDoc, True)
Else
System.Threading.Thread.CurrentThread.Sleep(500)
Print(oDrwDoc, False)
End If
oDrwDoc.Close(True)
End If
Next
If TypeOf oRowDoc Is AssemblyDocument Then
If oBomRow.ComponentDefinitions(1).BOMStructure = BOMStructureEnum.kPurchasedBOMStructure Then
GoThruEachBom(oRowDoc.ComponentDefinitions(1).BOM.BOMViews("Nur Bauteile"), idwList)
End If
End If
Next
End Function
Function Print(oDrwDoc As DrawingDocument, printAsA2 As Boolean)
Dim oApp As Inventor.Application = ThisApplication
oDrwDoc.MakeAllViewsPrecise
oApp.CommandManager.ControlDefinitions.Item("DrawingUpdateAllSheetsCmd").Execute2(True)
Dim oDrwPrintMgr As DrawingPrintManager = oDrwDoc.PrintManager
oDrwPrintMgr.ColorMode = PrintColorModeEnum.kPrintColorPalette
oDrwPrintMgr.PrintRange = PrintRangeEnum.kPrintAllSheets
Dim oSheetSize As DrawingSheetSizeEnum = oDrwDoc.Sheets(1).Size
If oSheetSize = DrawingSheetSizeEnum.kA4DrawingSheetSize Then
oDrwPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintFullScale
oDrwPrintMgr.Orientation = PrintOrientationEnum.kPortraitOrientation
oDrwPrintMgr.Printer = "\\KMSSRV10\Kopierer_Konstruktion _A4_Farbe"
oDrwPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA4
End If
If oSheetSize = DrawingSheetSizeEnum.kA3DrawingSheetSize Then
oDrwPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrwPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
oDrwPrintMgr.Printer = "\\KMSSRV10\Kopierer_Konstruktion _A4_Farbe"
oDrwPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA4
End If
If oSheetSize = DrawingSheetSizeEnum.kA2DrawingSheetSize Then
oDrwPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrwPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
oDrwPrintMgr.Printer = "\\KMSSRV10\Kopierer_Konstruktion _A3_Farbe"
oDrwPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA3
End If
If oSheetSize = DrawingSheetSizeEnum.kA1DrawingSheetSize Then
oDrwPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrwPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
oDrwPrintMgr.Printer = "\\KMSSRV10\Kopierer_Konstruktion _A3_Farbe"
oDrwPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA3
End If
If oSheetSize = DrawingSheetSizeEnum.kA0DrawingSheetSize Then
oDrwPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrwPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
oDrwPrintMgr.Printer = "\\KMSSRV10\Kopierer_Konstruktion _A3_Farbe"
oDrwPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA3
End If
If (oSheetSize = DrawingSheetSizeEnum.kA1DrawingSheetSize _
Or oSheetSize = DrawingSheetSizeEnum.kA0DrawingSheetSize) _
And printAsA2 = True Then
oDrwPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
oDrwPrintMgr.Orientation = PrintOrientationEnum.kLandscapeOrientation
oDrwPrintMgr.Printer = "\\KMSSRV10\HP DesignJet T1530 HPGL2 A2"
'oDrwPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA2 'Führt zu Error, warum? Geht auch ohne...
End If
'Logger.Info("Zeichnungsgröße: " & oSheetSize.ToString & "|Druckgröße: " & oDrwPrintMgr.PaperSize.ToString & oDrwPrintMgr.Printer, "dsds")
oDrwPrintMgr.SubmitPrint
End Function
End Class
Hi! I tried to use this code for myself to print all drawings for a file but got an error:
"Error in rule: Print All Drawings, in document: Q13605 06 00 Release.iam
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
In the 'More Info' tab:
"System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.ApplicationAddIns.get_ItemById(String ClientId)
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)"
Do you have any idea what is the cause of the error? I'm literally starting out with iLogic, and I'm getting bogged down with doing my normal work and trying to interrogate the code and find the issue!
Why does it disable the vault add in? Does it need to know the location of the specific printer it will be printed on, i.e. I can't run the code and then choose which printer to run on? All of our drawings are .dwg rather than .idw, I've replaced all in the code, but still getting the same error.
TIA!!!
Hi! Do you have Vault running? Also, the folder paths and file names may need to be changed.
Many thanks!
I think he's stopping at deactivating the addins vault and datastandard. If you don't have datastandard remove the line. You can also completly run the code without deaktivating the addins. It's only for supreesing the update messages while open the drawings if they're not up to date.
Also you don't need this code, it's for deactivating auto iLogic rules.
Try 'Wenn Datei nicht gefunden wird kommt sonst Fehler Rename("C:\Vault-Workspace\Preferences\ilogic Regeln\RulesOnEvents.xml", "C:\Vault-Workspace\Preferences\ilogic Regeln\RulesOnEvents_NotActive.xml") Catch End Try
:
This is fantastic, a great help to going to Vault and selecting drawings individually and printing! Is there a way to give the option to be able to choose A4 or A3 in a pop up?
Thanks,
MG