- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi.
I have an issue trying to export 3D PDF files in batch. When I go through all occurrences in an assembly trying to export all single components (parts and assemblies) to 3D PDF, the 3D PDF creation fails.
I think I also figured out why. It seems that a (to be exported) component must be opened visible to let the 3D PDF creation succeed. The problem is, I want the process to run invisible.
This is my code until now. I added notes what to (un)comment:
Sub Main
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
For Each oOcc As ComponentOccurrence In oCompDef.Occurrences
Dim oOccDoc As Document = oOcc.Definition.Document 'Comment for working code
' Dim oOccDoc As Document = ThisApplication.Documents.Open(oOcc.Definition.Document.FullFileName) 'Uncomment for working code
Export3DPDF(oOccDoc, "C:\TEMP", "Testfile", AccuracyEnum.kHigh)
' oOccDoc.Close 'Uncomment for working code
Next
End Sub
Sub Export3DPDF(ooModelDocument As Document, ooSaveFolder As String, ooFileName As String, ooAccuracy As AccuracyEnum, Optional ooTemplatePath As String = "") 'TEmplate optional???
'Get the 3D PDF Add-In.
Dim oPDFAddIn As ApplicationAddIn
Dim oAddin As ApplicationAddIn
For Each oAddin In ThisApplication.ApplicationAddIns
If oAddin.ClassIdString = "{3EE52B28-D6E0-4EA4-8AA6-C2A266DEBB88}" Then
oPDFAddIn = oAddin
Exit For
End If
Next
If oPDFAddIn Is Nothing Then
' MessageBox.Show("Inventor 3D PDF Addin not loaded.")
Exit Sub
End If
'Get PDF Converter
Dim oPDFConvertor3D
oPDFConvertor3D = oPDFAddIn.Automation
' Create a NameValueMap object as Options
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oSaveLocation As String = ooSaveFolder
If oSaveLocation.EndsWith("\") = False Then oSaveLocation = oSaveLocation & "\"
Dim oNewFileName As String = ooFileName & ".pdf"
Dim oFullPath As String = oSaveLocation & oNewFileName
' Options
oOptions.Value("FileOutputLocation") = oFullPath
oOptions.Value("ExportAnnotations") = 1
oOptions.Value("ExportWokFeatures") = 0
oOptions.Value("GenerateAndAttachSTEPFile") = False
oOptions.Value("VisualizationQuality") = ooAccuracy
oOptions.Value("ExportAllProperties") = True
oOptions.Value("ExportTemplate") = ooTemplatePath
oOptions.Value("LimitToEntitiesInDVRs") = True
oOptions.Value("ViewPDFWhenFinished") = False
' Set the design views to export
Dim oCompDef As ComponentDefinition = ooModelDocument.ComponentDefinition
Dim oRepsManager As RepresentationsManager = oCompDef.RepresentationsManager
Dim oDesignViewReps As DesignViewRepresentations = oRepsManager.DesignViewRepresentations
Dim oDesignViewRepsList(oDesignViewReps.Count) As String
Dim oCounter As Integer = 0
For Each oDesignView As DesignViewRepresentation In oDesignViewReps
oDesignViewRepsList(oCounter) = oDesignView.Name
oCounter += 1
Next
oOptions.Value("ExportDesignViewRepresentations") = oDesignViewRepsList
'Publish document.
oPDFConvertor3D.Publish(ooModelDocument, oOptions)
End Sub
Solved! Go to Solution.