|
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 |
|
|
 |
|
 |
| You are not authorized to post a reply.
|
|
| Author |
Messages |
|
COE-FORUM-USER
 |
| 11 Jan 2006 12:10 PM |
|
Hi Everybody. Its my first post....so I just wanted to begin by saying thanks in advance for this great forum.....wish I new about it earlier!
Im working with the KnowledgeAdvisor workbench in V5 R14 SP5 on a FOR/WHILE loop that im executing via a KWA-Reaction. I need to somehow extract the Name (name, not Value) of the ith item of a list.
Example: "ParameterListX" is a temporary KWA list filled with 40 or 50 length type parameters that belong to say, FeatureX.
I need to be able to code something along the lines of :- sName=ParameterListX.GetItem(i).Name()
The issue in the above code is the “.Name()” bit.
ParameterListX.GetItem(i) successfully retrieves the value of the ith item in the list, but how the hell do I retrieve the name of the ith item?????
If you create a list interactively then view its contents, its has two columns. The first is the Name, the second is the value. So the info is there. How to extract it?
Please Help
J |
|
|
|
|
BPRASAD

 |
| 11 Jan 2006 03:52 PM |
|
I know what you mean. DS uses "Name" and "Value (type) pair-schema to store the List information. I have not been able to access the Name only its ITEMs/values.
I don't know whethet List is a way to arrange an array of "pairs?" By design "List" is commonly meant to store an unknown number of contents/items -- usually implicitly captured from a Query command.
Hope this helps...
Brian |
|
Brian Prasad COE-DPC/KBE Chairperson |
|
|
COE-FORUM-USER
 |
| 12 Jan 2006 04:09 AM |
|
Hi Brian
Thanks for your reply. You are right, in my rule/reaction I am implicitly capturing the contents of the list with the "Query" command. The list contents and size will change over time, so im trying to make the code robust enough that it works in all cases, and can basically be copy and pasted from master model to master model to perform the same task.
Without going into too much boring detail, once i can extract the name of the particular parameters in the list, I am trying to use SetAttributeReal("ParamName", Value) to synchronise the parameters with an externally stored company knowledgebase. Because SetAttributeReal explicitly requires the "ParamName", i need to somehow implicitly grab it from the list.
So to any of the other KWA experts out there, I think my question still stands. |
|
|
|
|
COE-FORUM-USER
 |
| 12 Jan 2006 04:15 AM |
|
| Or perhaps someone can suggest another way to find/store/sort/modify an array of pairs in the KWA language.................. |
|
|
|
|
COE-FORUM-USER
 |
| 17 Jan 2006 09:48 AM |
|
Hello,
sorry this not possible with lists containing parameters :
1. The name property is not available for parameters (only for "true features") 2. The method GetItem transforms the real parameter in a "value" which is only a copy of the initial parameter. So even if Name property was available, it would not work...
I see a possible bypass, but not a nice one : you can use a Macro with arguments, pass it the list containing the parameters, and the index. Then you will probably be able to access list elemenst and their name property. Now, the point is "How to get this result back?". Once again not a nice thing to do : you can create a string parameter, which will be filled by the macro...
Hope it helps... |
|
|
|
|
IPHILLIPS
 |
| 19 Jan 2006 06:30 AM |
|
| We use lists with a known order. The position in the list can be mapped to the position the the second list. Thus making a pair. I dont know if this can work for you. |
|
Ian Phillips. FORCEFIVE AG, Munich, Germany |
|
|
COE-FORUM-USER
 |
| 19 Jan 2006 07:04 AM |
|
Hi Everyone, thanks for all the thoughts on this. Thanks "ds_developer2" for the definate answer on how lists work, its good to know for sure that its not possible.
Ian, I was going down that path (a pair of lists) as a workaround but got stuck (catch 22 situation). The main problem is that the lists are dynamic in that names and order change from time to time, and obviously I don't want to be making customized rule/reaction alterations for every user case.
At the moment I have all the parameters ordered into an openbody (not a parameter set). Perhaps its a bit dodgy, but I did this because it made it very easy to implicitly fill the list with the parameter values. Using just KWA (no VB) i havn't yet found a way to fill a second list with the parameter names.
If anyone has any other ideas I'm all ears. My VB is a bit rusty, so I only want to try "ds_developer2"s VB workaround as a last resort.
Thanks, Jason |
|
|
|
|
BPRASAD

 |
