Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
I' m struggling to fetch this code to the active document. I know it starts like this
Dim oDoc As ThisApplication.ActiveDocument
but then how to continue?
The code is as follow:
If ThisDoc.Document.DocumentType = kDrawingDocumentObject Then
MsgBox("Funtioniert nicht in der Zeichnung😊", vbInformation, "Nur .ipt oder .iam")
Exit Sub
End If
'Dim oDoc As Document = ThisApplication.ActiveDocument
' Get the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
SavePath = "T:\my_\my_steps\"
Dim Rev As String = iProperties.Value("Project", "Revision Number")
If Rev = Nothing Then : Rev = "-" : End If
Dim oFullPath As String = ""
If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
' Set application protocol.
' 2 = AP 203 - Configuration Controlled Design
' 3 = AP 214 - Automotive Design
oOptions.Value("ApplicationProtocolType") = 3
' Other options...
'oOptions.Value("Author") = ""
'oOptions.Value("Authorization") = ""
'oOptions.Value("Description") = ""
'oOptions.Value("Organization") = ""
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium
oData = ThisApplication.TransientObjects.CreateDataMedium
oData.FileName = SavePath & ThisDoc.FileName(False) & "_" & Rev & ".stp"
oFullPath = oData.FileName
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If
'System.IO.Path.GetDirectoryName(SavePath)
If System.IO.File.Exists(oFullPath) = True Then
MsgBox(ThisDoc.FileName(False) & "_" & Rev & ".stp" & _
vbCrLf & "wurde erfolgreich in " & SavePath & " erstellt!", vbInformation, "😊 👍 🤘")
Else
MsgBox("Da hat was nicht geklappt.😮"& vbCrLf &"Probiers nochmal.", vbCritical,"abbruch")
End If
Any help would be very apreciated
Thank you
Solved! Go to Solution.