Hello,
I'd like to delete all custom iProperties from a drawing which I've opened. I tried to adapt this:
It works fine for Parts but not for drawings. Can anyone help?
Thanks
Fabian
Solved! Go to Solution.
Solved by dalton98. Go to Solution.
That code should work for any document, so I'm assuming you want to delete the custom properties of the assembly from a drawing document?
Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oView As DrawingView oView = oDrawingDoc.ActiveSheet.DrawingViews.Item(1) Dim oDoc As Document oDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument 'define custom property collection oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties") 'look at each property in the collection For Each oCustProp In oCustomPropertySet 'delete the custom iProperty oCustProp.Delete Next
It worked for me. Try changing it from thisdoc to active document:
Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oCustomPropertySet As PropertySet oCustomPropertySet = oDrawingDoc.PropertySets.Item("Inventor User Defined Properties") 'look at each property in the collection Dim oCustProp As Inventor.Property For Each oCustProp In oCustomPropertySet 'delete the custom iProperty oCustProp.Delete Next
Hi @dalton98
sorry for the late reply, it took me some time to figure things out:
I used a script to create iProperties in a idw file, which worked fine. With another script I wanted to delete all iProperties within the idw file, which didn't work.
The problem seem to be the names of my iProperties. If they start with an underscore (for example "_S_M40_PROJEKTBEZEICHNUNG") they can't be deleted with a script, also they are not shown in the list of custom iProperties in the iLogic forms. Although the import-script works just fine.
I'm using Inventor 2020, is that a known problem?
Are there any other restrictions regarding the names of custom iProperties?
Best regards
Fabian
The only time I have a problem deleting iproperties is when the I'm working outside the part's project file, but it will throws an error explaining that.
I'm assuming the hidden property is giving you the error. You can try a try/catch or 'On Error Resume Next' to skip it. But then again that's probably the one you want deleted.
Can't find what you're looking for? Ask the community or share your knowledge.