"[AIS 2010 + SP2] print PropertySets and Properties

"[AIS 2010 + SP2] print PropertySets and Properties

PolemEngineering
Advocate Advocate
389 Views
2 Replies
Message 1 of 3

"[AIS 2010 + SP2] print PropertySets and Properties

PolemEngineering
Advocate
Advocate
I discovered this problem while working on a sub (with help of some forum-users). Ik replied this in http://discussion.autodesk.com/forums/thread.jspa?threadID=762164 , but while getting deeper in it, I decide this is a totaly different problem as described in this thread.

With a simple code I retrieve all PropertySets and their Properties.
{code}
Option Explicit

Public Sub AllPropSetsAndProps()
Dim oPropSet As PropertySet
Dim oProp As Property

For Each oPropSet In ThisApplication.ActiveDocument.PropertySets
Debug.Print oPropSet.DisplayName & " Count: " & oPropSet.Count
For Each oProp In oPropSet
Debug.Print " '" & oProp.Name & "' = '" & oProp.Value & "'"
Next
Next
End Sub
{code}

In a testpart I used this code, and it works. Now I copy past it to another document and then I get an error.

Run-time error '91'
Object variabele or With block variable not set

I get this error halfway executing the code. Everytime the code end on the same property
{code}
'Catalog Web Link' = ''
{code}

The next property should be:
{code}
'Part Icon' = '0'
{code}

The weird part is that when I create a new document holding the Shift + Ctrl buttons the error don't show up.

Is there anyone who can tell me wat is going wrong here..

thnx in advance,
René

//edit
It looks like it has to do with the .Value When I only ask for the Property.Name there is no error. Is it possible that there are properties without a value set...? Edited by: PolemEngineering on Feb 26, 2010 8:55 AM

René van der Starre

0 Likes
390 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
I suspect your problem is the value type of some properties. Most of the
values are strings and a few others are other simple types (Date, Currency,
Long, and Boolean), however two of them are IPictureDisp type to allow them
to contain a picture. Trying to display this using a Debug.Print statement
will fail because it can't convert this type to a string.
--
Brian Ekins
Inventor API Product Designer
http://blogs.autodesk.com/modthemachine
0 Likes
Message 3 of 3

PolemEngineering
Advocate
Advocate
Hello Brian,

thanks for responding. I think I understand your explanation, but
when I use the code, provided in one of the Inventor API Tutorials, it debugs the type (I expect..., again I don't have access to my workstation as this time) of Part Icon as:
the working part As Picture and the part with te error As Nothing.

So the working part is converting the type to a string when providing the value

It's strange that when I create a new part using the normal way (from template) there is an error when running the script, and when useSaveCopyAs from a template (I don't want to go this way) the code is running well.

Anyway, It looks like it has everything to do with the type of the variables. I don't need these properties. "On Error Resume Next" is enough at the moment...

Edited by: PolemEngineering on Feb 27, 2010 3:46 PM

//Edit2
De code I meant was:
{code}' Displays information about all of the property sets and their properties.
Public Sub DumpPropertyInfo()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oPropSet As PropertySet
For Each oPropSet In oDoc.PropertySets
Debug.Print "Name: " & oPropSet.Name & ", DisplayName: " & oPropSet.DisplayName & ", InternalName: " & oPropSet.InternalName
Dim oProp As Property
For Each oProp In oPropSet
Debug.Print " " & "Name: " & oProp.Name & ", DisplayName: " & oProp.DisplayName & ", PropId: " & oProp.PropId & ", Variant Type: " & TypeName(oProp.Value) '& oProp.Value
Next
Next
End Sub{code}

The working part gives for example the following line:
Name: Part Icon, DisplayName: Part Icon, PropId: 28, Variant Type: Picture
and with the other code:
'Part Icon' = '0'

And the 'error-part':
Name: Part Icon, DisplayName: Part Icon, PropId: 28, Variant Type: Nothing Edited by: PolemEngineering on Mar 1, 2010 6:27 AM

René van der Starre

0 Likes