Your goal and the presented code aren&#39;t clear to me. The consequence (after then) contains calls to static/class methods (Box.setX()) which isn&#39;t going to change anything in your fact object. The call b.setX() might change your object, but this depends on what the class method Box.getX() returns.<br>
<br>Assuming Drools 5, a typical consequence would look like<br>   b: Box(...)<br>then<br>   modify( b ){<br>      setX( ... )<br>   }<br>end<br><br>-W<br><br><div class="gmail_quote">On Sat, Aug 8, 2009 at 1:48 AM, sonia <span dir="ltr">&lt;<a href="mailto:robotnic%2Bdrools@gmail.com">robotnic+drools@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello<br>
<br>
I want to achieve this:<br>
box1.setX(0)<br>
box2.setX(box1.size());<br>
box2.setX(box1.size + box2.size)<br>
...<br>
<br>
I want to do it with rules, and would like to know what&#39;s the best<br>
method of initializing (or any other operation with varying data) a<br>
group of objects<br>
<br>
rule &quot;init box&quot;<br>
 when<br>
   b : Box( x == -1)<br>
 then<br>
   b.setX(Box.getX());<br>
   Box.setX( Box.getX() + b.size);<br>
end<br>
<br>
This does not work.<br>
A single box object is matched several times instead of different box objects.<br>
What is happening? how come a single box object is matched several<br>
times? Why doesnt drools choose other instances of box?<br>
<br>
What do I need to do to initialize all boxes, once for every box?<br>
<br>
Thank you.<br>
<font color="#888888"><br>
--<br>
robosonia<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>