Hallo zusammen,
ich möchte aus ein aus einem Modell verschiedene Dateien erstellen, darunter soll auch ein 3d-Pdf sein.
Ich habe bei der API Hilfe ein Programm gefunden das das machen soll.
hier der Code:
Option Explicit
Public Sub PublishTo3DPDF()
Dim invApp As Inventor.Application: Set invApp = ThisApplication
' 1. Das 3D-PDF Add-In suchen
Dim oPDFAddIn As ApplicationAddIn
Dim oAddin As ApplicationAddIn
' Korrigierte Schleife:
For Each oAddin In invApp.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 wurde nicht gefunden!", vbCritical
Exit Sub
End If
' 2. Add-In aktivieren, falls es noch nicht bereit ist
If Not oPDFAddIn.Activated Then
On Error Resume Next
oPDFAddIn.Activate
On Error GoTo 0
End If
' 3. Automation-Schnittstelle abrufen
Dim oPDFConvertor3D As Object
Set oPDFConvertor3D = oPDFAddIn.Automation
If oPDFConvertor3D Is Nothing Then
MsgBox "Die 3D-PDF Automation-Schnittstelle ist nicht verfügbar!", vbCritical
Exit Sub
End If
' 4. Dokument-Referenz
Dim oDocument As Document: Set oDocument = invApp.ActiveDocument
' Sicherheitscheck: Ist überhaupt ein Dokument offen?
If oDocument Is Nothing Then Exit Sub
' 5. Optionen erstellen
Dim oOptions As NameValueMap
Set oOptions = invApp.TransientObjects.CreateNameValueMap
' --- PFADE ---
oOptions.value("FileOutputLocation") = "D:\test.pdf"
oOptions.value("ExportTemplate") = "I:\0-Inventor\Vorlagen\IMF\Blank.pdf"
' --- GEOMETRIE ---
oOptions.value("ExportAnnotations") = 1
oOptions.value("ExportWorkFeatures") = 1
oOptions.value("VisualizationQuality") = 1 ' 1 = Medium
' --- ANSICHTEN ---
Dim sDesignViews(0) As String
sDesignViews(0) = "Master"
oOptions.value("ExportDesignViewRepresentations") = sDesignViews
' 6. PUBLISH
invApp.StatusBarText = "3D-PDF wird erstellt..."
On Error Resume Next
Call oPDFConvertor3D.Publish(oDocument, oOptions)
If Err.Number <> 0 Then
MsgBox "Fehler: " & Err.Description, vbCritical
Else
MsgBox "Erfolgreich erstellt!", vbInformation
End If
On Error GoTo 0
invApp.StatusBarText = "Bereit"
End Sub
Die zwei Zeilen unter
' --- PFADE ---
habe ich angepasst.
Wenn ich das Programm ausführe erscheint nur ein leeres weißes Blatt in Acrobat Reader.
Hat jemand ein Tipp, was ich anpassen muss damit die Geometrie exportiert wird.
mfg Stefan
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP