Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

delete all custom iProperties from drawing

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
fabimann
438 Views, 8 Replies

delete all custom iProperties from drawing

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

8 REPLIES 8
Message 2 of 9
dalton98
in reply to: fabimann

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
in reply to: dalton98

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

Message 4 of 9
dalton98
in reply to: fabimann

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
Message 5 of 9
fabimann
in reply to: dalton98

@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?

Message 6 of 9
dalton98
in reply to: fabimann

Ohhh. Try changing this maybe.

oCustomPropertySet = oDrawingDoc.PropertySets.Item(4)
Message 7 of 9
fabimann
in reply to: dalton98

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

 

 

Message 8 of 9
dalton98
in reply to: fabimann

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.

Message 9 of 9
fabimann
in reply to: dalton98

@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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report