Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Derive in iProperties of a part.

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
562 Views, 3 Replies

Derive in iProperties of a part.

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.

 

 

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

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
in reply to: Anonymous

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

Message 4 of 4
bradeneuropeArthur
in reply to: Anonymous

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:

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report