Message 1 of 8
Living Reference in Drawing Text Box from Inventor Property Sets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I am looking to insert a text box in an inventor drawing that has a "living reference" to the property set "Part Number". I know how to access the part number, but when I go to put it in the text box it always gives me a static value. I would like it to be the dynamic value so if I change the part number down the line my label will change. here is a copy of the code I have so far.
For reference
Public Sub DetailItemNumber()
Debug.Print ThisApplication.ActiveDocument
'Get the active document which must be a drawing or else it will error
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
'Create an object to store all the sheets called "oSheets"
Dim oSheets As Sheets
Set oSheets = oDrawDoc.Sheets
Count = 0
Dim Viewcount As Integer
Viewcount = 0
Dim d As Integer
d = 0
'Create an object to store an individual sheet
Dim oSheet As Sheet
'For every sheet in drawing doc
For Each oSheet In oSheets
Count = Count + 1
'Create an object to store all the drawing views
Dim oViews As DrawingViews
Set oViews = oSheet.DrawingViews
'Create an object to store an individual view
Dim oView As DrawingView
'For ever drawing view on the sheet
For Each oView In oViews
Dim c As Integer
c = 0
'Get the part number associated with the drawing view
Dim oPartNumber As String
oPartNumber = oView.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item(2).Value
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
'Create an object to store all the sheets called "oSheets"
Dim oSheets As Sheets
Set oSheets = oDrawDoc.Sheets
Count = 0
Dim Viewcount As Integer
Viewcount = 0
Dim d As Integer
d = 0
'Create an object to store an individual sheet
Dim oSheet As Sheet
'For every sheet in drawing doc
For Each oSheet In oSheets
Count = Count + 1
'Create an object to store all the drawing views
Dim oViews As DrawingViews
Set oViews = oSheet.DrawingViews
'Create an object to store an individual view
Dim oView As DrawingView
'For ever drawing view on the sheet
For Each oView In oViews
Dim c As Integer
c = 0
'Get the part number associated with the drawing view
Dim oPartNumber As String
oPartNumber = oView.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item(2).Value
^^^^^^^^ Above is how I am currently accessing the inventor part number property. This results in a static value. How would I convert this to a living reference?
For reference Below is how I am writing the property to the formatted text box view label. By default this view label holds a dynamic value so I think it should be able to accept an inputted dynamic value.
If oView.ViewType = kStandardDrawingViewType And oPartNumber = oMPN Then
oView.Label.FormattedText = ("DETAIL ITEM " & oItem & vbCrLf & oPartNumber)
GoTo CONT:
oView.Label.FormattedText = ("DETAIL ITEM " & oItem & vbCrLf & oPartNumber)
GoTo CONT:
Additionally, I would like to be able to do this with the weight of the referenced model for a given drawing view. Any ideas how to make that value dynamic/living reference?