Object model values different programmatically
-
When I look at the object model, the axes values are 0, 1, 2:
But when I run this code:
var Tool = null var Axis = null while iterations < #tools set var.Tool = iterations while iterations < #tools[var.Tool].axes set var.Axis = tools[var.Tool].axes[iterations] echo "tools["^var.Tool^"].axes["^iterations^"] =", var.Axis
I get 1, 2, 4:
These numbers seem to be 2 taken to the power of the actual numbers. -
@DonStauffer are you sure this isn't from the ^ operator?
-
@DonStauffer tools[n].axes[m] is a bitmap of the machine axes that the user axes are mapped to. It's a bitmap because on IDEX and similar machines you can map a user axis such as X to multiple machine axes.
-
@dc42 Does that mean the object model plugin is displaying the exponent instead of the value? I'm wondering why it's not the same as the programmatic result.
-
@oliof I'm not sure how. It's not even applied after the =, and I don't see anything wrong. I only used ^ to get the subscripts without the space echo adds if you use a comma. The subscripts are just taken from the iterations of the nested loops, so they are in the expected order. The first subscript comes from the outer loop iterations, so it starts from 0, and does the second subscript from the inner loop, so it goes through 0, 1, 2. Then the outer loop goes up to 1 and the inner loop does 0-, 1, 2 again. Everything to the left of the = is just for clarification. I could have just done echo var.Axis and it would have output:
1
2
4
1
2
4 -
@DonStauffer yeah but the value of a bitmap at index 2 is 4.
-
@DonStauffer you can index into a bitmap. So tools[0].axes[2][0] will be the first machine axis that the user Z axis is mapped to.
-
@dc42 That's interesting. I'll have to think about uses for that. I've never seen indexed bitmaps before. Is that only for the object model, or is there a way to do it with regular variables? Besides the obvious which I've already been doing: Divide by powers of 2 and truncate, etc.
-
@DonStauffer tools[].axes[] has a bitmap type in the OM, which is essentially a set of values all of which lie within a certain range. RRF meta GCode doesn't really support set types, but in order to allow you to delve into it, RRF lets you use the # operator on it (to ask how many bits are set) and to use the [] indexing operator to retrieve the bit numbers in ascending order.