| 19 Jan 2006 10:00 AM |
|
For some of you who don't know, this is to inform you that V5R16 contains some brand news KWA/KWE features which work on “Lists.” Just like what you could do with Real * For writing an attribute value,
- Feature->SetAttributeReal (attributeName: String, Real) : Void
* Or for reading an attribute value from the tree
- Feature->GetAttributeReal (attributeName: String) : Real
Note: Up to V5R15, the above methods existed only for Integer, Boolean, String and Dimensions In V5R16, you can apply the same technique on attributes of “List” type.
Meaning you can do the following:
- Feature->SetAttributeObject (attributeName: String, ObjectType) : Void
* Writes the attribute “attributeName” of the object from a value or an object. Can be used for List objects…
- Feature->GetAttributeObject (attributeName: String) : UndefinedType
* Reads the attribute “attributeName” of the object and returns an object. Can be used for List objects
In addition to above, in V5 R16, there are few additional features/functions added. Take a look. May be you can find it helpful. I still believe, you may not be able to do exactly what you wanted. But, may be a “workaround” would be easier for you to create -- if you employ the above two “GetAttributeObject” and SetAttributeObject” functions. Good Luck... |
|
Brian Prasad COE-DPC/KBE Chairperson |
|
|
IPHILLIPS
 |
| 23 Jan 2006 09:37 AM |
|
Brian
Thanks for that news. I have a general question about using GetAttributeReal a Rule. Is there an index of which Attributes are available for each feature?
In this case I am trying to extract the A, B and C components from a Direction:
let DirectionA(direction) let ComponentA(real) ComponentA =DirectionA.GetAttributeReal("A")
I am guessing the name of the attribute string "A" Or am I trying to do it all wrong? |
|
Ian Phillips. FORCEFIVE AG, Munich, Germany |
|
|
COE-FORUM-USER
 |
| 23 Jan 2006 12:01 PM |
|
Brian, thanks for the info. I do have many questions about your post, but at the moment I don't have R16, so I'll ask in the future when im a bit more informed.
Ian, I know what you mean mate. To use the GetAttribute range of functions it seems you first need to know in advance bits of infomation that DSS/"TheDictionary" don't obviously provide you with. Or similarly, you need to know the names of attributes that the user has (in the future) made avaiable to you or modified. This problem was the root of my original post about lists. Look forward to hearing what people have to say.
Its frustrating, KWA seems to have a pretty friendly learning curve, but (to me) is always limited in what you can achieve with it. VB has a horible learning curve (well, not one that users can justify to their boss), but is pretty limitless in what you can do with it. KWA with the power of VB is what we need. Am I asking DSS to turn dirt into Gold here, or do other people find VB ok? Opionions Please?????
Jason |
|
|
|
|
BPRASAD

 |
| 27 Jan 2006 01:32 PM |
|
Hi Ian: I am addressing your specific question you asked on "GetAttributeReal" and SetAttributeReal usage. It is easier for me to describe it with an example. Let us assume you have a right angle triangle with sides A=3in, B=4in. Let us denote Hypotenuse (H) as C. C is unknown (unset). In CATIA, I create 3 parameters A, B and C where A, and B are set at 3in and 4in respectively, and C is unset. Now you write a KWA rule as follows:
/*Rule created by bp51136 1/27/2006*/ let H (Length) H= sqrt (A**2 + B**2) Part4 .SetAttributeReal("C", H)
=============== Note “Part4” was the name of my Part, in which I wrote this rule. In your case, you would replace “Part4” with whatever name of the “part” you are working on. You will notice, in the rule, the “SetAttributeReal” sets a new calculated value (H=5in ) to the Parameter “C”. The value of C will be now 5in. Hint: Sometime, KWA does not recognize “Part4” in the rule. In that case, you need to highlight “Part4” in the KWA rule, point your cursor to “Part4 on the tree, and double click on it. A new “Part4” will be copied onto the rule. The rule should now work fine. |
|
Brian Prasad COE-DPC/KBE Chairperson |
|
|
COE-FORUM-USER
 |
