How to write number of custom iProperties for all opened drawings to a list?

How to write number of custom iProperties for all opened drawings to a list?

fabimann
Contributor Contributor
396 Views
2 Replies
Message 1 of 3

How to write number of custom iProperties for all opened drawings to a list?

fabimann
Contributor
Contributor

Hi,

I'm trying to set up an external iLogic rule to export the file name and the number of custom iProperties for all opened drawings to a file. The result should look something like this:

 

NAME - NUMBER OF CUSTOM IPROPERTIES

file name 1.idw - 24

file name 2.idw - 7

 

Every hint is highly appreciated.

Best regards

Fabian

0 Likes
Accepted solutions (1)
397 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor
Accepted solution

What you will need is to access the documents object and look for visible documents collection. Loop through this collection and then check the document type against an  object type enumerator, you will find drawing "kDrawingDocumentObject" in that list. Then access the document object and look for fullfilename. Then access iproperties collection known as property sets then the custom iproperty property set known as "Inventor User Defined Properties" . Then retrieve the count per document of this custom iproperty. 

 

Links for code creation from API help:

Documents object

Document Type

Object Type Enumerator

Document Object

Custom iProperty Sample 

Property Set Count

 

Dim sList As New ArrayList 
Dim opendoc As Document
For Each opendoc In ThisApplication.Documents.VisibleDocuments
	If opendoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject  Then
	 	' Get the user defined (custom) property set.
	    Dim invCustomPropertySet As PropertySet
	    invCustomPropertySet = opendoc.PropertySets.Item("Inventor User Defined Properties")
		sList.Add(opendoc.FullDocumentName & " - " & invCustomPropertySet.Count)' add to arraylist
	End If
Next

Item = InputListBox("Prompt", sList,Item, Title := "Drawing List", ListName := "List")
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

fabimann
Contributor
Contributor

Good morning,

it works perfectly thanks a lot for the code and the additional informations.

Best regards

Fabian