Hi
I have been searching all over this forum, youtube, google, and what not, and i haven't found a solution for my problem.
When we send 3D models to customers, we always derive the assembly to make it 1 solid part, so the customer cannot disassemble it to copy our product, and then save it as a step file.
I want to Derive an assembly to a part and then save it as a *.step file with an ilogic rule.
I worked out the last part, but i cannot find the Derive assembly code anywhere.
Im not an experienced programmer, i can only Copy paste, so if the solution is already posted in a simular rule, i will not be able to pick what i need from the code 🙂
hope someone can help me !
/LSA-skan
Hi LSA-skan,
Here's an example that will derive the assembly to a single solid with seams and then save that as a STP file. This example discards the derived part without saving it.
Attached it the code in a *.txt file in case pasting from this forum directly causes formatting errors.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'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")
Hi Curtis
First of all, im very impressed that you came up with this in such short time.!
This works on small assemblies (tested with an assembly with 10 parts), but a larger assembly with 258parts (1015 occurrences) the step file contains 93 solid bodies instead of just 1.?!
Do you have any idea why theres is this difference..?
It takes about 5 min for inventor to derive this assembly, is that somehow cut short by the rule, so it never finishes or something crazy like that?
Secondly: the big assemly have diffrent Position, and Views, that i would like to choose between, before it makes the derived part if that is possible..?
/LSA-Skan