Derive in iProperties of a part.

Derive in iProperties of a part.

Anonymous
Not applicable
759 Views
3 Replies
Message 1 of 4

Derive in iProperties of a part.

Anonymous
Not applicable

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.

 

 

0 Likes
Accepted solutions (1)
760 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted 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.

 

 

 

 

Message 3 of 4

Anonymous
Not applicable

Thanks a ton! I got what I needed for my code and its working great!

0 Likes
Message 4 of 4

bradeneuropeArthur
Mentor
Mentor
Hi,

Maybe this idea should be voted!

forums.autodesk.com/t5/inventor-ideas/derived-part-and-assembly-copy-i-properties/idi-p/634

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
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:
My 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 !


 


EESignature

0 Likes