How to get first chars of name of current stack modifier or class

Hi guys !

I wrote quick script for connect in one button for vertex and edges (in Edit_poly / Editable_poly modifiers). It works perfectly unless i change name of modifier (ex. Edit_poly_randomString). How to write that script will execute its case depends of first chars of modifier (Edit_polyDOESNT_MATTER_ANY_OTHER_STRING_HERE)or get class(?) of Edit_poly / Editable_poly?

macroscript ConnectSubObjectMode
category:"All MojeSkrypty"
tooltip:"Connect uruchamiany zaleznie od subMode"
(
local curObj = modPanel.getCurrentObject()
	Case (classOf curObj) of
	(
		Editable_poly: 
			(	Case (subobjectLevel) of
				(
				 1: $.EditablePoly.ConnectVertices ()
				 2: $.EditablePoly.ConnectEdges ()
				 3: $.EditablePoly.ConnectEdges ()
				)
			)
		Edit_Poly:
			(	Case (subobjectLevel) of
				(
				 1: $.modifiers[#Edit_Poly].ButtonOp #ConnectVertices 
				 2: $.modifiers[#Edit_Poly].ButtonOp #ConnectEdges
				 3: $.modifiers[#Edit_Poly].ButtonOp #ConnectEdges
				)
			)
		default:
			(	--Case (subobjectLevel) of
				--(
				 --1: $.modifiers[#Edit_Poly].ButtonOp --#ConnectVertices 
				 --2: $.modifiers[#Edit_Poly].ButtonOp --#ConnectEdges
				 --3: $.modifiers[#Edit_Poly].ButtonOp --#ConnectEdges
 
				)
			)
	)
)

Comments

Comment viewing options

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

Thank you very much ! :)

Thank you very much ! :)

barigazy's picture

...

As you saw I not use "case of" statement because you have only two conditions that U need to check.

barigazy

barigazy's picture

...

macroscript ConnectSubObjectMode category:"All MojeSkrypty" tooltip:"Connect uruchamiany zaleznie od subMode"
(
	if (node = modPanel.getCurrentObject()) != undefined do
	(
		if (number = findItem #(editable_poly, edit_poly) (classOf node)) > 0 do
		(
			if subobjectLevel > 0 and subobjectLevel < 4 do
			(
				if subobjectLevel == 1 then (if number == 1 then node.ConnectVertices() else node.ButtonOp #ConnectVertices)
				else (if number == 1 then node.ConnectEdges() else node.ButtonOp #ConnectEdges)
			)
		)
	)
)	

barigazy

Comment viewing options

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