- List -> AddItem (Object: Objecttype, Index: Integer):VoidType
Method used to add an item to the list. If the index is equal to 0,
the new item is added at the end of the list. If the index is equal to
1, the new item is inserted into the list at the location indicated by
the index, meaning that the existing item is replaced with the new one
and is therefore removed from the list. It is recommended to use the
InsertItem method.
Example:
let list (List)
list -> AddItem(PartBody\Hole.2
,1)
list -> AddItem(PartBody\Hole.3
,2)
Message("#",list.Size()) |
|
- List -> InsertItem (Object:ObjectType, Index: Integer):
VoidType
Method used to insert an item into the list. Where:
Object is the object to insert into the list.
Index is the location of the object to be inserted into
the list (Starts at 1)
|
- List -> Append (Object:ObjectType)
Method used to add an item at the end of the list. Where:
Object is the object to insert into the list.
|
- List -> SetItem (Object:ObjectType, Index: Integer):
VoidType
Method used to replace an item in the list. Where:
Object is the object to insert into the list.
Index is the location of the object to be
replaced in the list. In this case, the object to be replaced is
deleted (The index starts at 1)
|
- List -> RemoveItem (Index: Integer) :VoidType
Method used to remove an item from the list.
Index
is the location of the object to be removed in the list. The index
starts at 1.
|
- List -> RemoveAll(): VoidType
Method used to empty the list.
|
- List -> ReorderItem (Current: Integer, Target: Integer
) :ObjectType
Method used to move an element of the list referenced by its
position to a new position. Positions start at 1.
|
- List -> Compute(Operation: String, Type: String,
Expression: String, Result: out UndefinedType): VoidType
Function used to compute the result of an operation performed on
all elements of the list. It is
available for Actions, Reactions and in Knowledge Expert.
There are two usages for this method:
- On list of values, it simply computes an operation on the values
(+, min, max).
- On list of objects, it will compute an operation on results of
expressions on the object.
Example: List.1 -> Compute("+","","",Length.1)
This example sums all the values of the list.
Where:
- List.1 is the name of the list on which the calculation
will be performed
- + is the operator used. (Supported operators are: +, min,
and max.)
- The first "" string must be empty to indicate that we work on list
of values.
- The second"" String must also be empty when working on list of
values.
- Length.1 is the output parameter.
Example: List.1 -> Compute("+","Hole","x.Diameter+x.Depth",Length.1)
This example sums all the addition of the diameter and the depth of all
holes in the list.
Where:
- List.1 is the name of the list on which the calculation will be
performed.
- + is the operator used. (Supported operators are: +, min, and
max.)
- The first string contains the expected type of the objects of
the list (in this case, it is a list of holes)
- The second String contains a formula that will be computed on
each element of the list (holes in this case) and that will return a
value. In this expression the variable x is used to represent the
element in the list. One can then access its attributes for
instance.
Length.1 is the output parameter.
1 |
- List -> Apply (Type:String, Expression: String): VoidType
Applies a given expression to the objects of a list that are of a given
type. In this expression, the element of the list is represented by a
variable named x.
Example:
//Finds all rule bases and executes them
let L (List)
//P being Part Feature
/* Finding a value */
L = P -> Query("RuleBase","")
L -> Apply ("RuleBase","x -> Update()")
|
|
- List -> Filter(Type:String, Condition: String):
List
Method used to filter a list of objects by extracting the objects
that fulfill a Boolean expression.
Arguments
TypeName is the type of the objects that the
user wants to extract (in can be
"".
In this case, no filtering is done on types).
- The second string Expression corresponds to the Boolean
expression that must fulfill the objects of this given type. In
this expression "x"
is used as the variable name of type TypeName. This string can
be equal to "".
In this case, no expression is checked.
Example:
I = (List -> Filter("Hole","x.Diameter
> 3mm")).Size()
I = (List -> Filter("Hole","")).Size()
|
- +(List1: List, List2: List): List
Operator enabling you to add two lists and to return a third
one. Adding two lists means concatenating the elements of the two lists
and affecting the result to the returned list. The elements of the first
list will be at the beginning of the resulting list. The order of the
elements is kept.
This operator works on list of objects (persistent or not) or on list of
values (persistent or not).
If the operation required is not feasible (for example, trying to fill a
persistent list with a non persistent value), evaluation errors are
raised.
There is no simplification of the list (an element can be there twice
after the operation). Example:
Let L1(List)
Let L2(List)
Let L3(List)
L3=L2+L1
|
- List -> Extract (Type: String, TypeOutput: String,
Expression: String):List
Method used to extract some information on the items of the
list.
Arguments
Type : Knowledge types considered by the extract function
meaning that the list is first filtered to take only elements of a
given type into account. The type can be a value type or an object
type.
TypeOutput : Type of the object produced by the Extract
method. The output list contains the objects of this given type. The
type can be a value type or an object type.
Expression : Knowledge rule expression with two arguments,
x of type Type and y of type TypeOutput . The expression
must valuate y
depending on the expression computed on x. The expression can use
the if , else , for , let keywords like in a rule.
Note that:
- The list in output contains elements computed by the
expression on all the objects filtered on the list. The list may be
empty and its size may be less that the list in input if some
elements of the list in input have been filtered because they were
not of the right type.
- If
Type or TypeOutput are not a recognized type, an
evaluation error will be raised.
- If the
Expression is not syntactically correct, an
evaluation error is raised.
Example:
Let L1(List)
Let L2(List)
…
L2=L1 -> Extract(“Hole”,”LENGTH”,”y=x.Diameter+x.Depth”)In this
example, we produce a list in output that is the extraction of the sum
of the diameter and the depth of the holes in the list. |
- List -> Sort (Operator: String, Type:String,
TypeOutput:String, Expression: String):List
Method used to sort lists. It operates the sort based on a criteria
that corresponds to an extraction (see previous method).
Arguments
Operator : Accepted values are “<”, “>” .
These operators are used to sort the list.
Type : Type of the list objects taken into account. It can
be a type of value or a type of object. The type must be indicated
because it is used to validate the expression. All objects of the
list should be inheriting from this type.
TypeOutput : Type of the object produced using the
Sort
method. The output list contains objects of this given type. The
type can only be a value type. It can be a Real or a String.
Expression : Knowledge rule expression with two arguments,
x of type Type and y of type TypeOutput . The expression must valuate
y depending on the expression computed on x. The expression can the
if, else, for, let keywords like in a rule. The expression
can be empty if the list is a list of values.
Note that:
- If the operator is not equal to
“>” or “<” ,
an evaluation error is raised.
- If
Type or TypeOutput is not a recognized type, an
evaluation error is raised.
- This method does not operate on the list itself but
produces the sorted list in output. As a consequence, to solve the
problem, we should have created a new List and valuated it with:
"NewList = FilletRadius -> Sort(">","LENGTH","LENGTH","")
This example sorts a list of values.
"NewList = HoleList -> Sort(">","HOLE","LENGTH","y=x.Diameter")
This example sorts a list of holes based on their diameter.
|
List -> RemoveDuplicates
Method used to modify the content of the list by extracting
the duplicated elements.
Note that this method does not have the same behavior on lists of
parameters and on lists of values. On Lists of parameters, it removes
the parameter that are present twice in the list. On lists of values, it
removes the values that have the same value
|