Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a code where I make an export from a main assembly.
This is a .step export of all underlying parts, so no assys.
A model state is activated.
These step files are written to a new location.
The part number becomes the file name.
Now we also want to use the oSTEPTranslator to write the step as: 5 = AP 242 - Managed Model Based 3D Engineering
We also want to define other options.
If we add the default snippet it doesn't go well.
The parts are no longer written to the created folder.
Can anyone help me how to insert or apply the oSTEPTranslator?
My code:
'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = ThisDoc.FileName(False) 'without extension If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'get user input RUsure = MessageBox.Show ("This will create a STEP file for all components.") If RUsure = vbNo Then Return Else End If '- - - - - - - - - - - - -STEP setup - - - - - - - - - - - - oPath = "Z:\Werkvoorbereiding\Step files" 'get STEP target folder path oFolder = oPath & "\" & Werkorder & "-" & " STEP Profielen" 'oFolder = oPath & "\" & oAsmName & " STEP Files" 'Check for the step folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If ThisDoc.ActiveModelState = "CNC Profielen" Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments For Each oRefDoc As Document In oRefDocs 'if is not a Part, skip to next referenced document If oRefDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Continue For Dim oCurFile As Document = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) Dim oCurFileName = oCurFile.FullFileName Dim ShortName = IO.Path.GetFileNameWithoutExtension(oCurFileName) Dim oPN As String = oCurFile.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value 'might want to ckeck if oPN = "" or not Try ' 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 'If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then ' ' Set application protocol. ' ' 2 = AP 203 - Configuration Controlled Design ' ' 3 = AP 214 - Automotive Design ' ' 5 = AP 242 - Managed Model Based 3D Engineering ' oOptions.Value("ApplicationProtocolType") = 5 ' ' Other options... ' oOptions.Value("Author") = iProperties.Value("Project", "Designer") ' 'oOptions.Value("Authorization") = "" ' oOptions.Value("Description") = "" ' oOptions.Value("Organization") = iProperties.Value("Summary", "Company") ' oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Dim oData As DataMedium ' oData = ThisApplication.TransientObjects.CreateDataMedium ' oData.FileName = oFolder & "\" & oCurFileName & ".stp" 'oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData) ' End If oCurFile.SaveAs(oFolder & "\" & oPN & ".stp", True) Catch MessageBox.Show("Error processing " & oCurFileName, "ilogic") End Try oCurFile.Close() Next '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") 'open the folder where the new files are saved Shell("explorer.exe " & oFolder, vbNormalFocus)
Thanks.
Mvg Jos
Youre drawings are as good as the symbols that compleet them.....
Youre drawings are as good as the symbols that compleet them.....
Solved! Go to Solution.