Placing Iparts in assembly

Placing Iparts in assembly

Anonymous
Not applicable
371 Views
1 Reply
Message 1 of 2

Placing Iparts in assembly

Anonymous
Not applicable

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

0 Likes
372 Views
1 Reply
Reply (1)
Message 2 of 2

philippe.leefsma
Alumni
Alumni

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

0 Likes