Error when trying to add custom iProperty.

Error when trying to add custom iProperty.

shizahkhalid
Contributor Contributor
314 Views
3 Replies
Message 1 of 4

Error when trying to add custom iProperty.

shizahkhalid
Contributor
Contributor
Sub AddItemCodeiProperty(partDoc as PartDocument, ItemCode As String)
	
	Dim propertyName As String = "Item Code"
	Dim propertyValue As String = ItemCode

	customPropertySet = partDoc.PropertySets.Item("Inventor User Defined Properties")
	Try
		prop = customPropertySet.Item(propertyName)
	Catch
		' Assume error means not found
		customPropertySet.Add("propertyValue", propertyName)
	End Try

	iProperties.Value(partDoc.DisplayName, "Custom", propertyName) = propertyValue
End Sub 

For the above code, I am getting the following error for line 11 (customPropertySet.Add("propertyValue", propertyName)):

img.jpg

img2.jpg

This function runs perfectly on my PC but gives the above error on the client's PC, so I'm unable to get to the bottom of it. Would appreciate any guidance. 

0 Likes
315 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

Your code looks fine and works for me.

You can check the Document.IsModifiable Property before you try to add new iProperty

 

Note: Line 14 is unnecessary, because you can create iProperty (11) with appropriate value and set the value after (8)

Message 3 of 4

m_baczewski
Advocate
Advocate

Hi @shizahkhalid 

 

I used your code to create iProperties for my parts, assemblies, and components, and everything went according to plan. However, I managed to get an error similar to yours when trying to add iProperties in Content Center elements. It is possible that in your code, you iterate through the elements, create iProperties, and try to assign them to the element within the Content Center items. I'm not entirely sure how your rule works.

Message 4 of 4

zy19860604
Collaborator
Collaborator

Please check whether the content center document is read-only.