[Closed] instance current selection
Hi im quite new at this max script…but we are doing a library of components and we are working in RTRE
so i have tried to write a script that brings in a light dome and then instances the component over to the light dome once the lighting is done deletes the instance component…
now i had this working for one object but i want to be able to have two or more objects selcted as well…but thats where im alittle stuck…
macroScript deleteinstance Category:"tools" toolTip:"delete instance"
(
delete $tempinstance*
)
macroScript makedome Category:"tools" toolTip:"Make Dome"
(
thecopypastedir = getdir #scripts
thecopypastefile = "\RTRE_LDOME.max"
thecopypastestring = thecopypastedir + thecopypastefile
mergemaxfile (thecopypastedir + thecopypastefile) #select
)
macroScript deletedome Category:"tools" toolTip:"delete Dome"
(
delete $EL*
)
macroScript align Category:"tools" toolTip:"align"
(
cs = getcurrentselection()
cscount = cs.count
for i = 1 to cscount do
(
newobject = instance selection[i]
newobject.name = "tempinstance"[i]
newobject.pos.x = $el_dome.pos.x
newobject.pos.y = $el_dome.pos.y
)
)
thanks for you help in advance
maybe because you use
“csamount” instead “sccount”
in line
for i = 1 to csamount do
Oh yes thanks for that…
so i tried but still doesnt seem to work…also now ive tried to make a dialog box instead of just buttons but now my delete doesnt work…
macroScript RTRE_lighting_dome Category:"tools" toolTip:"RTRE Lighting Dome"
(
rollout buttons "RTRE Lighting Utility" width:158 height:321
(
button make "Make L DOME" pos:[19,38] width:117 height:42
on make pressed do
(
thecopypastedir = getdir #scripts
thecopypastefile = "\RTRE_LDOME.max"
thecopypastestring = thecopypastedir + thecopypastefile
mergemaxfile (thecopypastedir + thecopypastefile) #select
)
button delete "Delete L DOME" pos:[19,95] width:117 height:42
on delete pressed do
(
delete $EL*
)
groupBox grp1 "LIGHTDOME" pos:[8,8] width:139 height:146
groupBox grp2 "OBJECT ALIGN" pos:[8,162] width:139 height:146
button align "Align" pos:[19,189] width:117 height:42
on align pressed do
(
cs = getcurrentselection()
cscount = cs.count
for i = 1 to cscount [size=2]do
[/size](
newobject = instance selection[i]
newobject.name = "tempinstance"[i]
[size=2]newobject.pos.x = $el_dome.pos.x
newobject.pos.y = $el_dome.pos.y
[/size])
)
on execute do
createDialog Buttons
)
use “cs[i]” instead “selection[i]” in line
newobject = instance selection[i]
Oh cheers for that…something so simple right under your nose…
ok im getting an error now but im just not sure what it means
>> MAXScript Rollout Handler Exception: – Type error: Call needs function or class, got: ButtonControl:delete <<
and that relates to the code below…i had this working when it was in its own little maxscript but when its been put in the rollout its stopped working
on align pressed do
(
cs = getcurrentselection()
cscount = cs.count
for i = 1 to cscount do
(
newobject = instance cs[i]
newobject.name = "tempinstance"
newobject.pos.x = $el_dome.pos.x
newobject.pos.y = $el_dome.pos.y
)
)
on d_instance pressed do
(
delete $tempinstance*
)
Hi,
this error is beacause you are using a reserved Keyword for the button name: delete
change to:
button del “Delete L DOME” pos:[19,95] width:117 height:42
on del pressed do
(
delete $EL*
)
Hi thanks for that…
Ive now added a spinner and a checkbox…but the code isnt evaluating now… ive been looking at other code “E-Light.ms” as reference and i cant spot the porblem
Ive not put any commands into the spinner or checkbox yet
macroScript RTRE_lighting_dome Category:"Juice tools" toolTip:"RTRE Lighting Dome 3"
(
rollout buttons "RTRE Lighting Utility" width:158 height:407
(
group "Light"
(
checkbox chk1 "Checkbox" pos:[17,331] align:#right width:126 height:20
spinner spn1 "Multiplyer" type:#float fieldwidth:200 pos:[27,361] width:115 height:16
)
Group "LIGHTDOME"
(
button make "Make L DOME" pos:[19,38] width:117 height:42
button del "Delete L DOME" pos:[19,95] width:117 height:42
)
Group "OBJECT ALIGN"
(
button align "Align" pos:[19,189] width:117 height:42
button d_instance "Delete" pos:[19,244] width:117 height:42
)
on make pressed do
(
thecopypastedir = getdir #scripts
thecopypastefile = "\RTRE_LDOME.max"
thecopypastestring = thecopypastedir + thecopypastefile
mergemaxfile (thecopypastedir + thecopypastefile) #select
UtilityPanel.OpenUtility RTRE
max tool zoomextents
)
on del pressed do
(
delete $EL*
)
on align pressed do
(
IF $EL_dome != undefined then
(
cs = getcurrentselection()
cscount = cs.count
UtilityPanel.OpenUtility
for i = 1 to cscount do
(
newobject = instance cs[i]
newobject.name = "tempinstance"
newobject.pos.x = $el_dome.pos.x
newobject.pos.y = $el_dome.pos.y
select $tempinstance*
)
)
else messagebox "Create Light Dome First !"
)
on d_instance pressed do
(
select $tempinstance*
max delete
)
on chkl pressed do
(
)
on spnl pressed do
(
)
)
execute do
createDialog Buttons
)