Hello,
I am trying to write a code that will, with a part open (lets call it part A), will open a template part (part B), and then in part B, derive in specific user parameters of part A, and set them as parameters in part B. Then save part B as part A-1 or something.
I have a general idea of how it would work, however am unable to figure out which commands would allow me to derive one part from another part document, and then how to specify to only bring in certain parameters but not work geometry.
Can anyone give me an idea of where to look? Once I have that I'm sure I'll have other problems but I need somewhere to start.
Thanks.
Solved! Go to Solution.
Hi,
try creating a rule in part A, and paste the following code.
Dim NewFileNameAddition As String = "-1" Dim TemplateFileName As String = "D:\Template.ipt" Dim CurrentDocFileName As String = ThisDoc.Document.fullfilename Dim NewDocFileName As String = strings.left(CurrentDocFileName,strings.instrrev(CurrentDocFileName,".") - 1) & NewFileNameAddition & ".ipt" Dim oNewDoc As Inventor.PartDocument = ThisApplication.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject, TemplateFileName, True) oNewDoc.SaveAs(NewDocFileName, False) Dim oNewDocDef As Inventor.PartComponentDefinition = oNewDoc.ComponentDefinition Dim oDerivedPartDefinition As Inventor.DerivedPartDefinition = oNewDocDef.ReferenceComponents.DerivedPartComponents.CreateDefinition(CurrentDocFileName) ' oDerivedPartDefinition.IncludeAllParameters = True oDerivedPartDefinition.ExcludeAll() oDerivedPartDefinition.Parameters.Item("YourParameterName1").IncludeEntity = True oDerivedPartDefinition.Parameters.Item("YourParameterName2").IncludeEntity = True oDerivedPartDefinition.Parameters.Item("YourParameterName3").IncludeEntity = True Dim oNewDerivedPartComponent As Inventor.DerivedPartComponent = oNewDocDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPartDefinition) oNewDoc.Save() MsgBox("Done", MsgBoxStyle.Information, "Done")
Edit the first 2 lines of code to determine which template to use, and how your new filename will look like.
Also don't forget to replace "YourParameterName1"with the parameters of your choice.
Good luck.
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Can't find what you're looking for? Ask the community or share your knowledge.