delete all custom iProperties from drawing

delete all custom iProperties from drawing

fabimann
Contributor Contributor
958 Views
8 Replies
Message 1 of 9

delete all custom iProperties from drawing

fabimann
Contributor
Contributor

Hello,

I'd like to delete all custom iProperties from a drawing which I've opened. I tried to adapt this:

 

https://forums.autodesk.com/t5/inventor-forum/how-to-remove-custom-iproperty-with-ilogic/td-p/436406... 

 

It works fine for Parts but not for drawings. Can anyone help?

Thanks

Fabian

0 Likes
Accepted solutions (1)
959 Views
8 Replies
Replies (8)
Message 2 of 9

dalton98
Collaborator
Collaborator

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
Message 3 of 9

fabimann
Contributor
Contributor

Hello @dalton98,

thank you for the quick reply. The code does work as you intended, but it is not was I was looking for. I want to delete all custom iProperties from an idw file. How should the code be adapted?

Best regards

Fabian

0 Likes
Message 4 of 9

dalton98
Collaborator
Collaborator
Accepted solution

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
0 Likes
Message 5 of 9

fabimann
Contributor
Contributor

@dalton98 

It still doesn't remove the custom iProperties from the idw file. Are there any restrictions or modifications to be made as I'm using a german version of Inventor?

0 Likes
Message 6 of 9

dalton98
Collaborator
Collaborator

Ohhh. Try changing this maybe.

oCustomPropertySet = oDrawingDoc.PropertySets.Item(4)
0 Likes
Message 7 of 9

fabimann
Contributor
Contributor

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

 

 

0 Likes
Message 8 of 9

dalton98
Collaborator
Collaborator

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.

0 Likes
Message 9 of 9

fabimann
Contributor
Contributor

@dalton98 

 

I deleted the iProperties manually and changed my naming scheme in the Excel file to avoid further problems.

 

Thanks for your effort, much appreciated

Fabian

 

0 Likes