Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generate files automically

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
juha.lievonen
630 Views, 3 Replies

Generate files automically

Hi,

 

I have lot of iPart and iAssembly files. Could I generate files without clicking every member? Now I right click member and I choose "Generate files"

 

I mean that Could I use for example task scheduler to this works?

 

 

3 REPLIES 3
Message 2 of 4
Jon.Dean
in reply to: juha.lievonen

Check out the following code, it is not mine but written by Bob Van der Donck our Technical Lead who also write Blog postings; http://beinginventive.typepad.com/being-inventive/

Here is the API equivalent of  what you can do through the UI:

 

  • Open an existing iPart
  • Shift select all iPart members in the browser
  • Use the “Generate files” context menu

Code that uses a For…next loop

 

Public Sub ipart_member_generation()

Dim odoc As Inventor.PartDocument

Set odoc = ThisApplication.ActiveDocument

Dim rowindex As Long

For i = 1 To odoc.ComponentDefinition.iPartFactory.TableRows.Count

rowindex = odoc.ComponentDefinition.iPartFactory.TableRows.Item(i).index

Call odoc.ComponentDefinition.iPartFactory.CreateMember(rowindex)

Next i

End Sub

 

Code that uses a For each.. Next loop

 

Public Sub  ipart_member_generation()

    Dim oDoc As PartDocument

    Set oDoc = ThisApplication.ActiveDocument

   

    Dim factory As iPartFactory

    Set factory = oDoc.ComponentDefinition.iPartFactory

    Dim row As iPartTableRow

    For Each row In factory.TableRows

        Dim member As iPartMember

        Set member = factory.CreateMember(row)

    Next

End Sub


Code to generate all member of an iAssembly factory

 

Public Sub iassembly_member_generation()

Dim oDoc As AssemblyDocument

Set oDoc = ThisApplication.ActiveDocument

Dim factory As iAssemblyFactory

Set factory = oDoc.ComponentDefinition.iAssemblyFactory

Dim rowindex As Long

For i = 1 To oDoc.ComponentDefinition.iAssemblyFactory.TableRows.count

rowindex = oDoc.ComponentDefinition.iAssemblyFactory.TableRows.Item(i).index

Call oDoc.ComponentDefinition.iAssemblyFactory.CreateMember(rowindex)

Next i

End Sub

 

Maybe you can adapt the code to work for you.

Jon



Jon Dean

Message 3 of 4
karthur1
in reply to: juha.lievonen

Here is something that I have used in the past when I need to "Re" generate my ipart members.

 

 

Message 4 of 4
imbroke2
in reply to: Jon.Dean

Thanks jon.dean for reposting this. You just saved me at least a days worth of work. I have hundreds of ipart configurations that needed to be Re-generated. Smiley Happy

----------------------------------------------------------------------------------------

OS: Windows 7 x64
CPU: Intel Core i5 @3.0 GHz,
Ram: 8 GB Harddisk: 1TB
Software: Autodesk Product Design Suite Premium 2012

----------------------------------------------------------------------------------------

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

Post to forums  

Autodesk Design & Make Report