Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I've looked around and found a code from this forum post that makes a .stp file of part that's used in a drawing.
I've modified bretrick30's code (in comment 9) , as this only works for Sheet Metal parts.
The code below is what I use. This code do generate a .stp file, but the file is blank (2 kB size).
'Dim statement: Declares and allocates storage space for variables
Dim oPart As Inventor.PartDocument
'Takes the part shown in the 1st view
'of the current sheet's DrawingViews collection
oDrawingDoc = ThisDrawing.Document
oSheet = ActiveSheet.Sheet
oDrawingView = oSheet.DrawingViews.Item(1)
oPart = ActiveSheet.View(oDrawingView.Name).ModelDocument
' 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
oStepFileName = iProperties.Value("Project", "Part Number") & " " & iProperties.Value("Project", "Description")
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
strFolder = "C:\TEMP\"
oData.FileName = strFolder & "\" & oStepFileName & ".stp"
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If
Incase it's unclear: I open a .idw to make .stp of the part/assembly used in opened .idw.
Inventor 2021.1
Solved! Go to Solution.