[Closed] Create a scripted helper with the pivot at the bottom
I’m trying to create a scripted helper that always has it’s pivot at the bottom, and when I adjust the height it should beep the it’s base at the bottom while just scaling it upwards.
With the attached code it behaves correctly on creation, but when it’s created the pivot is in the center, and when the height is adjusted it scales it in both directions. I know my way around with maxscript, but I have to admit I don’t really understand how the steps creation really works, and setting properties on “delegate” and such.
Any chance someone could help me out on this?
plugin Helper HelperTest name:"HelperTest" classID:#(0x471114fe, 0x4e9fa290) category:"Standard" extends:dummy
(
parameters params rollout:helperMainUi
(
dummyRadius type:#float ui:ui_dummyRadius default:0.02
dummyHeight type:#float ui:ui_dummyHeight default:0.02
on dummyRadius set val do (delegate.boxsize.x = val; delegate.boxsize.y = val)
on dummyHeight set val do (delegate.boxsize.z = val)
)
-- Rollout
rollout helperMainUi "Properties" width:160 height:456
(
spinner ui_dummyRadius "Dummy Radius: " fieldWidth:58 type:#worldunits range:[0,1e9,0] align:#left offset:[0,0] tooltip:"X/Y"
spinner ui_dummyHeight "Dummy Height: " fieldWidth:60 type:#worldunits range:[0,1e9,0] align:#left offset:[0,-2] tooltip:"Z"
)
-- Specifies the way creating the helper works
-- https://forums.cgsociety.org/t/resize-dummy-modifier/1530867/3
tool create
(
local pos
on mousePoint click do case click of
(
1: pos = nodeTM.translation = gridPoint
2: pos = nodeTM.translation
3: #stop
)
on mouseMove click do case click of
(
2:
(
nodeTM.translation = pos
dummyRadius = abs griddist.x
)
3:
(
nodeTM.translation = pos + [0, 0, griddist.z*0.5]
dummyHeight = abs griddist.z
)
)
)
)
Instead of a Helper object do a Scripted Manipulator, where you will be able to control its gizmo shape.
I published several examples of scripted manipulators on this from. Try to find.
you must create mesh by yourself , use a box or mesh method to create it
Something like this may work:
plugin helper HelperTest
name:"HelperTest"
classID:#(0x471114fe, 0x4e9fa290)
category:"Standard"
(
local imesh
parameters params rollout:helperMainUi
(
radius type:#float ui:ui_radius default:0.02
height type:#float ui:ui_height default:0.02
on radius set val do if imesh != undefined do imesh.length = imesh.width = val
on height set val do if imesh != undefined do imesh.height = val
)
rollout helperMainUi "Properties"
(
spinner ui_radius "Radius: " fieldWidth:58 type:#worldunits range:[0,1e9,0] align:#left offset:[0,0] tooltip:"X/Y"
spinner ui_height "Height: " fieldWidth:60 type:#worldunits range:[0,1e9,0] align:#left offset:[0,-2] tooltip:"Z"
)
on getDisplayMesh do
(
if imesh == undefined do imesh = createinstance box length:0 width:0 height:0
imesh.mesh
)
tool create
(
on mousePoint click do
(
case click of
(
1: nodeTM.translation = gridPoint
2: nodeTM.translation
3: #stop
)
)
on mouseMove click do
(
case click of
(
2: radius = abs griddist.x
3: height = abs griddist.z
)
)
)
)