In the code below, I am trying to move an element by a user defined amount. It is moving the item but it seems to be doubling the distance. instead of moving the element 550mm it is moving it 1100mm, can anyone tell me why?? I cant see the reason here…
I haven’t uploaded the family file, but the point of the script is to place plinths underneath a tank, and have the tank move up by the same value as the height of the plinths.
Thank you!
You are right, it is a face based element and I do not have the parameter to adjust it’s offset by default.
However, the element is moving when the script executes… Just not by the correct amount?
Have you gone to the view and moved it manually to see what it does? I am assuming it’s at the level to begin with and not already elevated from the Offset From Level parameter?
This item does not have any way of inputting an elevation. So there is no “Offset” or “Offset from Level” or “Reference Level” or anything like that. It is a generic model which has been constructed using a repeater.
It is sitting level with L0 at the moment yes, no pre-existing offset. I can manually move it up and down no problem using the move command. This is why I am using the MoveElement method from the API, I thought it would accomplish the same task as the move command.
It appears to be working fine for me. What is the Plinth made from? Is it a floor, or another family? Just wondering if something is moving the reference to the plinth and therefore doubling the offset.
I’m guessing its caused by your python node being called twice by Dynamo’s VM, so your element gets translated twice. Its most likely your plinthHeight; it updates after the element is translated and expires your graph so Dynamo’s VM re-executes your graph again. I would expect it to get into a never-ending loop if this is the case? …so maybe Dynamo’s VM has something which handles possible recursive results which terminates subsequent re-evaluation. One way to check is hard code your value temporarily and even get the element temporarily using its hard coded ID in your python script so you are completely divorced from Dynamos VM until you get to a point where its working consistently, then re-insert your inputs to isolate the cause of the problem.
@SeanP it does work when I hard code it, which is how I had it originally, then it needed to be user defined so I started to accept an input which is when things started going a bit south. Thank you for this suggestion though, that really helped.
@Thomas_Mahon, I did not even think of this… Thank you, I will make some adjustments and come back with (Hopefully) a working result.
Thank you for all the suggestions!
Transaction.End and Transaction.Start nodes may be something to look at if you modifying the plinth in the same run. Extract the height after the Transaction.End to use for the Offset to avoid the doubling up.