- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I am trying to write some code to look through the custom i-properties and if the name of the i-property contains the search term, then delete it.
So far I have got to here...
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") oCustomPropertyName = (oCustomPropertySet.Name) Dim searchTerm As String searchTerm = "Item" For Each oCustomPropertyName in oCustomPropertySet If InStr(1, oCustomPropertyName, searchTerm, CompareMethod.Text) >0 Then MessageBox.Show("We found it", "Debug") Else MessageBox.Show("We didnt find it", "Debug") End If Next
The error i am getting is "Conversion from type 'Property' to type 'String' is not valid."
What am I doing wrong?
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi William,
I have to take a guess. Probably, you need to declare a String variable to capture "CustomPropertyName" value. It is because "CustomPropertyName" itself isn't a String variable.
Many thanks!

Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @johnsonshiue
I have just tried that, I get the same error.
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Dim oCustomPropertyName As String oCustomPropertyName = CStr(oCustomPropertySet.Name) Dim searchTerm as String searchTerm = "Item" For Each oCustomPropertyName In oCustomPropertySet If InStr(1, oCustomPropertyName, searchTerm, CompareMethod.Text) >0 Then MessageBox.Show("We found it", "Debug") Else MessageBox.Show("We didnt find it", "Debug") End If Next
Is the InStr command the best way of going about this? I originally took @Curtis_Waguespack code from an earlier post (https://forums.autodesk.com/t5/inventor-forum/how-to-remove-custom-iproperty-with-ilogic/td-p/436406...)
but the ".contains" method doesnt seem to work if the search term is inside the string, eg. it will not pick up that "Item" is contained inside "Item8_Code"
so I found another post that I though would be applicable (https://forums.autodesk.com/t5/inventor-customization/code-vb-for-if-quot-value-quot-contains-quot-t...)
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @william
This should work for you.
Also recall that there is the Inventor Customization forum , where programming questions of this type are better suited:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I'll ask the moderators to move this to that forum.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Dim searchTerm As String
searchTerm = "Item"
For Each oProp In oCustomPropertySet
If oProp.name.Contains(searchTerm) Then
MessageBox.Show("We found: " & oProp.name _
& vbLf & "Now we're going to delete it!", "iLogic")
oProp.delete
End If
Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report