I'm writing a macro that exports .idw's to .dxf's. For each new revision we save a new copy with the revision number tagged onto the part number ( Example I00-001234 revision 1 becomes I00-001234R1).
The problem comes when i try to extract the revision number from the drawing. Because the drawing updates the revision from the model, the titleblock shows the model revision. However, when I pull the revision number, the code pulls the data from the sheet iproperties rather than the model iproperties.
Is there a way to pull the model revision, or a way to pull the data from the titleblock on the drawing?
Dim FSO As Scripting.FileSystemObject Dim InvDocuments, Path As Documents Dim invDocument As Document Dim InvDoc, oDoc As Document Dim FilePath As String Dim newDXF As String Dim PopUp As String Dim Ans As String
Dim InvRevision As Property Dim Revision As String
Set InvDoc = ThisApplication.ActiveDocument Set Path = ThisApplication.Documents Set InvRevision = InvDoc.PropertySets.Item("Inventor Summary Information").Item("Revision Number")
'^^^ This line reads the sheet revision (which is 0) but the model revision is 1
Set FSO = New Scripting.FileSystemObject FilePath = "C:\TEMP" + newDXF MsgBox "Revision Number: " & InvRevision.Value If FSO.FileExists(FilePath) = False Then If InvRevision.Value = Null Or 0 Then Revision = "" Else Revision = "R" + CStr(InvRevision.Value) newDXF = newDXF + Revision End If
' Here I call the function to save copy as DXF
Else PopUp = "Do you wish to overwrite the file" & vbNewLine & _ newDXF & "?" Ans = MsgBox(PopUp, vbOKCancel, "Overwrite File?") If Ans = vbOK Then 'Delete old file With New FileSystemObject .DeleteFile "C:\TEMP" & newDXF End With If InvRevision.Value = Null Or 0 Then Revision = "" Else Revision = "R" + CStr(InvRevision.Value) newDXF = newDXF + Revision End If ' Here I call the code to save a copy as DXF Else End If End If