« Back

"Position" attribute

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
"Position" attribute
community graphrep special attribute documentation
Answer
3/27/14 12:14 PM
We tried to add text to a relation in GraphRep, but experienced problems, when moving objects around.

How can we get the position of the class from an attribute?

RE: "Position" attribute
Answer
11/18/13 8:50 AM as a reply to Anonymous.
For getting the position of an object, you have to read the attribute "Position":

 1# the variable objectid contains the ID of the object
 2CC "Core" GET_CLASS_ID objid: (objectid)
 3 # --> RESULT ecode: intValue classid: intValue isrel: intValue
 4SET id_ClassID: (classid)
 5CC "Core" GET_ATTR_ID classid: (id_classID) attrname: ("Position")
 6 # --> RESULT ecode: intValue attrid: id .
 7SET id_PositionAttrID: (attrid)
 8CC "Core" GET_ATTR_VAL objid: (objectid) attrid: (id_PositionAttrID)
 9 # --> RESULT ecode: intValue val: anyValue
10SETL sObjPosition: (val)

The resulting value is a string looking like this:  "NODE x:16.5cm y:7cm w:4cm h:4cm index:3" ; x and y are the coordinates of the top-left corner, w and h are the width and height of the object's graphical representation and index represents the index of the layer containing the object.

For extracting the values for x, y, w, h or index you can either implement a parser of your own using AdoScript, or you can use the LEO parser included in the AdoScript commands.
Below is a simple example of how to use the LEO parser:

1LEO parse: (sObjPosition) get-tmm-value:n_x_fromobj:"x" get-tmm-value:n_y_fromobj:"y"      

where:
sObjPosition is the string you want to parse
x and y are the parameters whose values you want to extract from the string, followed by the special carracter ':'
get-tmm-value is a keyword used for extracting the value in a dimensional format (centimeters)
n_x_fromobj and n_y_fromobj are the names of the variables where the extracted values will be stored


The LEO command can be used for parsing any string. The full sytax of the LEO command is:

LEO ParseCmd { AccessCmd }
 
ParseCmd : parse:strExpr
 
AccessCmd : get-elem-count:varName | set-cur-elem-index:intExpr | get-keyword:varName | is-contained:varName [ :strExpr ] |
              get-str-value:varName [ :strExpr ] | get-int-value:varName [ :strExpr ] | get-real-value:varName [ :strExpr ] |
              get-tmm-value:varName [ :strExpr ] | get-time-value:varName [ :strExpr ] | get-modifier:varName:strExpr