- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This should be simple a simple request. Im looking for how to reference a custom property of the assembly in the first view of a drawing.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, this could be a start
If the first view reference is an assembly document and if the assembly document references a custom property a message box will appear with value.
Sub main Dim CustomProp As String = "CustompropName" 'property to be found change this Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDrawDoc.ActiveSheet If oSheet.DrawingViews.Count = 0 Then Exit Sub Dim oView As DrawingView = oSheet.DrawingViews.Item(1) 'firts view to be found Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Dim oCustomprop As Inventor.Property = GetCustomprop(oDoc, CustomProp) If oCustomprop IsNot Nothing Then Dim oCustompropValue As String = oCustomprop.Value MsgBox(oCustompropValue) End If End If End Sub Private Function GetCustomprop(AssyDoc As AssemblyDocument, CustomProp As String) As Inventor.Property Dim result As Inventor.Property = Nothing Try ' Get the PropertySets object. Dim oPropSets As PropertySets = AssyDoc.PropertySets ' Get the design tracking property set. Dim oPropSet As Inventor.PropertySet = oPropSets.Item("Inventor User Defined Properties") ' Get the part number iProperty. Dim oPartNumiProp As Inventor.Property = oPropSet.Item(CustomProp) result = oPartNumiProp Catch ex As Exception End Try Return result End Function
If a response answers your question, please use ACCEPT SOLUTION to assist other users later.
Also be generous with Likes! Thank you and enjoy!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is this what you mean?
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is this what you mean?
Regards,
Arthur Knoors
Autodesk Affiliations:
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: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Im looking for something similar to the parameter snippet:
Parameter("ASSYNAME.iam.PARAMETERNAME")
But im trying to call a property of the assembly instead of a parameter. Is that much code required for something like the above for properties?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @SECOJOSE. I think you are looking for something like this:
Dim sTitle As String = iProperties.Value("22240287.iam", "Summary", "Title")
Logger.Info(sTitle)
...where "22240287.iam" is the file name, with file extension, of the assembly being referenced in your drawing. This type of iLogic shortcut snippet can 'reach' any document that is being referenced by the current document that the rule is acting upon. The "Summary" is associated with which PropertySet the iProperty is located within, then the "Title" is the name of the iProperty. Just change those as needed.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thats what i needed.
Im trying to make the description of a drawing file match the description of the model in the first view, however, the model has multiple model states. The way this snippet works now is that it will grab the description of the model state the model was saved in. Is there a way to specify which model state to pull the description from?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @SECOJOSE. I'm still using Inventor Pro 2024.3, and there is nothing within the standard iLogic 'snippets' that suggests a way to specify a specific ModelState for this code to focus on yet. I know that in 2025 some advancements were made to give us more control over how those 'simplistic' iLogic shortcut snippets access documents with multiple ModelStates in them, but I thing that additional control is mainly focussed on whether your 'edits' will effect only the 'active' ModelState or 'all' ModelStates in the target document. I am not sure if they added a way to say which specific ModelState you want it to read from / write to with that code tool. There are also multiple other uncertainties (not well documented anywhere) about how that simplistic code tool will work in different situations.
You could try replacing the regular file name, with extension with "22240287.iam (Model State1)", where the name of the ModelState is included at the end, after a single space, and within ( & ) symbols, like how it appears in the Document.DisplayName value, when representing a ModelState member.
However, then the whole issue of factory vs member thing comes into play. We can usually read or write to the 'factory' version of a model document, but can only read from member versions of the document. There is only a 'factory' when there are 2 or more ModelStates present, and the factory is simply the document associated with whichever ModelState happens to be 'active' at that time.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you very much for your help. Its unfortunate about the lack of control with model states, but im going to try a workaround involving a program that opens the model, changes the model's model state to the model state presented in the view, saving it, then updating the description. Not the most elegant solution but hopefully it will tie me over until Autodesk catches up.
Thanks again