Autodesk Inventor Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Extract model REV from drawing that only references an ipn using VBA
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I'm trying to extract the Rev of a model (part or assembly) from a drawing. Since Inventor has independent revs for the model and idw I am trying to drill down and put the rev from the model referenced. I got it to work for ipts and many iams using:
Dim oModelDoc As Document
Set oModelDoc = oDocument.Sheets(1).DrawingViews(1).ReferencedDocu
The problem I have is when the drawing only references an ipn presentation file. The ipn ALSO has it's own independant rev! I'm trying access the model the ipn references but cannot get it to work.
BTW, I do know about the ability to sync idw and ipt properties. I have enable it for our template but we have a lot of legacy drawings that don't have this option selected. I also haven't tested that method with an drawing that only references an ipn.
Code is below with offending section in bold:
' Find model (part or assembly) referenced by drawing if active document is a drawing
If oDocument.DocumentType = kDrawingDocumentObject Then
Dim oModelDoc As Document
Set oModelDoc = oDocument.Sheets(1).DrawingViews(1).ReferencedDocu
If oModelDoc.DocumentType = kPresentationDocumentObject Then
Dim oModelDoc2 As Document
Set oModelDoc2 = oModelDoc.AllReferencedDocuments.Item(1) 'oModelDoc..ReferencedDocumentDescriptors.Item(1).
' debug: test if the correct document type was found
If oModelDoc2.DocumentType = kAssemblyDocumentObject Then
MsgBox ("yeah, it's an iam")
End If
' debug: check to see if the correct file has been found by looking at filename
Set oFMetadata = ThisApplication.TransientObjects.CreateFileMetadat
PN = oFMetadata.FileName
'Dim test As PresentationDocument
'test.AllReferencedDocuments.Item (1)
'test.ReferencedDocuments.Item(1).ReferencedDocume
Set oDocument = oModelDoc2
Else
Set oDocument = oModelDoc
End If
End If
' END TEST
' Get the PropertySets collection object
Dim oPropertySets As PropertySets
Set oPropertySets = oDocument.PropertySets
' Get Rev if it exists else oRev = ""
Dim oRev As Variant
oRev = oPropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002
INV 2013
Re: Extract model REV from drawing that only references an ipn using VBA
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Any VBA experts have any ideas?
INV 2013
Re: Extract model REV from drawing that only references an ipn using VBA
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I may not get what you meant: ....the ipn ALSO has it's own independant rev! I'm trying access the model the ipn references but cannot get it to work.
I created an assembly and used it in a drawing. And I created a presentation document with this assembly. Finally ran your code snippet. this line works well to me.
Set oModelDoc2 = oModelDoc.AllReferencedDocuments.Item(1)
Could you clarify the problem you are having? or any screenshots, or specific documents?
Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

