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: 

Automate idw drawing file creation for all ipart members

21 REPLIES 21
SOLVED
Reply
Message 1 of 22
mbgustin
4078 Views, 21 Replies

Automate idw drawing file creation for all ipart members

I'm sure this is possible and likely simple, I just don't know how to do it.  I'm looking for a way to automate the creation of an idw file for each member of my ipart.

 

I have a large project that will have me making large ipart factories with several hundred members.  I'm drawing hydraulic seals that have a range of diameters and then also have different cross sections.  We typically do not like to use tabulated drawings because it causes manufacturing errors when someone reads the table incorrectly.  I use custom property fields to place text in the drawing file based on the ipart member.  So basically the drawing file views remain the same but text/notes change with each member. 

What I'd like to do is make one drawing file that is tied to the first member adding all my views and dimensions and then have a program that changes the member and does a save as with the file name being equal to the member name.

 

Currently I make the ipart file and generate all the members.  Then I generate the first drawing and save it as membername.idw.  I then change the member associated with the main view and do a save as newmembername.idw...over and over again until I have a drawing file for each member.  Automating this would be a huge efficiency gain.

21 REPLIES 21
Message 21 of 22
ldellaversano
in reply to: Yijiang.Cai

Hi, i have use your rule in inventor 2022 but I get a runtime 5 error. Why? How can I resolve?
This is your code

Sub CreateDrawing()
Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = ThisApplication.ActiveDocument

Dim oView As DrawingView
Set oView = oDrawingDoc.ActiveSheet.DrawingViews(1)

Dim oPartDoc As PartDocument
Set oPartDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim oDef As PartComponentDefinition
Set oDef = oPartDoc.ComponentDefinition

If oDef.IsiPartMember = True Then
Dim iPartF As iPartFactory
Set iPartF = oDef.iPartMember.ParentFactory

For i = 1 To iPartF.TableRows.Count - 1

Set oPartDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim sPath As String
sPath = Replace(oPartDoc.FullFileName, iPartF.FileNameColumn(i).Value, iPartF.FileNameColumn(i + 1).Value)

Call iPartF.CreateMember(i + 1)

Call oView.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(sPath)

Call oDrawingDoc.Update2(True)

Call oDrawingDoc.SaveAs(Replace(oDrawingDoc.FullFileName, iPartF.FileNameColumn(1).Value, iPartF.FileNameColumn(i + 1).Value), True)
Next
End If

End Sub

 

Message 22 of 22
mbgustin
in reply to: ldellaversano

You have to open the idw file associated with the first model in the factory (save this file before you run the program).  Run the program and then close the idw file without saving.  It should generate all of the ipt and idw files required.  It works for me.  I use it almost daily.  

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report