Hier mal ein Code für PDF und DXF für das Speichern
mußt Du einen FileDialog aufrufen
Public Sub PublishTo3DPDF()
' 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
Set oPDFAddIn = oAddin
Exit For
End If
Next
If oPDFAddIn Is Nothing Then
MsgBox "Inventor 3D PDF Addin not loaded."
Exit Sub
End If
Dim oPDFConvertor3D
Set oPDFConvertor3D = oPDFAddIn.Automation
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
Set oDocument = ThisApplication.ActiveDocument
' Create a NameValueMap object as Options
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Options
oOptions.Value("FileOutputLocation") = "c:\temp\test.pdf"
oOptions.Value("ExportAnnotations") = 1
oOptions.Value("ExportWokFeatures") = 1
oOptions.Value("GenerateAndAttachSTEPFile") = True
oOptions.Value("VisualizationQuality") = kHigh
' Set the properties to export
Dim sProps(0) As String
sProps(0) = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}:Title" ' Title
oOptions.Value("ExportAllProperties") = False
oOptions.Value("ExportProperties") = sProps
' Set the design views to export
Dim sDesignViews(1) As String
sDesignViews(0) = "Master"
sDesignViews(1) = "View1"
oOptions.Value("ExportDesignViewRepresentations") = sDesignViews
'Publish document.
Call oPDFConvertor3D.Publish(oDocument, oOptions)
End Sub
Public Sub PublishDXF()
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
Set DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
Set oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\tempDXFOut.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
oDataMedium.FileName = "c:\tempdxfout.dxf"
'Publish document.
Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
Public Sub PublishDXF()
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
Set DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
Set oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\tempDXFOut.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
oDataMedium.FileName = "c:\tempdxfout.dxf"
'Publish document.
Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP