Hi all,
i'm looking for a way to disable a button when selected any object in scene and enabled with not selected too.
thanks for your help.
Forum topic · General Scripting
By paparalla · 2016-05-05
Hi all,
i'm looking for a way to disable a button when selected any object in scene and enabled with not selected too.
thanks for your help.
Enjoy
Swordslayer · 2016-05-06
rollout disableTest "Disable Test"
(
button btnDoSomething "Do something"
on disableTest open do
callbacks.addScript #selectionSetChanged "disableTest.btnDoSomething.enabled = selection.count == 0" id:#disableButton
on disableTest closed do
callbacks.removeScripts #selectionSetChanged id:#disableButton
)
createDialog disableTestThanks so much!!!
paparalla · 2016-05-06
It is exactly what I wanted thanks you very much. Can you help me whit a one more thing please?
OK, I need something like this...
If selection object have a UVmap modifier -- disable the button, but if not Add modifier to object.
Here my little sample but its work only when "pressed button" and if the uvwmap is the first in the modifier list to the objects selection. I need this only when you select objects or not, and no matter order the UV map in the object selected.
Try(DestroyDialog Rtest)catch()
rollout Rtest "Test-Rollout"
(
button bt1 "DetectUVmap"
on bt1 pressed do
(
for i in selection do
m = 1
if classOf geometry[1].modifiers[m] != Uvwmap then
(
messagebox "Add_UVmap" beep:off
obj = selection[1]
size= obj.max.x - obj.min.x
uvmodifier = uvwmap name:"Fit Bitmap" maptype:4 length:(size) width:(size) height:(size)
addmodifier obj uvmodifier
)
else messagebox "Uvmap exist" beep:off
)
)
CreateDialog Rtest ()
Thanks!
.
miauu · 2016-05-06
rollout Rtest "Test-Rollout"
(
button bt1 "DetectUVmap"
on bt1 pressed do
(
selObjsArr = selection as array
for o in selObjsArr do
(
if o.modifiers.count != 0 then
(
stopLoop = false
for m in o.modifiers where classOf m == Uvwmap while stopLoop == false do
(
bt1.enabled = false
stopLoop = true
)
if stopLoop == false do
(
size= o.max.x - o.min.x
uvmodifier = uvwmap name:"Fit Bitmap" maptype:4 length:(size) width:(size) height:(size)
addmodifier o uvmodifier
)
)
else
(
size= o.max.x - o.min.x
uvmodifier = uvwmap name:"Fit Bitmap" maptype:4 length:(size) width:(size) height:(size)
addmodifier o uvmodifier
)
)
)
)
CreateDialog Rtest ()
Thanks =)
paparalla · 2016-05-11
Thansks Miauu you are crack!
Swordslayer · 2016-05-09
This doesn't make sense with a mixed selection where some objects already have the modifier and some don't. I'd avoid disabling a part of the UI, let the user decide and just skip all the objects that already have the modifier applied
try destroyDialog Rtest catch()
rollout Rtest "Test-Rollout"
(
button bt1 "TryAssignUVmap"
on bt1 pressed do
(
for obj in selection where (getClassInstances Uvwmap target:obj).count < 1 do
(
local size = obj.max.x - obj.min.x
addModifier obj (Uvwmap name:"Fit Bitmap" mapType:4 length:size width:size height:size)
)
)
)
createDialog RtestThanks again!
paparalla · 2016-05-11
thanks for your time Swordslayer!
Thanks again!
paparalla · 2016-05-11
Thansk for your time wordslayer. Am very happy :)