Notifications
Clear all

[Closed] What is "is #sel_2" "is #sel_1" "is #sel_0"

Hi all

I study maxscript,Some do not know what it means .
for example:
if (is #sel_2 and is #poly) then ()
if (is #sel_0 and is #poly) then ()
if (is #sel_1 and is #poly) then ()
What is “is #sel_2” “is #sel_1” “is #sel_0” ?

6 Replies

This is not your code, so you have to give us the hole script and my be we can help you.

I understand ,it is a fn

fn is arg =
(
local sel = selection[1]
case arg of
(
#sel_0: selection.count == 0
#sel_1: selection.count == 1
#sel_2: selection.count > 0
#mod: getCommandPanelTaskMode() == #modify
#poly: classOf sel.baseObject == Editable_Poly
#mesh: classOf sel.baseObject == Editable_Mesh
#patch: classOf sel.baseObject == Editable_Patch
#shp: superClassOf sel == shape
#spline: findItem #(Edit_Spline, Line, SplineShape) (Classof sel.baseObject) != 0
#fSel_1: (polyOp.getFaceSelection $ as array).count == 1
#fSel_2: (polyOp.getFaceSelection $ as array).count > 0

	#editable: validModifier $ Edit_Mesh
	#inBase: modPanel.getCurrentObject() == $.baseobject
	#modPoly : modPanel.getCurrentObject() == $.modifiers[#Edit_Poly]

	#sLev_x: (is #mod) and (subObjectLevel > 0 )
	#sLev_0: (is #mod) and (subObjectLevel >= 0)	
	#sLev_1: (is #mod) and (subObjectLevel == 1)
	#sLev_2: (is #mod) and (subObjectLevel == 2)
	#sLev_3: (is #mod) and (subObjectLevel == 3)
	#sLev_4: (is #mod) and (subObjectLevel == 4)
	#sLev_5: (is #mod) and (subObjectLevel == 5)
	
	#Move: toolmode.commandmode == #Move
	#Rotate: toolmode.commandmode == #Rotate
	#Scale: (toolmode.commandmode == #nuscale) or (toolmode.commandmode == #uScale) or (toolmode.commandmode == #squash)
	)
)

#sel_0 – no object are selected
#sel_1 – only one object is selected
#sel_2 – one or more objects are selected

#poly – the selected object is Editable Poly
#mesh – the selected object is Editable Mesh
#patch – the selected object is Editable Patch
#shp – the selected object is shape(spline)

What is the name of the script that you study?

It’s arguments of the function. I’m not sure how they are called, but you can use them instead of string for example.

You can say:

fruit = #apple
fruit = #pear

alternatively to:

fruit = “apple”
fruit = “pear”

with strings it would look like this in the case expression:

“sel_0”: selection.count == 0
“sel_1”: selection.count == 1
“sel_2”: selection.count > 0

etc.

 lo1

these are called name values. They are much faster and more memory conservative than strings. See maxscript help ‘how to make it faster’.

Hi
It is my old unfinished function for errorcheck, which is helped me optimize code little bit.
Also in begin of my scripting it was easiest to remember these shortcuts

one example how you can use it:

If you want to know :
-tat one object is selected
-that is an editable poly
-that is in subobject level 4 state

if is #sel_1 and is #poly and is sLev_4 do print “the selected object is ok, continue…”

I hope that helps you understand how its works