Message 1 of 3
Step file name when attached to 3D PDF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I've used and tweaked this code to generate a 3D PDF with a step file attachment. Everything works well but the only thing I can't figure out is how I change the step file name that is attached to the PDF. For now the filename listens to the filename of the part/ assembly but it needs to listen to the Filename of the pdf (or specified like I did in the code below). I defined the value as "StepFileName" for now but I'm looking for the actual one.
Any help would be great! Thanks in advance.
On Error Goto KSEerror: ' 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 MsgBox ("Inventor 3D PDF Addin not loaded. Go to Tools -> Add-Ins, and make sure Anark 3D PDF Publisher is loaded.") Exit Sub End If UserinputRequired = MessageBox.Show("Do you want to publish a 3D PDF with a step file attached?" _ ,"KSE",MessageBoxButtons.YesNo,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1) If UserinputRequired = vbNo Then Return Else Dim oPDFConvertor3D oPDFConvertor3D = oPDFAddIn.Automation '-----a reference to the active document (the document to be published)----- Dim oDocument As Document oDocument = ThisApplication.ActiveDocument '-----Create a NameValueMap object as Options----- Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap '-----Create a NameValueMap object as Options for step----- Dim oStepOptions As NameValueMap oStepOptions = ThisApplication.TransientObjects.CreateNameValueMap '-----Filename definition----- FileName = iProperties.Value("Summary", "Title") & "r" & iProperties.Value("Project", "Revision Number") & ".pdf" FileNameStep = iProperties.Value("Summary", "Title") & "r" & iProperties.Value("Project", "Revision Number") & ".step" '-----Options----- oOptions.Value("FileOutputLocation") = (ThisDoc.Path(False) & FileName) oOptions.Value("ExportAnnotations") = 0 oOptions.Value("ExportWokFeatures") = 0 oOptions.Value("GenerateAndAttachSTEPFile") = True oOptions.Value("LimitToEntitiesInDVRs") = True oOptions.Value("ExportAllProperties") = True '-----Step file options----- 'oStepOptions.Value("ApplicationProtocolType") = 2 '(AP203) 'oStepOptions.Value("ApplicationProtocolType") = 3 '(AP214IS) oStepOptions.Value("ApplicationProtocolType") = 4 '(AP242) oStepOptions.Value("StepFileName") = FileNameStep '------Accuracy - selection by Arraylist----- Dim MyArrayList As New ArrayList MyArrayList.add("Very High") MyArrayList.add("High") MyArrayList.add("Medium") MyArrayList.add("Low") ACCURACYinput = InputListBox("Select an quality level for the PDF. If you do not select anything the default is set to *Low*", MyArrayList, d0, Title := "Set Quality", ListName := "List") If ACCURACYinput = "Very High" Then ACCURACYtoUSE = AccuracyEnum.kVeryHigh Else If ACCURACYinput ="High" Then ACCURACYtoUSE = AccuracyEnum.kHigh Else If ACCURACYinput ="Medium" Then ACCURACYtoUSE = AccuracyEnum.kMedium Else If ACCURACYinput ="Low" Then ACCURACYtoUSE = AccuracyEnum.kLow Else If ACCURACYinput ="" Then ACCURACYtoUSE = AccuracyEnum.kLow End If oOptions.Value("VisualizationQuality") = ACCURACYtoUSE '-----the properties to export----- Dim sProps(0) As String sProps(0) = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}:Title" ' Title '-----Choose the export template based off the current document type----- oOptions.Value("ExportTemplate") = ("D:\Google drive\CAD\Inventor\KSE\KSE 3D.pdf") '-----Export Current design view----- Dim sDesignViews(0) As String sDesignViews(0) = oDocument.ComponentDefinition.RepresentationsManager.ActiveDesignViewRepresentation.Name oOptions.Value("ExportDesignViewRepresentations") = sDesignViews ThisApplication.StatusBarText= "Exporting 3D PDF. This could take some time. There is no progress bar" 'Publish document. Call oPDFConvertor3D.Publish(oDocument, oOptions) ThisApplication.StatusBarText= "3D PDF is ready" i = MessageBox.Show("3D PDF is saved in the same location as this document. Preview the 3D PDF?", "KSE",MessageBoxButtons.YesNo) If i = vbYes Then : launchviewer = 1 : Else : launchviewer = 0 : End If If launchviewer = 1 Then ThisDoc.Launch(ThisDoc.Path(False) & FileName) End If Return KSEerror: MessageBox.Show("Error. The PDF cannot be published. Please ensure that you are in a Part or Assembly file. Ensure that all parts (in Assemblies) are fully resolved, models with missing links cannot be used for publishing 3D PDF's","Kanon Smart Engineering")
---------------------------------------------------------------------------------------------------------