If select object then disable button

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.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Swordslayer's picture

Enjoy

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 disableTest
paparalla's picture

Thanks so much!!!

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!

Swordslayer's picture

This doesn't make sense with

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 Rtest
paparalla's picture

Thanks again!

Thansk for your time wordslayer. Am very happy :)

paparalla's picture

Thanks again!

thanks for your time Swordslayer!

miauu's picture

.

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 ()
paparalla's picture

Thanks =)

Thansks Miauu you are crack!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.