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: 

Placing Iparts in assembly

1 REPLY 1
Reply
Message 1 of 2
Anonymous
311 Views, 1 Reply

Placing Iparts in assembly

Hi there,

 

Subject: Inventor placing Iparts in Assembly (Autodesk Inventor 2010)

 

Problem:

 

When placing an Ipart into a project Assembly it will make a copy of that variant and place it in the same map as the Ipart.

So when variant B of Ipart A is selected it will make a copy of variant B in the same folder where Ipart A is located.

 

Question:

 

Is it possible to make a “save as” option or another similar manner to save those copies of variant B in a project map of a project assembly?

Instead of saving all the Ipart variants to a single folder. So each time a new project is started they have all the parts in the same folder.

 

Reason:

 

I am making a local library for parts that are used for repairs. These parts have many variants and some times need to be customized for a repair.

The current system keeps polluting itself causing the users to loose their parts and accidentally delete the original parts etc.

 

I contacted Autodesk support and theyrecommended to post this question on this forum. They did mentioned that vba programming could achieve this. I have no knowledge of this type of programming.

 

Thanks for any input,

 

Piet Klaas

1 REPLY 1
Message 2 of 2
philippe.leefsma
in reply to: Anonymous

Hi Piet,

 

So following code illustrates how to generate an iPart member and move it to a different directory. You cannot choose where the member is going to be saved on the disk first, but the sample illustrates how to retrieve it:

 

Private Sub CreateAndMoveiPartMember()

    Dim factoryDoc As PartDocument
    Set factoryDoc = ThisApplication.Documents.Open("C:\Temp\Factory.ipt")

    Dim factory As iPartFactory
    Set factory = factoryDoc.ComponentDefinition.iPartFactory
    
    Dim member As iPartMember
    Set member = factory.CreateMember(1)
    
    Dim srcFilename As String
    srcFilename = factory.MemberCacheDir + "\" + member.name
    
    Dim destFilename As String
    destFilename = "C:\Temp\MembersDir\" + "NewMember1.ipt"
    
    Call ThisApplication.FileManager.CopyFile(srcFilename, destFilename)
    
    'Delete the original file, if you'd like to
    Call ThisApplication.FileManager.DeleteFile(srcFilename)
    
End Sub

In your case, what you will need to do is to insert the iPart in the assembly, retrieve the generated member, do a copy of the physical file to the location of your choice, then use "ComponentOccurrence.Replace" on the relevant occurrence to swap the original iPart member with the new copy.

 

I hope it helps.

 

Regards,

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report