Set a value in code block as input

Hi All,
In order to use my script in dynamo player I should define a computed value in a code block as input in another python script which is the result of subtraction of two other inputs…so how can I do that pls?

Thanks.

Maybe temp. store the value in a .csv file?

1 Like

@Marcel_Rijsmus

You mean by using Excel and store this value in .csv file; then by using file path to set it as input?
Can you show me an example how to proceed?
Thanks.

you don’t need excel to create a csv file.
It’s just a .txt in disguise :slight_smile:

@Marcel_Rijsmus

I should use ExportSCV node? then how to reinsert it in my script? by using ImportSCV node?..but I dont see set as input under ImportSCV node??

Thanks.

It’s csv for comma separated value
and use the file path node as input for the player

@Marcel_Rijsmus

Excuse me …I’m not sure what I’m doing!! I dont understand well what I should do…I got my value divide in two values??

Should I export then import from csv or what?

Thanks.

your value has decimals in it, which are separated by the comma delimiter, so the csv file is not read correctly.
Maybe you can replace them by another character like 3|4 (pipe) or use excel, or use the read text (file) node.

@Marcel_Rijsmus

I should in first export to csv then import from csv with the same file path or I’m wrong?

Thanks.

@christian.stan

Any idea?

Thanks.

@Marcel_Rijsmus
I don’t know if I found the right approach

In this case my value is set as an input in dynamo player ?

Thanks.

1 Like

I think the file path node is better for input in the player.
(in case you have more than 1 value stored )
the graph seems ok to me

I’m a bit confused here. You have value 1 (exterior shaft) and value 2 (shaft thickness) which are number sliders and can be inputs for player.

What value are you looking to use as the other input? If it’s The differences between the two, don’t make a 3rd input; just let the Python node do the subtraction.

@jacob.small

I know that you may be confused if you dont understand what I have to do !!

I divided my elevated water Tank into three parts (Foundation, Shaft and Tank ) to be able to class each element separately as a family in REVIT (I dont want my Tank to be a single piece)…so for some inputs I should extract values from another element
In this case I want to compute Shaft interior radius (from the element Shaft) which I need to size my Tank

Thanks.

Makese sense.

In this case, no input is needed. Assuming you have ShaftExteriorRaidus and ShaftWallThicness as variables in Python (ie: input 1 and input 2), then the next line of the code can define the interior radius: ShaftInteriorRadius = ShaftExteriorRadius - ShaftWallThickness

If that’s not clear it might help to post the dyn or a sample reproducible case thereof.

Hello, Why not create 3 separate groups with the possibility of interaction between each group
rather than 3 scripts

We are not limited (I think, never asked myself the question actually) in block size
Cordially
christian.stan

@jacob.small

I know that the interior radius can be defined in the next line in python (I defined it in the script which I named Shaft_Profil… see the image below) …but I need to use this value again as input in the next script which I named Tank_Profil…I know that I can define it another time but I wanted to extract the value directly from the first script and it seems to me that it’s an extra work
In a other case I need Shaft total Height which I named H_Total_Shaft and which is generated from the Shaft elemental height and level numbers to be used as input in Tank_Profil script…so do I have to define it again in the Tank_Profil script??..it seems like repeated work

Thanks.

A few options here:

  1. Instead of passing along one object at a time, create a dictionary and put the needed (or possibly needed) data into the dictionary. Each Python node then just has a single entity in it (ie: designDictionary), from which you can pull whatever information you need (ie: designDictionary["ShaftInteriorRadius"]). This would be my preference; in fact I use this method in pretty much every project I undertake lately, as it has several benefits beyond keeping your data organized and accessible.
  2. Output a list of all necessary items into the Dynamo environment, and pull the list of data into the next graph. This works and is the easiest structure method to build up front; however it requires keeping track of what data is at which index, and the reliance on order means it is prone to breaking as you update your code.
  3. Calculate the value prior to the input into the python node, and feed that into each subsequent Python node. This is the easiest up front - you already had it in fact.

In all cases you would not want another input, as the user could put in a value which breaks the automation (ie: if the interior radius was set to 10 units, and the exterior radius was set to 1 unit, the resulting polycurve would likely be invalid as a profile for a revolve/sweep/extrusion).

1 Like

@jacob.small

Thanks a lot Jacob for your ideas and guidelines

First off all I have not yet reached an advanced level in python which facilitates to me the management and organization of my datas
secondly, as that is my first full project in python and it’s took me a lot of time, I was disorganized and I didn’t pay attention that I can output in my list the items wich I can use them later

Finally the idea to create dictionary from which I can pull informations I need is perfect…Can you if it’s possible give me a small exemple for that?
Thanks.

Everyone start’s somewhere - you’re in a good spot now. :slight_smile:

Even though I do this often, I rarely start there. Don’t get discouraged by ‘not being in the file state already’. My process is usually something like this, though every project and person is different:

  1. Draw my roadmap showing the steps I have to take
  2. Build a POC via Nodes / DesignScript / Python
  3. Fine tune the organization / structure / workflow
  4. Optimize the inputs and workflow UX

Sounds like you’re past step 2 and into step 3 and 4; Good place to be!

As for an example… This should get you started:

1 Like