Welcome to the COE Discussion Forum! 

 

To participate in the discussion forum, you must be logged in to the website.  If you forget your login information, please contact COE Headquarters at coe@coe.org or (800) 263-2255.

If you are new to the COE Discussion Forum and would like to participate, please register.


Forum Highlight: CATIA V6

 

Get Answers to Your V6 Questions
Dassault Systèmes answers user questions about CATIA V6.  Discuss these answers and propose new questions with end users from around the world in the CATIA V6 Forum.

COE DISCUSSION FORUM
Subject: Controlling Muiti-value String Parameters

You are not authorized to post a reply.   
Author Messages
COE-FORUM-USER

23 Jan 2006 11:57 AM
Greetings Lads

Say I have created a new parameter of type "String" with "Multiple Values" with the f(x) button.

I give the parameter (call it "MyString") the following possible initial values

Option1
Option2
Option3

Option 1, 2 and 3 are generic. If a user wants to rename them to something more logical (eg, Steel, Aluminium, Composite) they can do so by double clicking the parameter, then right-clicking "Update Values". Problem is, what if I have some KWA programing (wanting to keep it generic) that relies in the text "Option1", "Option2" etc. For example:-

if(MyString=="Option1")
{do this}

else if (MyString=="Option2")
{do that}

Does anyone know how to program something (preferably within KWA) that can keep the link between the KWA programing and the String values after they are changed? I have the feeling the answer will be "No, use VB", but please give me your thoughts.

Alternativly, say I want to automatically rename MyString's value range {"Option1", "Option2", "Option3"} according to some other info I have got from the user. Does anybody know how to do this.

Thanks
J

PS: As another side question, do posts relating to V5 Knowledge programing belong in the Knowledge section or in the V5 Programming section of this forum?
BPRASAD


24 Jan 2006 05:38 PM
By putting the string within the double quotes in KWA, you are indicating that the contents are fixed and you do not wish to change it. If you wish those to change dynamically, you may have to program it little differently. You may want to define two String parameters: say (Option1 and Option2) – each single value and assign them some initial/default values. The name of the two attributes remains fixed only its values or contents change. String with Multiple values would not work since “GetAttributeString” at present is not equipped to read entries in a “String Parameter with multiple values.” If you wish that to be made available, please submit Enhancement Request at COE site.

Define Source {B: PartFeature} in KWE Rule
Here is what you can do in a KWE Rule editor:
if(B-> GetAttributeString (“MyString”) ==B->GetAttruibuteString (“Option1”) )

{do this}

else if (B-> GetAttributeString (“MyString”)== B->GetAttruibuteString (“Option2”) )
{do that}

At present, KWA rule does not provide enough flexibility like KWE Rule does. May be in future you would be able to do that in KWA rules as well. Again submit request for Enhancement on COE web site, if you wish that to be made available in future releases.

Brian Prasad
COE-DPC/KBE Chairperson
COE-FORUM-USER

25 Jan 2006 03:32 AM
Thats a good workaround, Thanks.

COE-FORUM-USER

26 Jan 2006 04:37 AM
Hello,

you can access to multiple values information thanks to attribute AuthorizedValues, which returns a list.

For example :
Length.1.AuthorizedValues = List(1mm, 2mm, 3mm) /* uses list constructor */

or
Message("This parameter has # authorized values", parameter.AuthorizedValues.Size())

So you can set or read those values, and write generic rules...

I don't understand Brian's remarks : you can use part->GetAttribute... in KWA rules as well.

Bye
BPRASAD


26 Jan 2006 01:09 PM
I misspoke. I was trying to use GetAttributString in KWA first and I was not successful.
I was getting "The Interface referenced by this Handler is Null" Error. I don't know why?

1. I am indeed very pleased to know that GetAttributeXX and SetAttributeXX can be used inside a KWA rule.
Could you kindly post an example of its use in KWA rule?

2. Also it is nice to know that we can process the contents of a multi-valued parameter via "AuthorizedValues".
Piping its contents into a "List" is even better, because it is easy to manipulate list Parameter.

Thanks for the your kind posting.

Brian Prasad
COE-DPC/KBE Chairperson
COE-FORUM-USER

27 Jan 2006 11:07 AM
Thats Ok Brian, I know what you were getting at, and your workaround did work, I should have mentioned that I did it in KWA......I just figured you were more comftorable with KWE syntax so you gave your example that way. AuthorizedValues was however the ultimate solution to my problem.

And your forgiven for not realising that Set/GetAttributeXXX can be used in a KWA rule. The "Object" family of Set/GetAttributeXXX operators appear in the KWA dictionary if you are editing a Reaction, but not if you are editing a Rule. They do however work fine in Rules. I develop my KWA rules in the reaction editor, then copy and paste them into a rule once they are debugged.

Cheers to the developer for the tip on AuthorizedValues. One more question......(I hope you read the thread again).......Where would I normally find this documented for the KWA? So far all these sort of goodies I find indirectly, by reading random examples from the online help, or guessing keywords from other languages/KWE Dictionary/VB. Its slow and painful.

Jase
COE-FORUM-USER

27 Jan 2006 11:26 AM
Hi,

actually, we try not to show methods that are not fully compliant with formulaes/rules/actions behaviours : GetAttribute... breaks associativity because a rule is not evaluated even if the attribute is modified (or you can not be sure it will be evaluated). This is the reason why this functions are hidden from rule editor.

Also, I think AuthorizedValues is documented somewhere in our documentation before R16, but R16 is a major enhancement for this kind of things:
- documentation of the language has been improved and makes it easier to find functions/methods and attributes
- a new language browser is available in all our editors (see in icons at the right and top of KWA editors for example). It allows to select an object or a type and see other types supported, all attributes available and functions/methods you can use on it or to get it. It reacts to selection in editors and in general frame (3d, tree). And typing F1 gives you access to the documentation.

Great isn't it?
Bye
BPRASAD


27 Jan 2006 12:33 PM
I am glad you made it work. Will it be possible, if you could kindly post/share your "neutral and generic KWA solution" to this thread -- for the benefits of the rest of the KBE/KW users. Thanks!!!

Brian Prasad
COE-DPC/KBE Chairperson
You are not authorized to post a reply.
Forums > COE Forums > KBE > Controlling Muiti-value String Parameters



ActiveForums 3.6

    

401 North Michigan Avenue, Chicago, IL 60611-4267 | (312) 321-5153 | (800) COE-CALL (U.S.)