ScriptSpot

Forum topic · Scripts Wanted

Link slice modifier slice plane to an object

By titane357 · 2025-07-23

Description

Hi,
I made a simple script to link slice modifier slice plane to an object with wireparameters
But if the object with slice modifier is rotated it don't work as I don't understand how to use node transfoem or matrix.
Can somebody can help ? thanks.

How to use : select object with slice modifier then run the script, with the rubberband click on the target object


		CurrentMod = modpanel.getCurrentObject()
		theModifier_ID = modPanel.getModifierIndex $ CurrentMod 
		MODD = $.modifiers[theModifier_ID]
		POSS= $.position
		clearSelection()		
		(			
		TARG = pickObject rubberBand:POSS rubberBandColor:yellow 

		PX= "X_Position - " + ( POSS.x )as string 
		paramWire.connect TARG.pos.controller[#X_Position] MODD.Slice_Plane.controller.Position.controller[#X_Position]  PX

		PY= "Y_Position - " + ( POSS.y )as string 
		paramWire.connect TARG.pos.controller[#Y_Position] MODD.Slice_Plane.controller.Position.controller[#Y_Position]  PY

		PZ= "Z_Position - " + ( POSS.z )as string 
		paramWire.connect TARG.pos.controller[#Z_Position] MODD.Slice_Plane.controller.Position.controller[#Z_Position]  PZ
		paramWire.connect TARG.rotation.controller[#X_Rotation] MODD.Slice_Plane.controller.Rotation.controller[#X_Rotation]  "X_Rotation"
		paramWire.connect TARG.rotation.controller[#Y_Rotation] MODD.Slice_Plane.controller.Rotation.controller[#Y_Rotation]  "Y_Rotation"
		paramWire.connect TARG.rotation.controller[#Z_Rotation] MODD.Slice_Plane.controller.Rotation.controller[#Z_Rotation]  "Z_Rotation"		
		)
Comments (4)

titane357 · 2025-08-20

Thank you very much to show me how useless i am in coding !!! :-)

Yes I should have do this.... ;-)

AEI · 2025-08-12

with wire parameter , you should matrix calculate , the main point is transpose matrix of modifier's node left multiply target matrix , then set back position to in modifier's node target's position

by extend slice modifier ,replaced by controller instance , it will be faster when update and easy to use

a simple example


plugin modifier ceshi111
name:"ceshi111"
classID:#(14531456,54132110)
extends:SliceModifier
(
parameters main rollout:params
(
nodeobj type:#node ui:aa
on nodeobj set val do 
(
	if val != undiasdf do
	(
		c=transform_script()
		c.AddNode "a" (refs.dependentNodes this)[1]
		c.AddNode "b" val 
		c.script = "matrix=if IsValidNode b then(m=b.transform*inverse a.transform;m.row4=in coordsys a b.pos;m)else m=matrix3 1;matrix"
		this.Slice.Slice_Plane.controller=c
	)
)
)
rollout params "Parameters"
(
pickbutton aa "pick node"
)
)

run script , and modifier ceshi111,it is a slice modifier with a pick button , pick a node the slice plane will link the node

titane357 · 2025-08-11

Hi, thanks but I wanted to do it for other tools too.....

AEI · 2025-08-11

you can upgrade your max , new version has built-in method