Notifications
Clear all

[Closed] when spinner value changed

hiiii
Please help me!!!
I am working in maxscript. I created a spinner as:
spinner val “Value” type: #float range:[0, 100, 0]
and a button as:
button btn_1 “start”
and created a cylinder
now i want that when start button is pressed and when value changed in spinner the length of the cylinder also changes accordingly but when start button is not pressed and by changing the value in spinner there will be no any change in cylinder length. Now, please tell me what will be my code.
And, also i want to generate a custom graph according to some value in x-axis and some value in y-axis. In starting the graph is linear upto some value and after that it is curve. I have the equation of both linear and curve and want to plot the curve according to equation in maxscript. How to do this?

5 Replies

For your first question, I can see two approaches:

Disable the spinner at the start, so the user can’t use it. Enable it when the Start-button is pressed. You can use the Start-button to toggle this behaviour, like this:

on btn_1 pressed do
(
	val.enabled = not val.enabled
)
on val changed newValue do
(
	-- your cylinder changing stuff here, like
	cylinder.height = newValue
)

On the spinner event, check if the Start-Button was pressed before.

local started = false

on val changed newValue do
(
	if (started) then
	(
		-- your cylinder changing stuff here, like
		cylinder.height = newValue
	)
)

on btn_1 pressed do
(
	started = true
)

I prefer the first approach, so you avoid a (rather useless) variable.

You should change the name of your spinner, because “val” can be confusing as the script grows.

Thank you for your reply and nice guidance. now, one problem is still remaining that i have also quoted in my thread that how to plot a graph in 3ds max. Suppose i have some value on x-axis and some value that i have to take in y-axis . Now, how i can plot the graph by using maxscript command…It is a great favor if you reply

Hello,
well the truth is I have no idea how graphs work. I don’t use 3ds Studio Max, I just make some scripts with Maxscript.

How do you draw graphs? Is there a tutorial? If so, you can use it to solve your problem.

Is your problem the maths? A graph can be described by a formula. If you have the formula, you can write it in maxscript.

Please describe your problem more exactly.

Hiiii!
Actually, there is no any tutorial for drawing graph. And, you are right my problem is mathematical one. And, the graph is discontinuous graph but this doesn’t be the problem. and, i have the equation too, but i don’t know how to draw it. According to me max is capable of drawing the graph as it is used for game development, so it might be capable. But, i am not getting an idea that how to do this. And, there is no need that if i provide the equations to you as the equations are non-linear and you feels problems in understanding it. So, you just assume one part of the equation as linear one like y = mx+c (take arbitrary value or arbitrary equations as per your comfort) and after travelling some distance on x & y- axis the graph changes to quadratic equation (a+bx+cx^2=0). Now, please help me to find out. take any arbitrary graph also if you don’t want to mesh up with the above such as sin graph, tan graph. But, whatever you take, it is simple one & also provide me the equations you are using, so that i can understand. O.k Thank you.

Ok let’s see if I understood you.

[…]and after travelling some distance on x & y- axis the graph changes to[…]

If you hace a threshold value like x = 3, than just do something like:

if ( x < 3 ) then
(
	y = m*x + n
)
else
(
	y = a + b*x + c*x*x
)

And then use the given x-value and the calculated y-value to draw graphs.

…or maybe you are referring to the graphs for the animation? If so, then I cannot help you.