If All Objects - Checker

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2012   #1
If All Objects - Checker

I've written a few functions that check if the selection of objects are either all "l" or "r", which stand for left and right. They also have to be point helpers.

The selection of objects has to meet 3 requirements and I've got a feeling that what I've written could be a bit more condensed so I figured I would go to the forums to get others opinions.

So what they need to require.
1. All objects have to be "classof Point"
2. All objects have to either contain "_l_" or "_r_". And only one or the other, not both.
3. Selection has to be greater >= 1

I'm using this as a callback selection-changed function which controls the enabled state of a button. Here is what I have.


	fn state_LMirrorOK = 
	(
		if selection.count <= 0 do return false
		for obj in selection do
		(
			if (findString (obj.name) "_l_") == undefined do 
			return false
		)
		return true
	)
	
	fn state_RMirrorOK = 
	(
		if selection.count <= 0 do return false
		for obj in selection do
		(
			if (findString (obj.name) "_r_") == undefined do 
			return false
		)
		return true
	)
	
	fn state_GuideOK = 
	(
		if selection.count <= 0 do return false
		for obj in selection do
		(
			if classof obj != point do 
			return false
		)
		return true
	)
	
	fn fnMirrorGuidesCtrl = (
		if state_LMirrorOK() OR state_RMirrorOK() AND state_GuideOK() then 
		(
			rlRigCreator.btnMirrorGuides.enabled = true
		)else(
			rlRigCreator.btnMirrorGuides.enabled = false
		)
	)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 03 March 2012   #2

$selection/helpers/*_l_*.count == $selection.count

 
Old 03 March 2012   #3
once again you condense it quite a bit id say.

wont that bug out my code because it things that /* is a comment and now its all green.

Thanks Denis
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com

Last edited by JokerMartini : 03 March 2012 at 08:15 PM.
 
Old 03 March 2012   #4
Originally Posted by JokerMartini: wont that bug out my code because it things that /* is a comment and now its all green.

oops...

$selection/helpers/'*_l_*'.count == $selection.count

that's more correct
 
Old 03 March 2012   #5
is it possible to put a variable in the name. Because right now it is evaluating the entire scene for that "_l_" which every object on the left has that. I need it to evaluate just the selection of objects.

theGuide = "leg_l_"
$selection/helpers/'*theGuide*'.count == $selection.count
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 03 March 2012   #6
Originally Posted by JokerMartini: is it possible to put a variable in the name. Because right now it is evaluating the entire scene for that "_l_" which every object on the left has that. I need it to evaluate just the selection of objects.

theGuide = "leg_l_"
$selection/helpers/'*theGuide*'.count == $selection.count


i don't have max at the moment but after thought a little i see that my method probably wrong. you have to double check it.
to pass a string variable is easy. make a string and execute it:

(execute ("$selection/helpers/'*" + pattern + "*'")) as array
 
Old 03 March 2012   #7
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:03 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.