| 30 Jan 2006 02:49 AM |
|
Yep, that bug about the rule forgetting the Part sure is annoying.
Brian, can you always use "Part" as the feature when modifying attributes, or do you find you have to sometimes be more specific? e.g., MyLine.SetAttributeReal("C", H). I never thought of using the part parameter directly......i guess mainly becuase the rule editor often forgets it then gives the useful message "syntax error (< > " |
|
|
|
|
BPRASAD

 |
| 30 Jan 2006 05:21 PM |
|
It depends upon where you have defined your parameters and which parameters set you want to work with?? For instance, if the same set of parameters were defined under PartBody (say under a Pad feature). Let us assume we named them AA, BB and CC respectively to distinguish them from the previous set (Part4\Parameters). Let us assume that you initialize AA= 5in; BB= 12in. Then, CC will be recalculated and written back under Pad feature by using the following rule. /*Rule created by bp51136 1/30/2006*/
let H (Length) H= sqrt (PartBody\Pad. GetAttributeReal("AA")**2 + PartBody\Pad. GetAttributeReal("BB")**2) PartBody\Pad .SetAttributeReal("CC", H)
/* EOR */ The old value of CC will be overwriiten--> CC=13. |
|
Brian Prasad COE-DPC/KBE Chairperson |
|
|
IPHILLIPS
 |
| 31 Jan 2006 03:14 AM |
|
Brian
Thanks for your reply. But what I am looking for is slightly different. I dont have a problem Setting an attribute and then Reading it later.
I wish to read attributes from features that I did not set. Such as the equation of a plane (a.b.c..) or coordinates of a point (Sure, In the "point" case it can be done another way).
The documentation is poor for this. But maybe I'm trying the wrong thing? |
|
Ian Phillips. FORCEFIVE AG, Munich, Germany |
|
|
COE-FORUM-USER
 |
| 01 Feb 2006 05:52 AM |
|
Hello Ian,
in R16, the new language browser will give you this information in two clicks... You will be able to see which attributes are defined on which objects.
Before R16, this information is available in Knowledge Expert in the package browser (you have to find the good package). Another way is to use the search panel in advanced tab which also allows users to see attributes on types. But I'm not sure this information is complete.
Bye |
|
|
|
|
IPHILLIPS
 |
| 01 Feb 2006 09:25 AM |
|
Thanks In KWE using the Rule editor "Browser" you can see the "list of attributes" available for each feature type. But are they not "methods" and not attributes? It does not show which attributes are available for "GetAttributeReal" on a Plane or GSMPlane for example. |
|
Ian Phillips. FORCEFIVE AG, Munich, Germany |
|
|
COE-FORUM-USER
 |
| 01 Feb 2006 10:24 AM |
|
Methods are written "method()" where attributes have no parenthesis "attribute"
On GSMPlane, I see following attributes : Activity Children Color ... PosX PosY PosZ ... UserInfoComment
If I look at only specific attributes (not inherited ones), there are only 4 attributes : PlaneType, PosX, PosY, PosZ (all others coming from super type, so from Plane)
Depending on their type (give in browser Description frame), all these attributes can be used in GetAttributeReal, GetAttributeString, GetAttributeBoolean, ... Those attributes can also be used with SetAttribute... methods if they are not declared as read only (but you don't have access to this information yet) |
|
|
|
|
IPHILLIPS
 |
| 03 Feb 2006 07:34 AM |
|
Thanks So it looks like I cant get the X Y and Z "components " from a plane or Direction. I expect I'd need VBA for that. |
|
Ian Phillips. FORCEFIVE AG, Munich, Germany |
|
|
BPRASAD

 |
| 03 Feb 2006 10:44 AM |
|
Looks like you misunderstood what "ds-developer2" said. Is it not "PosX, PosY and PosZ" you were looking for? |
|
Brian Prasad COE-DPC/KBE Chairperson |
|
|
IPHILLIPS
 |
| 06 Feb 2006 03:08 AM |
|
I assumed "Pos" meant position. Which is not what I need. I need the direction component, sometimes called X,Y,Z or A,B,C. I shall look into this though. Maybe it is. But My test rule cannot retrieve it:
let x(real) x=Set\Plane.GetAttributeReal("PosX") Message("PosX = ",x)
But this gives me the error "Unexisting attribute PosX on the object Plane" Hmmm. |
|
Ian Phillips. FORCEFIVE AG, Munich, Germany |
|
|
|
| You are not authorized to post a reply. |
|
|
|
ActiveForums 3.6
|
|
|
|