Automate idw drawing file creation for all ipart members

Automate idw drawing file creation for all ipart members

mbgustin
Contributor Contributor
6,030 Views
21 Replies
Message 1 of 22

Automate idw drawing file creation for all ipart members

mbgustin
Contributor
Contributor

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.

0 Likes
Accepted solutions (2)
6,031 Views
21 Replies
Replies (21)
Message 21 of 22

ldellaversano
Explorer
Explorer

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

 

0 Likes
Message 22 of 22

mbgustin
Contributor
Contributor

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.  

0 Likes