Hi gazybara, thank you for your help, i have change a little of this code to avoid the error i get when i ‘Evaluate All’ in maxscript editor. now it work behave like previous( I still don’t understand after changing a lot of code just for get the same behave as previous?? confuse again???)
Since this code is work like what i expected,(it will apply the camera setting to selected camera, and it will pop up a warning message if i didn’t select anything.).
on btn1 pressed do
(
if selection.count != 0 then
(
for i = 1 to selection.count where isKindOf (vrcam = selection[i]) VrayPhysicalCamera do
(
vrcam.f_number = 8
vrcam.shutter_speed = 60
vrcam.ISO = 100
vrcam.vignetting = off
vrcam.whiteBalance_preset = 1
)
)
else
(
messagebox "Please select a VrayPhysicalCamera to proceed." title:"VrayPhysicalCamera"
)
)
so for btn2, i just do like below:
on btn1 pressed do
(
if selection.count != 0 then
(
for i = 1 to selection.count where isKindOf (vrcam = selection[i]) VrayPhysicalCamera do
(
vrcam.f_number = 8
vrcam.shutter_speed = 60
vrcam.ISO = 100
vrcam.vignetting = off
vrcam.whiteBalance_preset = 1
)
)
else
(
messagebox "Please select a VrayPhysicalCamera to proceed." title:"VrayPhysicalCamera"
)
)
on btn2 pressed do
(
if selection.count != 0 then
(
for i = 1 to selection.count where isKindOf (vrcam = selection[i]) VrayPhysicalCamera do
(
vrcam.f_number = 8
vrcam.shutter_speed = 400
vrcam.ISO = 400
vrcam.vignetting = on
vrcam.whiteBalance_preset = 1
)
)
else
(
messagebox "Please select a VrayPhysicalCamera to proceed." title:"VrayPhysicalCamera"
)
)
or is there any other way to do the same thing?
i think it will change the camera value according to the script
sorry for throw too many question in here, i am still a newbie.
Is my script simplifly completed? shall i share the script to others? will i script crush other’s user max file?
ok boss, i will try, where can find tips? maxscript help file?(i hope i can complete it as a beginner)
i copy and paste your code into the maxscript editor and evaluate it, i get error
findVrayPhysicalCameras()
-- Error occurred in anonymous codeblock; filename: ; position: 185; line: 7
-- Compile error: no local declarations at top level: preset1
-- In line: local preset1 =
may be my rollout code is something wrong because i get the below error after apply it
the rollout:
try (closeRolloutFloater MainFloater) catch()
rollout test "test"
(
button btn1 "test"
fn findVrayPhysicalCameras selected:off =
(
cams = getclassinstances VrayPhysicalCamera
if selected do cams = for c in cams where c.isselected collect c
cams
)
local preset1 =
#(
#(#f_number, 8),
#(#shutter_speed, 60),
#(#ISO, 100),
#(#vignetting, off),
#(#whiteBalance_preset, 1),
#(#whiteBalance_preset, 4)
)
on btn1 pressed do undo "Change Vray Physical Cameras" on
(
all_cameras = keyboard.controlpressed
cams = findVrayPhysicalCameras selected:(not all_cameras)
if cams.count > 0 do
(
for p in preset1 do setproperty cams p[1] p[2]
)
)
)
MainFloater = NewRolloutFloater "test" 250 400
addrollout test MainFloater
the error:
>> MAXScript Rollout Handler Exception:
-- Unknown property: "isSelected" in VRayPhysicalCamera <<
i copy and paste the error message in google search, it show nothing
try(destroydialog test) catch()
rollout test "test" width:200
(
button change_bt "Change VRay Cameras" width:190 align:#left offset:[-8,0] \
tooltip:"Change VRay selected cameras settints
+ Ctrl - All"
fn findVrayPhysicalCameras selected:off =
(
if iskindof VrayPhysicalCamera node then
(
cams = getclassinstances VrayPhysicalCamera
if selected do cams = for c in cams where c.isselected collect c
cams
)
else #()
)
local preset1 =
#(
#(#f_number, 8),
#(#shutter_speed, 60),
#(#ISO, 100),
#(#vignetting, off),
#(#whiteBalance_preset, 1),
#(#whiteBalance_preset, 4)
)
on change_bt pressed do undo "Change Vray Physical Cameras" on
(
all_cameras = keyboard.controlpressed
cams = findVrayPhysicalCameras selected:(not all_cameras)
if cams.count > 0 do
(
for p in preset1 do setproperty cams p[1] p[2]
)
)
)
createdialog test
but my idea is to force you to try understand how my code works
i understand, and thats why i am here, and that how i learn my 3d skills too( but untill now still cannot get international quality look ) to me, its hard to learn with my poor english 🙁
i can see you the way you create rollout is difference, shall i change my way of create rollout?
i don’t have VrayPhysicalCamera in my system…
there is a function in my code that collects cameras. check what it collects…
just try to understand the idea.
Hi denisT,
I just get it work, after i evaluate your code, the rollout pop up, and then i have to CTRL+click the Change VRay Cameras button, it will change the camera setting which i have selected.
but i get error if didn’t select anything
-- Error occurred in c loop; filename: C:\Users\user\Downloads\denisT_test.ms; position: 434; line: 13
-- Frame:
-- c: VRayPhysicalCamera
-- called in findVrayPhysicalCameras(); filename: C:\Users\user\Downloads\denisT_test.ms; position: 434; line: 13
-- Frame:
-- selected: true
-- cams: #(VRayPhysicalCamera)
-- called in change_bt.pressed(); filename: C:\Users\user\Downloads\denisT_test.ms; position: 782; line: 29
-- Frame:
-- cams: undefined
-- all_cameras: false
>> MAXScript Rollout Handler Exception:
-- Unknown property: "isSelected" in VRayPhysicalCamera <<
Try to change
Fn findvrayphysicalcameras selected:off =(
Cams=#()
If selected then for i in selection where iskindof vrayphysicalcamera appendifunique cams i
else join cams (getclassinstances VrayPhysicalCamera)
Cams)