[Closed] Help with a solution for small script
Hi all ,
Im having a crack at maxscript to try and speed up a project, would really appreciate some direction. Im no programmer but just getting an idea of how to tackle this problem.
I need to create a bunch of characters from a few similar elements, this was to help speed up the process.
So basically I am trying to create two buttons, these are navigation buttons that perform functions but stop at a point.
For example imagine 3 circles O O O with constant names. So say I click the > arrow, it moves to the next circle, hides it
Select $circle2
Then when I click > again it moves to $cirlce 3 but stops there. Accordingly clicking back < button brings the selection back to previous circle select $circle 2 and then $circle 1 when clicked again.
I am thinking using something with a counter that +1s everytime the button clicks, but am not sure how to stop it at the 3rd circle while also performing an action?
e.g
For I =3 Do
If Selection=$Circle3 Then
Hide $Circle2
Hide $Circle1
Am I going about this the right way or what are some other solutions?
Also something that is frustrating the heck out of me is the Visual maxscript editor, I create it save it run the script but my window doesnt come up! :banghead:
Any help appreciated.
Thanks
For the first part that is probably how I would go about it…
Visual maxscript can be a little tricky. Most people stay away from it… though I do use it from time to time when I am creating a large interface and I want to experiment with how it will look/flow.
-
Make sure you are “saving as” from the visual maxscript as a .ms or .mcr.
-
And you will want to add a CreateDialog followed by the RolloutName at the end of the script.
i.e.
rollout unnamedRollout “Untitled” width:162 height:300
(
button btn1 “Button” pos:[22,17] width:57 height:33
)
CreateDialog unnamedRollout – <– THIS IS WHAT YOU NEED TO ADD!
Never used visual max script before, i tend to just write it all myself.
This is how i would go about it. Make sure to check the objects exist in the scene. If true then carry on. I have it selecting each object, but you can have it doing anything you want.
(
try(destroydialog cirlce_mover)catch()
start_value = 1
-- A function to check if objects in scene exist
fn check_objects fn_check_objects_array =
(
local check_objects_array=fn_check_objects_array
true_false = undefined
for i = 1 to fn_check_objects_array.count do
(
if (getnodebyname fn_check_objects_array[i]) != undefined then(
format "% Does Exist
" fn_check_objects_array[i] -- prints circles that exist
if fn_check_objects_array.count == i do true_false = true
)else(
format "% Does Not Exist
" fn_check_objects_array[i] -- prints circles that don't exist
true_false = false)
)
return #(true_false, fn_check_objects_array)
)
rollout cirlce_mover "Circle Mover"
(
button b_forward ">" width:30 height:20 across:2
button b_back "<" width:30 height:20
on b_forward pressed do
(
fn_circles = check_objects(#("Circle001","Circle002","Circle003"))
if fn_circles[1] == true do
(
if start_value >= 3 then
(
start_value = 3
print "3 is the limit"
)
else
(
start_value += 1
print start_value
)
select (getnodebyname fn_circles[2][start_value])
)
)
on b_back pressed do
(
fn_circles = check_objects(#("Circle001","Circle002","Circle003"))
if fn_circles[1] == true do
(
if start_value <= 1 then
(
start_value = 1
print "1 is the lowest"
)
else
(
start_value -= 1
print start_value
)
select (getnodebyname fn_circles[2][start_value])
)
)
)
createdialog cirlce_mover 200 100
)
Thanks guys,
I figured it out, but not by way of function, so this is handy too as I can relate to its practicallity!
Much appreciated, yeah I am finding not many people liking the visual tool builder!
Thanks
i tell you the truth. only developers of the visual mxs can potentially like it… but it’s not likely either.
It is just so shitty it takes longer to use it then to build it yourself.
Lol THAT bad! haha…love the comment about the developers…
Hmm may I be so bold as to ask one of you gus for an example rollout
With buttons alligned left centre and middle…
OH and while I’m making my christmas list how about a slider between 1 – 100 and a button that gives a random value to the slider as well…
try(destroydialog test_rol) catch()
rollout test_rol "" width:220
(
button left_bt "Left" width:60 align:#left across:3
button center_bt "Center" width:60 align:#center
button right_bt "Right" width:60 align:#right
slider sl range:[0,100,0] width:120 across:2
button random_bt "Random" width:60 align:#right offset:[-2,10]
on random_bt pressed do sl.value = random 0 100
)
createdialog test_rol
or
try(destroydialog test_rol) catch()
rollout test_rol "" width:220
(
button left_bt "Left" width:60 align:#left
button center_bt "Center" width:60 align:#center
button right_bt "Right" width:60 align:#right
slider sl range:[0,100,0] width:120 across:2
button random_bt "Random" width:60 align:#right offset:[0,10]
on random_bt pressed do sl.value = random 0 100
)
createdialog test_rol
if you want to have your controls be perfectly aligned don’t trust to control’s default alignment.
always use align: and offset: arguments.
here is a sample why you shouldn’t trust
(the default button’s alignment is “center”)
try(destroydialog test_rol) catch()
rollout test_rol "" width:220
(
button center_bt1 "Center" width:60
button center_bt2 "Center" width:60 align:#center
)
createdialog test_rol
personally i trust to only #left and #right alignment, and don’t trust to “center”
check:
try(destroydialog test_rol) catch()
rollout test_rol "" width:100
(
label center_bt1 "Center" width:60
label center_bt2 "Center" width:60 align:#center offset:[0,-6]
)
createdialog test_rol
you can see that labels are not centered at all.