How does i-logic control custom properties of ipt placed in idw?

How does i-logic control custom properties of ipt placed in idw?

khnam
Contributor Contributor
426 Views
4 Replies
Message 1 of 5

How does i-logic control custom properties of ipt placed in idw?

khnam
Contributor
Contributor

How does i-logic control custom properties of ipt placed in idw?

 

The standard view of part A was placed in idw.
At this time, I would like to create an item called A-1 in the Custom Properties of Part A and enter the user input value there.

' Get the current IDW document.
Dim idwDoc As DrawingDocument
idwDoc = ThisDoc.Document

' Collect IPT files placed in the IDW.
Dim iptFiles As New List(Of Document)
For Each view As DrawingView In idwDoc.ActiveSheet.DrawingViews
If view.ReferencedDocumentDescriptor.ReferencedDocumentType = DocumentTypeEnum.kPartDocumentObject Then
iptFiles.Add(view.ReferencedDocumentDescriptor.ReferencedDocument)
End If
Next

' Perform the operation for each IPT file.
For Each iptFile As Document In iptFiles
' Prompt the user to input the value for the "Size" property.
Dim specValue As String
specValue = InputBox("Enter specification for " & iptFile.DisplayName & ":", "Specification Input")

' Update or add the "Size" property in the "Design Tracking Properties" of the IPT file.
Dim customProps As PropertySet = iptFile.PropertySets.Item("Design Tracking Properties")
Dim specProp As Inventor.Property
Try
specProp = customProps.Item("Size")
' Update the value if the property exists.
specProp.Value = specValue
Catch
' Add a new property if it doesn't exist.
specProp = customProps.Add(specValue, "Size")
End Try
Next

 

0 Likes
427 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @khnam.  The first 3 PropertySet objects within the Document.PropertySets collection are the 'standard' ones, which exist in every document, and have a static number of Property objects in them, with specific names.  You can not change the names of any of those PropertySet objects, and can not change the names of any of the Property objects within them, and can not add any new Property objects in them.  There are some Property objects in them that have Read/Write values, but I believe that most in the third ("Design Tracking Properties") set are ReadOnly.  And there is no property in that third set named "Size", but there is one named "Size Designation".  But I think that one named Size Designation is used by the Content Center, or something like that.  The fourth PropertySet in the collection is always the primary 'custom' one, and it always exists in every document, but usually does not contain any Property objects, unless you have specifically created them, or if you have set some Parameter objects to export, which automatically creates a custom iProperty with the same name and value as that Parameter.

Attached is a PDF of an Excel spreadsheet I made a some time ago, documenting a lot of the details of the iProperties, as a reference sheet.  If you need to create a new iProperty, then it will need to be created within the fourth PropertySet, named "Inventor User Defined Properties" (in English installations).

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

khnam
Contributor
Contributor

Hi

I want to edit or enter the value of Custom properties of ipt in idw.

However, when I try to control IPT by creating logic in idw, an error appears.

0 Likes
Message 4 of 5

m_baczewski
Advocate
Advocate

Hello,

 

Try running this code and let me know if everything is working well. I changed: Item("Inventor User Defined Properties")

' Get the current IDW document.
Dim idwDoc As DrawingDocument
idwDoc = ThisDoc.Document

' Collect IPT files placed in the IDW.
Dim iptFiles As New List(Of Document)
For Each view As DrawingView In idwDoc.ActiveSheet.DrawingViews
If View.ReferencedDocumentDescriptor.ReferencedDocumentType = DocumentTypeEnum.kPartDocumentObject Then
iptFiles.Add(View.ReferencedDocumentDescriptor.ReferencedDocument)
End If
Next

' Perform the operation for each IPT file.
For Each iptFile As Document In iptFiles
' Prompt the user to input the value for the "Size" property.
	Dim specValue As String
	specValue = InputBox("Enter specification for " & iptFile.DisplayName & ":", "Specification Input")
	
	' Update or add the "Size" property in the "Design Tracking Properties" of the IPT file.
	Dim customProps As PropertySet = iptFile.PropertySets.Item("Inventor User Defined Properties")
	Dim specProp As Inventor.Property
	Try
	specProp = customProps.Item("Size")
	' Update the value if the property exists.
	specProp.Value = specValue
	Catch
	' Add a new property if it doesn't exist.
	specProp = customProps.Add(specValue,"Size")
	End Try
Next

 

Message 5 of 5

WCrihfield
Mentor
Mentor

Just another related tip.  Here is the quickest way to access/change custom iProperties that are within a model document being referenced within the currently 'active' drawing document for that model.  Expand the BrowserNode for the Sheet, then expand the BrowserNode for the View, then right-click your mouse on the model document's BrowserNode, and choose 'iProperties' from the right-click menu.  The iProperties dialog will show, but it will be for the 'model' document, not the active drawing document.  Below is a screen captured image of me doing this in a drawing, just to show you how quick/simple it is.

WCrihfield_0-1705434267605.png

And likely the shortest route to the custom iProperties of 'the model' (assuming there is just one), from an iLogic rule that is in its running from the drawing, is the following combination of two iLogic shortcut snippets.

iProperties.Value(ThisDrawing.ModelDocument.DisplayName, "Custom", "Test") = "My Test Value"

(iProperties.Value)...where the 'ThisDrawing.ModelDocument.DisplayName' portion (Link, Link, Link) is where you specify the 'name' of a Document that is being referenced by the 'active' document.  And the "Custom" portion specifies the name (we can use short version) of which PropertySet that the Property is located within.  And the "Test" portion is where you specify the name of the Property.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)