ScriptSpot

Forum topic · General Scripting

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

By Drathir · 2014-08-14

Description

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 (3)

Drathir · 2014-09-12

Thank you very much ! :)

barigazy · 2014-08-14

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

barigazy · 2014-08-14


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)
)
)
)
)