Living Reference in Drawing Text Box from Inventor Property Sets

Living Reference in Drawing Text Box from Inventor Property Sets

cameron.houston
Enthusiast Enthusiast
973 Views
7 Replies
Message 1 of 8

Living Reference in Drawing Text Box from Inventor Property Sets

cameron.houston
Enthusiast
Enthusiast

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
 
^^^^^^^^ 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:
 
 
 
 
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?
0 Likes
974 Views
7 Replies
Replies (7)
Message 2 of 8

Stakin
Collaborator
Collaborator

pls do like this,i can not copy formated text on the cellphone ,sorry。post a screenshot for you。

65FDB8EC-3C80-4962-8EF0-A9B131D218AD.jpeg

 

0 Likes
Message 3 of 8

cameron.houston
Enthusiast
Enthusiast

Hi @Stakin,

 

Can I use the < ******************> and put that in the formatted text box view label? or do I have to create a new textbox. Additionally, I am not trying to grab I props of the drawing, but of the referenced file in the drawing view. Is that possible?

0 Likes
Message 4 of 8

bradeneuropeArthur
Mentor
Mentor

You can select the partnumber if model in the drawing via dropdown box in the text editor. Now you have a live update when the initial model changes 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 8

Stakin
Collaborator
Collaborator

More one link and the propertysets

https://forums.autodesk.com/t5/inventor-customization/propertie-set-names-where-are-they-vb-net/m-p/...

 

As for the Property Sets. Here is a list of them. 

----

PropertySets:

DispalyName = “Summary Information”
InternalName = “{F29F85E0-4FF9-1068-AB91-08002B27B3D9}”
Properties = “Title”, “Subject”, “Author”, “Keywords”, “Comments”, “Last Saved By”, “Revision Number”, “Thumbnail”


DisplayName = “Document Summary Information”
InternalName = “{D5CDD502-2E9C-101B-9397-08002B2CF9AE}”
Properties = “Category”, “Manager”, “Company”


DisplayName = “Design Tracking Properties”
InternalName = “{32853F0F-3444-11D1-9E93-0060B03C1CA6}”
Properties = “Creation Time”, “Part Number”, “Project”, “Cost Center”, “Checked By”, “Date Checked”, “Engr Approved By”, “Engr Date Approved”, “User Status”, “Material”, “Part Property Revision Id”, “Catalog Web Link”, “Part Icon”, “Description”, “Vendor”, “Document SubType”, “Document SubType Name”, “Proxy Refresh Date”, “Mfg Approved By”, “Mfg Date Approved”, “Cost”, “Standard”, “Design Status”, “Designer”, “Engineer”, “Authority”, “Parameterized Template”, “Template Row”, “External Property Revision Id”, “Standard Revision”, “Manufacturer”, “Standards Organization”, “Language”, “Defer Updates”, “Size Designation”, “Categories”, “Stock Number”, “Weld Material”, “Mass”, “SurfaceArea”, “Volume”, “Density”, “Valid MassProps”, “Flat Pattern Width”, “Flat Pattern Length”, “Flat Pattern Area”, “Sheet Metal Rule”, “Last Updated With”, “Sheet Metal Width”, “Sheet Metal Length”, “Sheet Metal Area”, “Material Identifier”, “Appearance”

 

DisplayName = “User Defined Properties”
InternalName = “{D5CDD505-2E9C-101B-9397-08002B2CF9AE}”
-----------------------------------

 

0 Likes
Message 7 of 8

Stakin
Collaborator
Collaborator
0 Likes
Message 8 of 8

Stakin
Collaborator
Collaborator

Document Properties <Property>

 

The Property tag specifies that the value of a document property is to be used in the text string. Currently, if a document property is used it must be the only text input for the formatted string. The StyleOverride tag can be used to control the style but no other text can be mixed with the property text. In order to define which property is to be used the following attributes are used:

Document – The Document attribute is optional and used to specify which document the property value is to be extracted from. If this attribute is not specified, it uses the properties from the model document referenced by the first view placed on the sheet. Valid values for this attribute are "model" or "drawing". If "drawing" is used, the properties from the drawing document are used.

FormatID – The FormatID attribute specifies which property set the property is within. This is specified as a GUID in string form. The "Document Properties" topic in the API Overview discusses how to obtain the format ID’s for specific property sets.

PropertyID – The PropertyID is a numeric value, which uniquely identifies a property within the property set.

 

The "Document Properties" topic in the API Overview discusses how to obtain the property ID’s for specific properties. The Id of a property is the same as the value of the associated enum.

 

Example:

 

The example below will display the string associated with the description property of the design tracking properties associated with the document containing the model referenced by the first view on the sheet. The backslash at the end of the tag definition denotes that the opening and closing tags have been combined. This is useful in this case since a property tag does not require any additional information besides what’s provided by the attributes.

<Property Document="model" FormatID="{32853F0F-3444-11d1-9E93-0060B03C1CA6}" PropertyID="29" />

 

Sub Main () 
	Dim oDrawDoc As DrawingDocument
	Dim oDoc As Document	
	Dim oSheet As Sheet
	Dim oTG As TransientGeometry
	Dim oPoint4, oPoint5 As Point2d
	Dim oGeneralNotes As GeneralNotes	
	oDoc = ThisDoc.Document	
	oDoc = ThisApplication.ActiveDocument
	oSheet = oDoc.Sheets.Item(1)
	oGeneralNotes = oSheet.DrawingNotes.GeneralNotes
	oTG = ThisApplication.TransientGeometry	
	oPoint4 = oTG.CreatePoint2d(15, 20) 'MATERIAL NOTE POSITION
	oPoint5 = oTG.CreatePoint2d(15, 18) 'STOCK NUMBER NOTE POSITION	
	oPoint6 = oTG.CreatePoint2d(15, 16)
	oPoint7 = oTG.CreatePoint2d(15, 14)
	oPoint8 = oTG.CreatePoint2d(15, 12)
	oMtl = "<Property Document='Model' PropertySet='Design Tracking Properties' Property='Material' >MATERIAL</Property>"
	oStockNum = "<Property Document='Model' PropertySet='Design Tracking Properties' Property='Stock Number' >Stock Number</Property>"	
	oMtlNote = oGeneralNotes.AddFitted(oPoint4, "MATERIAL: " & oMtl)
	oStockNumNote = oGeneralNotes.AddFitted(oPoint5, "STOCK NO.: " & oStockNum)
	oStockNum ="<Property Document='drawing' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property>"
	oStockNumNote = oGeneralNotes.AddFitted(oPoint6, "Drawing PART NUMBER: " & oStockNum)
	oPartNum ="<Property Document='Model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property>"
	oPartNumNote = oGeneralNotes.AddFitted(oPoint7, "Model PART NUMBER: " & oPartNum)
	oPartNumNote = oGeneralNotes.AddFitted(oPoint8, "Model PART NUMBER: " & oPartNum &";   Drawing PART NUMBER: " & oStockNum & ";   MATERIAL: " & oMtl)
End Sub

Inventor 2021 Help: PropertiesForDesignTrackingPropertiesEnum Enumerator (autodesk.com)

Inventor 2021 Help: PropertiesForDocSummaryInformationEnum Enumerator (autodesk.com)

Inventor 2021 Help: PropertiesForSummaryInformationEnum Enumerator (autodesk.com)

Inventor 2021 Help: PropertiesForUserDefinedPropertiesEnum Enumerator (autodesk.com)

Inventor 2021 Help: PropertiesForContentLibraryEnum Enumerator (autodesk.com)

0 Likes