Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trying to pull a custom iProperty from a main view in a drawing

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
joe_love-gunn
139 Views, 3 Replies

Trying to pull a custom iProperty from a main view in a drawing

Hi I am currently trying to pull a custom parameter out of a main view in a drawing sheet, the end goal is to rename the sheet to the value of that parameter, however whenever I run the code the parameter cannot be found. I have changed the parameter value from "Panel ID" on Line 21 to "Author" and the Author can be found, but my custom iProperty cannot. I am not sure if my code is looking to the correct property set and cannot find much on this, any help would be appreciated. (I am currently in the debugging stage to find the property and I am new to iLogic coding hence not adding the name change part yet)

 

(Running while searching for "Panel ID")

joe_lovegunn_0-1714580844761.png

(Running while searching for "Author")

joe_lovegunn_1-1714580902745.png

 

(IProperties on Assembly "11366-H2557")

joe_lovegunn_2-1714581021710.pngjoe_lovegunn_3-1714581025354.png

 

Code will be linked below.

 

 

3 REPLIES 3
Message 2 of 4

' Get the current drawing document
Dim doc As DrawingDocument = ThisDoc.Document

' Loop through all the sheets in the drawing
For Each sheet As Sheet In doc.Sheets
    ' Get the first view on the sheet
    Dim view As DrawingView = Sheet.DrawingViews.Item(1)

    ' Check if the view exists
    If Not view Is Nothing Then
        ' Print the name of the sheet being checked
        Debug.Print("Checking sheet: " & Sheet.Name)

        ' Get the associated model
        Dim model As Document = view.ReferencedDocumentDescriptor.ReferencedDocument

        ' Check if the model exists and has the desired iProperty
        If Not model Is Nothing Then
            Try
                ' Get the value of the desired iProperty (replace "CustomProperty" with your actual iProperty name)
                Dim customPropertyValue As String = model.PropertySets.Item("Inventor Summary Information").Item("Panel ID").Value

                ' Output the value of the iProperty
                MsgBox("The value of the custom property is: " & customPropertyValue & vbCrLf & "Checked on sheet: " & Sheet.Name)
            Catch ex As Exception
                ' Handle the case where the property doesn't exist
                ' You can add your custom error handling here
                MsgBox("The desired iProperty does not exist in the model.")
            End Try
        End If
    End If
Next
Message 3 of 4
WCrihfield
in reply to: joe_love-gunn

Hi @joe_love-gunn.  There are always at least 4 PropertySets in every document, but some may have more than that.  The fourth PropertySet is always the 'custom' one.  It will always exist, but it will not have properties in it, by default, until you add some into it, one way or another.  The name of that PropertySet is "Inventor User Defined Properties" (in English), and its 'InternalName" is "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", which will work in all languages.  I usually just specify PropertySets.Item(4) though, because it is always at that Index position.

 

The first 3 PropertySets are a fixed size, so we can not add more Properties into them, or remove any properties from them.  And only some of those properties are Read/Write, while many are ReadOnly.

 

I have attached a PDF of an Excel sheet I created, which shows all all the 'standard' PropertySets & Properties, but also shows a coupe of the others (not all possible others though).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

That worked perfectly thank you!

joe_lovegunn_0-1714634452369.png

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report