Why boolean Attribute does not work?

Why boolean Attribute does not work?

Cris-Ideas
Advisor Advisor
849 Views
6 Replies
Message 1 of 7

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
850 Views
6 Replies
Replies (6)
Message 2 of 7

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 7

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 7

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 7

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 7

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 7

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