Why boolean Attribute does not work?

Why boolean Attribute does not work?

Cris-Ideas
Advisor Advisor
1,880 Views
9 Replies
Message 1 of 10

Why boolean Attribute does not work?

Cris-Ideas
Advisor
Advisor

Hi,

I have another problem with attributes.

Fore some reason attempt to add boolean attribute fails.

 

This line brings up an exception

 occAttributeSet.Add("_0003Associative", ValueTypeEnum.kBooleanType, True)

because of he attribute type.

 

Why boolean attribute does not work?

 

Cris.

Cris,
https://simply.engineering
1,881 Views
9 Replies
Replies (9)
Message 2 of 10

clutsa
Collaborator
Collaborator

Object model looks like ".Add(AttributeName As String, ValueType As ValueTypeEnum, Value) As Attribute" and ValueTypeEnum only has {kByteArrayType, kDoubleType, kIntegerType, kStringType} so set as an integer with value 1 for true and 0 for false and a boolean variable should be able to read/convert/use that just fine.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 10

tomasz.sztejka
Advocate
Advocate

Thanks. Saved me some time. It seems that in this case reading official API was a wrong way to go.

0 Likes
Message 4 of 10

WCrihfield
Mentor
Mentor

Hi @clutsa.  Which version of Inventor are you using, because when I look at the online help page (2022 help) for the ValueTypeEnum, I see 5 variations available, and one of them is kBooleanType (14597).  And I still see it that same way for 2018 & 2019 online help.

@Cris-Ideas 

However, I just tried assigning a Boolean type attribute to one of my test files that I have already assigned a bunch of named entities in, and also got an error.  It's just one of those "The parameter is incorrect." error messages though, and just points to the line where I am attempting to add the attribute, with no further explanation.  I can assign other attributes to the selected face, within the same attribute set, like Double type, but when I try to add a Boolean type attribute, it fails for some reason.  I even tried using a predefined Boolean type variable as the value, instead of True or False directly, but that did not make any difference.  I'm still not sure why though.  There is no documentation on the AttributeSet.Add method's online help page about not being able to create Boolean type attributes.  But there is a page called "Introduction to Attributes and AttributeSets", which talks about them, and on that page it mentions all the other 4 types, but not the Boolean type.  If we can't create boolean type attributes, they should update the Add method's web page to indicate that, and maybe add something to the pop-up help text to help avoid similar issues in the future.  I do know that the ValueTypeEnum is used in several places, so that type may just be available to other situations where it is used.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 10

clutsa
Collaborator
Collaborator

I don't know what version I was using ~3.5 years ago. 😋 My guess is 2018 but we could have still been on 2016 at that point. The question was never accepted as a solution so it's possible I was wrong. Did you try what I suggested to see if it worked?

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 6 of 10

WCrihfield
Mentor
Mentor

Your suggestion about using Integer type and either 1 or 0 is definitely the next logical alternative to the Boolean type, when Boolean type is not available.  Similar functionality is observed within some of the import/export translator methods' options.  Sometimes they use real Boolean value, and other times they use the Binary type value of zero or 1.  I'm sure they had their reasons for using one vs the other.  Since we are able to create & use both iProperties & Parameters with normal Boolean values and functionality, it is just expected that we would have the same functionality in the Attributes system, but it has not been enough of a priority or something.  This might make a good entry in the Inventor Ideas system.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 10

clutsa
Collaborator
Collaborator

I see what you mean. The help page does list five values but the Object Browser still only lists four. When adding iLogic code I'm prompted that kBooleanType is an option but when adding VBA code I'm not. That does seem like error.

 

 ValueTypeEnum.pngValueTypeEnumHelp.png

ValueTypeEnumILogic.pngValueTypeEnumVBA.png

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 8 of 10

JBerns
Advisor
Advisor

I just ran into this problem today. I hope they get the API fixed to support kBooleanType in AttributeSets.

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 9 of 10

WCrihfield
Mentor
Mentor

I mentioned this in Message 4 above, but I know they also use that ValueTypeEnum in other situations also.  Below are all of the Links I found where it is being used within the 2026 online API help documentation.

All these are Attribute related:  Attribute.ValueType Property , AttributeSet.Add Method , & AttributeSet.AddAttributes Method 

These are Content Center table column related, and they do use the Boolean one:  ContentTableColumn.DataType Property & ContentTableColumns.Add Method 

These are MiniToobar related, but do not include the Boolean one, just Double & Integer:  MiniToolbarSlider.ValueType Property & MiniToolbarControls.AddSlider Method 

So, the Boolean variation is being used by the ContentTableColumn, but apparently not by Attributes or that MiniToolbar control.  And I know that the ByteArray variation is being used by the Attributes system, for storing internal iLogic rules and iLogic Form specs within the Document.

In Message 6 above, I mentioned that this would be a good 'idea' to post in the Inventor Ideas board, and so I just did a quick search in that area, and since I did not find one, I just made one myself.  I will post the Link to that Inventor Idea post below, so that it is easy for every one to find, and vote for, so that we can hopefully get this ability either fixed, or added sooner.

https://forums.autodesk.com/t5/inventor-ideas/attribute-valuetype-allow-enable-kbooleantype-valuetyp... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 10 of 10

JBerns
Advisor
Advisor

@WCrihfield,

Great info!

Thanks for the Idea post - I have voted. 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes