Derive and Save As STEP Issues

Derive and Save As STEP Issues

Anonymous
Not applicable
810 Views
3 Replies
Message 1 of 4

Derive and Save As STEP Issues

Anonymous
Not applicable

Hi Everyone,

 

Im using the code below to derive my assembly to a single part and then save that as a STEP file. However i have run into a few difficulties.

 

1) For some reason the derivied part includes any suppressed components when it is created. is there an option to prevent this?

 

2) Is there a way to have the File Name different to the original file name? for example i would like to save the .stp file as the iProperties "Part Number". I have played around with this and can't seem to get it to work.

 

Any Help is appreciated.

 

Dan

 

'set a reference to the assembly component definintion.
'this assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition    

'define the path and file name
Dim sPathandName as String
sPathandName  = ThisDoc.PathAndFileName(False) 

' Create a new part file to derive the selected part into 
'note: kPartDocumentObject is the default template
'you could specifiy a path and file name for a custom template
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject)) 

'create the derived assembly deffinition
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition 
oDerivedAssemblyDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(sPathandName & ".iam")

'Set derive style options
oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyWithSeams
'options:
	'kDeriveAsSingleBodyWithSeams 
	'kDeriveAsSingleBodyNoSeams 
	'kDeriveAsMultipleBodies 
	'kDeriveAsWorkSurface 

'Create the derived part
Dim oDerivedAssembly As DerivedAssemblyComponent 
oDerivedAssembly = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)

'- - - - - - - - - - - - - - - - save *.stp  file- - - - - - - - - - - - - - - - - - - - - - - - - - - 
' 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
    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 = sPathandName  & ".stp"
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If
'- - - - - - - - - - - - end of *.stp  file code - - - - - - - - - - - - - - - - - - - - - - - - - 

'close the derived part without saving
oPartDoc.Close(True) 'True set's the skipsave boolean variant
MessageBox.Show("STP file created: " & sPathandName & ".stp", "iLogic")
0 Likes
811 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Okay, Did a little more digging and have come up with a solution for the renaming problem.

 

'set a reference to the assembly component definintion.'this assumes an assembly document is open.Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition    

'define the path and file nameDim sPathandName As String
sPathandName  = ThisDoc.PathAndFileName(False) 

' Create a new part file to derive the selected part into 'note: kPartDocumentObject is the default template'you could specifiy a path and file name for a custom templateDim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject)) 

'create the derived assembly deffinitionDim oDerivedAssemblyDef As DerivedAssemblyDefinition 
oDerivedAssemblyDef = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(sPathandName & ".iam")

'Set derive style optionsoDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams
'options:    'kDeriveAsSingleBodyWithSeams     'kDeriveAsSingleBodyNoSeams     'kDeriveAsMultipleBodies     'kDeriveAsWorkSurface 
'Create the derived partDim oDerivedAssembly As DerivedAssemblyComponent 
oDerivedAssembly = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)

'- - - - - - - - - - - - - - - - save *.stp  file- - - - - - - - - - - - - - - - - - - - - - - - - - - 
'define the model referenced by the drawingDim oModelDoc = ThisDoc.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
If oSTEPTranslator.HasSaveCopyAsOptions(oModelDoc, oContext, oOptions) Then

'Options for STEP outputoOptions.Value("ApplicationProtocolType") = 3 'Set application protocol: 2 = AP 203 - Configuration Controlled Design, 3 = AP 214 - Automotive DesignoOptions.Value("Author") = ThisApplication.GeneralOptions.UserName
oOptions.Value("Description") = iProperties.Value("Summary", "Title")
oOptions.Value("Organization") = "IKM Technique AS"

oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium
oData = ThisApplication.TransientObjects.CreateDataMedium

FilePath= ThisDoc.Path    'pathOutputPath = FilePath & "\" & "CREATED CYLINDER ASSEMBLIES"    'Output destination for the new STPOutputFileName = iProperties.Value("Project", "Part Number") & ".stp" 'Output File Name as specified in Custom iProperties, as specified by the iLogic rule OutputFileName

'Set the destination path & file nameoData.FileName = OutputPath & "\" & OutputFileName

'Publish DocumentoSTEPTranslator.SaveCopyAs(oModelDoc, oContext, oOptions, oData)
End If
'- - - - - - - - - - - - end of *.stp  file code - - - - - - - - - - - - - - - - - - - - - - - - - 
'close the derived part without savingoPartDoc.Close(True) 'True set's the skipsave boolean variantMessageBox.Show("STP file created: " & OutputFileName & ".stp", "iLogic")


0 Likes
Message 3 of 4

adam.nagy
Autodesk Support
Autodesk Support

Hi Dan,

 

If the option is not available in the UI then it's probably not in the API either.

You can check all the options available as shown here: 

http://adndevblog.typepad.com/manufacturing/2014/02/get-option-names-and-values-supported-by-invento...

 

I could not reproduce the issue of seeing a suppressed component of a derived part show up in the exported SAT file.

Could you provide a non-confidential set of files that can be used to reproduce the issue?

 

Cheers, 



Adam Nagy
Autodesk Platform Services
0 Likes
Message 4 of 4

Anonymous
Not applicable

Adam,

 

Thanks for your reply.

 

Turns out i had mixed some of the code up, i was saving the main assembly as a STEP rather than the new derived part.. 

 

Dan

0 Likes