ScriptSpot

Forum topic · General Scripting

Visual Maxscript and Attibute Editor

By klemt · 2012-09-20

Description

Hi all.

I have a problem beacause I'm not a pro in scripting and I need to create a little windows dialog in the Visual MAXScript. In this windows I have a slider and I must to connect this slider with an attribute holder wich control a dummy by a wire parameter. I'm not sure if I'm very clear ^^
So I made a little script but there is a problem and I don't know how to do.
If somebody can help me it will be really fantastic! :)
Thanks!

Here is my wonderfull script:
.
.
.
.

rollout unnamedRollout "Untitled" width:162 height:300
(
slider sld1 "Slider" pos:[8,8] width:141 height:44
on sld1 changed val do
$Circle005.modifiers[#Attribute_Holder].Custom_Attributes.Pied_Milieu = val
)
createdialog unnamedRollout

Comments (15)

klemt · 2012-09-21

It's really really cool of you!!! Thank you very much Barigazy for all your work!
It's perfect :)

I will send to you a picture when the project will be finish.
Have a nive day!
Thank you again!

Klemt

klemt · 2012-09-21

Ok I will send to you all files ^^
Can you have your mail plz?

Really thank for all!

Pied Script

barigazy · 2012-09-21

Hi klamt,
i finish your tool. See how to use it.
By the way, i don't speak french by i try
to make french version.Give me some credit for that :)

And this is your script

Attachments

barigazy · 2012-09-21

If you create manually controls for the Atribute_holder modifier then this is normal behavior, but if you not then look the line in my CA definition *on spn1 change val do ...*
how to connect modifier slider with rollout slider.
If you not understand this, send me a mail with a *.max file and *.ms for the rollout and if you have *.ms for the CA.

Another question: when I

klemt · 2012-09-21

Another question:
I use the first script with "Pied milieu".
So, when I activate "Auto Key" and I activate the slider, it created key on the timeline so it's perfect. But the sliders in the windows "Untitled" don't move when I move the timeline. How to link sliders to the timeline so that when I move the timeline, sliders moves too?

barigazy · 2012-09-21

Whitch slider, again post screenshot

klemt · 2012-09-21

Yeah! It's perfect!
Thank you very much barigazy! :)

Klemt

barigazy · 2012-09-21

My pleasure :)

script

barigazy · 2012-09-20

Then use this script.
NOTE:As you see i have linked rollout slider with CA slider in
both way.


global testRollout
try (destroyDIalog testRollout) catch()
rollout testRollout "Untitled" width:162 height:300
(
	local ctrlObj
	fn filt obj = (obj.modifiers.count > 0 and (for m in obj.modifiers where m.name == "TestMod" collect m).count == 1)
	slider sld1 "PositionZ:" pos:[5,5] width:140 height:44 range:[0,100,0] 
	pickbutton pb_node "Pick Object" width:140 height:18 filter:filt
	on pb_node picked obj do
	(
		if obj != undefined do
		(
			ctrlObj = obj
			pb_node.text = obj.name
			sld1.controller = ctrlObj.TestMod.testAtt.posZ.track
		)
	)
	on sld1 changed val do
	(
		if ctrlObj != undefined do ctrlObj.TestMod.testAtt.posZ = val
	)
)
createdialog testRollout 150 85

edit (second solution with example)

barigazy · 2012-09-20

Ok.First, you need to execute this code for the scene creations.


	delete objects
	ca = attributes testAtt
	(
		parameters params rollout:params
		(
			posZ type:#float ui:ui_spin default:0.0 
		)
		rollout params "Parameters"
		(
			slider ui_spin "PositionZ: " fieldwidth:54 type:#integer range:[0,100,0]
			on ui_spin changed val do
			(
				if testRollout != undefined and testRollout.open == true and testRollout.controls[2].text != "Pick Object" do
				(
					testRollout.controls[1].value = val
				)
			)
		)
	)
	
	objModd = EmptyModifier name:"TestMod"
	circShape = circle radius:10
	sphObj = Sphere radius:10 pos:[100,0,0]
	custAttributes.add objModd ca
	addmodifier circShape objModd
	max modify mode
	paramWire.connect circShape.modifiers[#TestMod].testAtt[#posz] sphObj.pos.controller[#Z_Position] "posz"

klemt · 2012-09-20

Sorry for my poor english ^^
So, to simplify my request, I made a new scene with a sphere and a circle.

http://postimage.org/image/qejet8rpj/full/

The circle (Arc001) have an attribute holder. The spinner "Param1" control the sphere on Z Rotation.

How to connect the attribute "Param1" to "Slider"?
I hope it's more simple and clear ^^
Cordially,
Klemt

barigazy · 2012-09-20

If you already make wire connection then this will help you

rollout unnamedRollout "Untitled" width:162 height:300
(
local ctrlObj
fn filterObj obj = isProperty obj "Attribute_Holder" and isProperty obj.Attribute_Holder.Custom_Attributes "Pied_Milieu"

slider sld1 "Slider" pos:[5,5] width:140 height:44 range:[0,100,0]
pickbutton pb_node "Pick Object" width:140 height:18 filter:filterObj
on pb_node picked obj do
(
if obj != undefined do
(
ctrlObj = obj
pb_node.text = obj.name
sld1.controller = ctrlObj.Attribute_Holder.Custom_Attributes.Pied_Milieu.track
)
)
on sld1 changed val do
(
if ctrlObj != undefined do ctrlObj.Attribute_Holder.Custom_Attributes.Pied_Milieu = val
)
)
createdialog unnamedRollout 150 85

barigazy · 2012-09-20

You are not clear.Post a screenshot, to see whats do you need connect whit what