ScriptSpot

Forum topic · General Scripting

spinner control scale by axis

By SugaR · 2013-02-04

Description

Hi everyone,

I'm beginning on maxscript and I currently have an issue.
I'd like to control an object's scale x, y and z independently with 3 spinners. I also need the feeback on the spinners if I scale the object

I already can control the position or the rotation like this:

"
x_Controller = Bezier_float(); y_Controller = Bezier_float(); z_Controller = Bezier_float()

--assign controller to spinners
dialogtest.spinnerA.controller = x_Controller; dialogtest.spinnerB.controller = y_Controller; dialogtest.spinnerC.controller = z_Controller

-- position control:
$.pos.X_Position.controller = x_Controller; $.pos.Y_Position.controller = y_Controller; $.pos.Z_Position.controller = z_Controller

--rotation control:
$.rotation.X_Rotation.controller = x_Controller; $.rotation.Y_Rotation.controller = y_Controller; $.rotation.Z_Rotation.controller = z_Controller
"

But I didn't succeed to do the same for the scale. I can easily control the scale with spinners like this:

"
on SpinnerA changed arg_x do $.scale.x = (arg_x)
on SpinnerB changed arg_y do $.scale.x = (arg_y)
on SpinnerC changed arg_z do $.scale.x = (arg_z)
"

but this way I don't have the feedback on the spinners if I directly scale the object ...

So after hours of google search, I'm tired and I need help please

Comments (10)

teresa · 2013-02-19

I experienced using the same code before and it really works. I'm familiar with different programming codes because I experienced making programs before. Programming is quite difficult and challenging but it's just need patience.-bio-oil

Thank you for your post, it gives me a big help for my project reference.

chia frø

barigazy · 2013-02-04

U can assigne "ScaleXYZ" controller to selection.

b1 = box()
b1.scale.controller = ScaleXYZ ()
sc = b1.scale.controller = ScaleXYZ ()
sc.value.x
sc.value.y
sc.value.z
b2 = box pos:[100,100,100]
m = b2.scale.controller
m.value.x = 2
m.value.y = 2
m.value.z = 2

I don't understand

SugaR · 2013-02-04

Hi Barigazy

Thanks for your answer :)

Actually I don't understand how i'm supposed to use this with a spinner.

The thing is that I really need to control the scale with the 3 spinners in real time (with the upbutton, downbutton or when a value is set directly in the spinner manualy) but I also need the reverse fonction in real time.
I mean when I scale the selected object in the viewport with the scale tool, I want the spinners update their value in real time too.

Hope you understand what I'm searching for.

gift from me ;)

Anubis · 2013-02-05

rollout dlgScaler "Scale Control"
(
	local asp = #()
	
	spinner spnX "X:" range:[-1000,1000,100]
	spinner spnY "Y:" range:[-1000,1000,100]
	spinner spnZ "Z:" range:[-1000,1000,100]
	pickbutton pbNode "Pick Object" autoDisplay:true
	
	on pbNode picked obj do if isValidNode obj do
	(
		if classOf obj.scale.track != ScaleXYZ do
			obj.scale.track = ScaleXYZ()
		local asc = getXYZControllers obj.scale.track
		asp = #(spnX, spnY, spnZ)
		for i = 1 to 3 do asp[i].controller = asc[i]
	)
	on pbNode rightclick do
	(
		pbNode.object = undefined
		pbNode.caption = "Pick Object"
		if asp.count == 3 do
			for i = 1 to 3 do asp[i].controller = undefined
		free asp
	)
)
CreateDialog dlgScaler

well... even attaching a bit improved version (.ms file), cheers!

Attachments

Thanks a lot

SugaR · 2013-02-06

Hi Anubis

Thanks a lot for this, it's (almost) perfect !

Almost because i'd like to display the scale value in spinners as a percentage, like the transform type-in dialog (F12).

But hey, since it works, it's really not a big problem if I can't do this.

Again thank you

LOL

Anubis · 2013-02-06

The TTI(F12) is just a tool NOT binded to selected or other object.

What you can do though, for the 2nd goal, is to add another set of 3 controls (spinners or labels), which to serve as display only, and in them to display measured percent value. But I'll leave this as exercise (homework) for you.

Cheers!

Hi AnubisAgain, thanks for

SugaR · 2013-02-07

Hi Anubis

Again, thanks for the help.
Still, I really want to set and get the object scale with a percentage in associated spinners.

Like that I get more precision on the scale (I'm often doing really tiny scale on objects at my job, so it's easier when manipulating a percentage).

Since I'm doing this tool to help me working faster, the actual way don't help me...

Hope i'm not bothering you :)

spinnerPrecision vs measured-percent ;)

Anubis · 2013-02-08

preferences.spinnerPrecision

is what you need then (quote from mxs-help: This integer value defines the number of decimal digits displayed by spinners.) or open Customize > Preferences > General and set the value there.

Adjust also the #scale property of Rollout Spinner control (which is 0.1 for Floats by defaults).

Works now

SugaR · 2014-05-17

Hi, it's been a while since this but finally find a solution to what I did want to do exactly.
So two parts for the code:


-- spinner with % value controling the selection scale
on spn_scaleX changed arg do $.scale.x = arg / 100
on spn_scaleY changed arg do $.scale.y = arg / 100
on spn_scaleZ changed arg do $.scale.z = arg / 100

-- selection scale controling the spinner value as %
when transform $ changes id: #test do 
(
	testRoll.spn_scaleX.value = $.scale.x * 100
	testRoll.spn_scaleY.value = $.scale.y * 100
	testRoll.spn_scaleZ.value = $.scale.z * 100
		
)

So that way it's working nicely

Thanks, it works but on " object level"

crystal3d · 2017-11-24

so i could not scale the selected vertices of that object, dont know it if is possible though...