Dimension checker

Hello everyone,
I’m trying to create a script that acts like a dimensions checker, using Python. I inserted picture below of what I have written in Python, when I run the script, the run is completed without warnings, but it doesn’t tell me if my dimensions are wrong or not. Could it be that I wrote it wrong in Python?
BR

Hi @yasm0382

can you include a picture of the whole dynamo script with inputs and output.

-biboy

1 Like

Hi @blsalvio
image
This is the script :sweat_smile:

There is only one output port on the Python node in the Dynamo environment. The values this produces are defined as the OUT variable. You can only define this as a value or list once, with anybody additional definitions overwriting the previous value.

Look closely at what I believe are lines 30 and 34 (the last and fourth from last in your code).

2 Likes

hi @yasm0382

like @JacobSmall said, delete all the lines below OUT = values

-biboy

1 Like

Hi @blsalvio and @JacobSmall
I did that, but I still get a warning. It seems like line 15 is the problem.
image

The key to understanding that warning is in the word iteration. Imagine going to the grocery store with a list of stuff to buy. When you get there you hand a worker the list, and they would go item by item through the store and grab what was written and put it in your basket. That repeated action based on the contents of the list is iteration - the action could be anything else, but the key is perform action sequence based on a list of variables. The worker is iterating over the list.

But what if you didn’t have a list and instead just needed to buy a soda? You walk in without the list, and the worker asks for the list and you just say ‘I need a soda please.’ A being with average intelligence who is capable of original thought would think ‘well this is a problem, I need a list but am only getting a request for a soda, I guess I’ll just get that.’ However, computers both dumb and are not capable of unique thought. As such they simply say ‘you didn’t give me a list, so I am closing the shop.’

To prevent this, you need to ensure you are passing a list instead of saying ‘I’ll have a soda.’ There are several ways to do this, but

You can do this in Dynamo by adding a List.Create and a List.Flatten node before the Python input. Or you can do this in Python by asking if the data in the variable ‘dimensions’ does not have a property ‘iter’, and changing the variable contents to be equal to the previous value in a list (this is two lines, the first of which is an if statement). There are also a few custom nodes for this, including one in the Clockwork package.

Give it a shot and see if that fixes things for you.

2 Likes

hi @yasm0382,

I just tried your script and it seems no problem with me. But I have one comment on your python code. Why is it you are iterating through dimensions but you are not using anything related to dimensions. Also even though you are iterating, x and y values are not changing so the values of r1, r2, r3 and formula also will not change.

Please check the logic of your python script first.

-biboy

1 Like