Preset Number Slider Value

Hey there,

is there a way to preset the value of a number slider node? I’m not talking about the min and max values. What I want is to preset several number sliders with values from a list, like the first number slider gets the first value of the list and so on.

hi
you cant do this by OOTB nodes inside dynamo, but instead you can use user interface " UI " based node . like the one on Data-Shape package ,

1 Like

Prior to opening the graph, yes.

This is what Generative Design and Dynamo Player do under the hood.

Conceptually you need to read the text of the graph to see what nodes are inputs, and then map those input nodes to the list, and set the values accordingly in the string before saving it. Then open the graph with Dynamo.

1 Like

Come to think of it, a view extension might be able to do this as well… might dig into this some in a few weeks if there is interest.

1 Like

Thanks for your fast reply, but the UI node from the DataShape package doesn’t solve my Problem, as my code needs the original number slider in order to keep the point which it is linked to draggable in the 3D view. When I create a number slider node the preset value is one, so it should be some how possible to set it to a new value.

This is probably not what you are looking for, so may just be a curiosity - but you can manually do this inside of the .DYN file :slight_smile:

In Dynamo:
image

Right-click on your .DYN file, and click Edit - You can use any text editor. It will bring up your .DYN. You will see a bunch of stuff in there, but also under the "Nodes": [ { } ]" JSON field you will find your Number sliders. When in doubt, search for NumberInputNode.

If you make changes here to the InputValue and save your changes to the .DYN file, it will show up in your graph next time you open it. Like so:

7 Likes

This is unfortunately not solving my problem. I need this number slider node, where I can preset its value with an input parameter. I looked for this node on the github page of dynamo and found this:

Here the link: Dynamo/DoubleSlider.cs at master · DynamoDS/Dynamo · GitHub

Shouldn’t it be possible to create a new version of this slider, where we assign “Value” to a input parameter, instead of “1” [Codelines 72 and 81]

It’s a pity that I am new to developing node with visual studio, so I appreciate any advices or ideas. Maybe I am blindfolded and its not possible to recreate or enhance existing nodes.

Unfortunately this is a little tricky due to the way that Dynamo is currently designed and built. Number sliders (And other nodes with no input port) are flagged for use in things such as Dynamo Player and Generative Design in Revit (Otherwise known as Refinery).

The reason this gets tricky is that all of these static inputs are pre-populated in these other applications so you see their defaults, and having something feed into them not only requires a code rewrite, but also presents issues with how this data is presented. In essence, you need to “Run the graph before you run the graph”. Not saying it’s impossible, but just a problem we’ve not yet addressed :slight_smile:

In the meantime, as Jacob mentioned above an Extension may do the trick.

2 Likes

Okay that are bad news for me :roll_eyes:, but still thank you for your fast reply and easy explanation.

What do you mean exactly with “Extension”, because I need the number slider to keep a Point.ByCoordinates movable in the z-axis by dragging it in the 3D view and I think with other number sliders it’s not possible to keep this effect.

1 Like

An “Extension” is like an Add-on for Revit if you are familiar with that. It’s a way for anyone (Our team, or other users both create them) to Extend Dynamo; basically creating new functionality or modifying existing functionality.

For example, @john_pierson has the Monocle View Extension that adds new annotative functionality to the workspace: Alignment icons in canvas, easy way to create groups, custom colour etc.

@Mostafa_El_Ayoubi has the DynaMaps View Extension that creates a connection to a series of resources (Open Street Maps, Topographical repositories etc.) to allow you to quickly and rather effortlessly bring in site context data to your Dynamo workspace; roads, buildings, trees etc.

In your case, you could create a View Extension (As per @jacob.small 's suggestion) to allow you to inject values into the out-of-the-box Number Sliders. This may allow you to get what you are looking for!

3 Likes

Can you give me some insight into what you’re after? Share a diagram, or a graph, or something else? Where are the slider values coming from? User input or read from another location?

It’s likely that there is a way to use a toggle to pass either the sliders as is or another data source (ie: data from a row in an excel file) based on a Boolean input. You could also use the number slider as a means of ‘tweaking’ the data from excel (default to 0), or bypass it entirely via Boolean… really the options are limitless, just a matter of intent.

1 Like

Okay sounds like even deeper dynamo developing. It is also described on the developer webpage (https://developer.dynamobim.org/), but I didn’t found it before. Otherwise I wouldn’t have asked, but your examples helped anyway. :+1:

@jacob.small

After all these informations I would really appreciate if you could spare some time for a view extension, that is capable of solving my issue. Of course I want to offer my help, eventhough I have just advanced knowledge of java, visual basic, c# and matlab.

Here a video of what I am working on:

I create a surface and pick specific points which I substitute with “handle points”. At the moment these points only inherit the x and y values from the points they are replacing and get their z-value from the number slider as with this they are movable in the 3D viewer. The problem resolving from this is that they have the wrong height.

Here my dynamo file. I marked the position where I would like to assign a default value to the number slider in red.

ReplacePointAtIndexWithHandlePoint.dyn (142.6 KB)

I might be able to begin to look into this over my weekend, but I don’t have any experience here either.
I’m also a bit confused as to what you’re after.
What part of the number slider do you want to set?
How often do you want to set it?
How you are you deciding what to set the value to?

1 Like

I marked the issue in red. I want to preset the current value of the number slider. That way the “handle point” would inherit not only the x and y value, but also the correct z-value and would still be draggable in the 3D view. Thats what I promise me of this.
So to answer your questions:

I want to set the current value as if I slided it to the desired value.

Once per slider.

I get the z-value from the point that is beeing replaced.

Why use a slider then?

Admittedly I have not read through the rest of this thread, so forgive me if I’m missing something that has been addressed already.

I just came to say that, depending on how you’re planning to use your “slider”, you could use a randomly generated index to select a value within the range of your top and bottom constraints.

Set the range on the number slider from -n to n, and set the value to 0.

Read the Z value of the point.

Add the number slider value to the Z value, returning the Z value by default but allowing you to adjust as desired.

1 Like

@jacob.small

Thats doesn’t work as then the point can’t be dragged in the 3D view, because the z-value input of the handle point is then not directly connected to a number slider. I can elevate the point with the slider, thats correct, but I want to drag it with my mouse in the 3D view, just like my video shows.

Because without it I can’t elevate these handle points with my mouse in the 3D view. Thats the property of point.bycoordinates. You can move it in any direction (x,y,z) if the matching input gets its value from a number slider. Otherwise you can’t move it with your mouse. At least I don’t know of any other opportunity.

You could set the slider range from -1 to 1 similar to @jacob.small’s suggestion but then scale the slider value by n.

Handlepoint

The number slider needs to be directly connected to the z-value input. When I do it like @jacob.small suggests it isn’t directly connected anymore.