[Closed] "SimpleManipulators"
Hi
How can I make a resizable rectangle and some text in grid space, like in this picture.
only with manipulatros gismos…
Im tried this all day , but nothing found.:hmm:
manipulator can be in world (3D) space or in screen (2D) space.
if the manipulator is in screen space, width and length in world units doesn’t make sense for me.
what “grid space” is?
is in 3d space ,is base of a cube. The same way , when you create a spline rectangle.
try this one:
plugin simpleManipulator resize3D_Manipulator
name:"3D Resizer"
classID:#(0x2feb1967, 0x173d058a)
--invisible:on
category:"Manipulators"
(
local rd = colorMan.getColor #manipulatorsSelected
local yc = [1,1,0]
local bc = [0,1,1]
local ac = [0,0.8,0.8]
local ic = [0,0.7,0.7]
parameters main rollout:paramRollout
(
xPos type:#float animatable:off ui:ui_xPos default:0.0
yPos type:#float animatable:off ui:ui_yPos default:0.0
width type:#float animatable:off ui:ui_width default:0.0
length type:#float animatable:off ui:ui_length default:0.0
)
rollout paramRollout "Target Manipulator"
(
group "Parameters: "
(
spinner ui_xPos "X Position: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,0]
spinner ui_yPos "Y Position: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,-2]
spinner ui_width "Width: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,0]
spinner ui_length "Length: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,-2]
)
)
on canManipulate target return (iskindof target resize3D_Manipulator)
tool create
(
local pos
on mousePoint click do case click of
(
1:
(
pos = nodeTM.translation = gridPoint
)
2: #stop
)
on mouseMove click do case click of
(
2:
(
this.width = gridPoint.x - pos.x
this.length = gridPoint.y - pos.y
)
)
)
on updateGizmos do
(
local cc = if (target != undefined) then
(
this.xPos = target.xPos
this.yPos = target.yPos
this.width = target.width
this.length = target.length
ac
)
else ic
local pos = [this.xPos,this.yPos,0]
local size = [this.width,this.length,0]
this.clearGizmos()
giz = manip.makeGizmoShape()
giz.startNewLine()
giz.addPoint pos
giz.addPoint (pos + [this.width,0,0])
giz.addPoint (pos + [this.width,this.length,0])
giz.addPoint (pos + [0,this.length,0])
giz.addPoint pos
this.addGizmoShape giz gizmoDontHitTest cc cc
this.addGizmoMarker #bigBox pos 0 yc rd
this.addGizmoMarker #hollowBox (pos+size) 0 bc rd
)
on mouseMove m which do if target != undefined do
(
projectedPoint = [0,0,0]
viewRay = this.getLocalViewRay m
local pl2 = manip.makePlaneFromNormal z_axis [0,0,0]
pl2.mostOrthogonal viewRay pl2
if (pl2.intersect viewRay &projectedPoint) do case which of
(
1:
(
target.xPos = projectedPoint.x
target.yPos = projectedPoint.y
)
2:
(
target.width = projectedPoint.x - target.xPos
target.length = projectedPoint.y - target.yPos
)
)
)
)
Excelent!!!
Finaly I can continue with a good base!
many thanks Denis. It is something new for me , alone I wil never get it
The text which I adedd by this.addGizmoText , is not displaying for the most part.
I dont know if is problem of my PC, or gismo text function?
Global sketch3D_plane_node
Global sketch3D_plane
plugin simpleManipulator sketch3D_plane
name:"Plane01"
classID:#(0x3f79562a, 0x662c3770) --GenclassID()
--invisible:on
category:"Manipulators"
(
local rd = colorMan.getColor #manipulatorsSelected
local yc = [1,1,0]
local bc = [0,1,1]
local ac = [0,0.8,0.8]
local ic = [0,0.7,0.7]
parameters main rollout:paramRollout
(
xPos type:#float animatable:off ui:ui_xPos default:0.0
yPos type:#float animatable:off ui:ui_yPos default:0.0
width type:#float animatable:off ui:ui_width default:0.0
length type:#float animatable:off ui:ui_length default:0.0
)
rollout paramRollout "Target Manipulator"
(
group "Parameters: "
(
spinner ui_xPos "X Position: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,0]
spinner ui_yPos "Y Position: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,-2]
spinner ui_width "Width: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,0]
spinner ui_length "Length: " fieldwidth:56 range:[-1e9, 1e9, 0.0] type:#worldunits align:#right offset:[0,-2]
)
)
on canManipulate target return (iskindof target sketch3D_plane)
tool create
(
local pos
on mousePoint click do case click of
(
1:
(
pos = nodeTM.translation = gridPoint
)
2: #stop
)
on mouseMove click do case click of
(
2:
(
this.width = gridPoint.x - pos.x
this.length = gridPoint.y - pos.y
)
)
)
on updateGizmos do
(
local cc = if (target != undefined) then
(
this.xPos = target.xPos
this.yPos = target.yPos
this.width = target.width
this.length = target.length
ac
)
else ic
local pos = [this.xPos,this.yPos,0]
local size = [this.width,this.length,0]
this.clearGizmos()
giz = manip.makeGizmoShape()
giz.startNewLine()
giz.addPoint pos
giz.addPoint (pos + [this.width,0,0])
giz.addPoint (pos + [this.width,this.length,0])
giz.addPoint (pos + [0,this.length,0])
giz.addPoint pos
this.addGizmoShape giz gizmoDontHitTest cc cc
this.addGizmoMarker #bigBox pos 0 yc rd
this.addGizmoMarker #smallHollowBox (pos+size) 0 bc rd
wid_txt = "Width: " + abs size.x as string
wid_pos = [pos.x+size.x, pos.y+1, 0]
len_txt = "Length: " + abs size.y as string
len_pos = [pos.x, pos.y+size.y, 0] -- - (getTextExtent len_txt).x
this.addGizmoText wid_txt wid_pos 0 yc rd
this.addGizmoText len_txt len_pos 0 yc rd
return (wid_txt+" "+len_txt)
)
on mouseMove m which do if target != undefined do
(
projectedPoint = [0,0,0]
viewRay = this.getLocalViewRay m
local pl2 = manip.makePlaneFromNormal z_axis [0,0,0]
pl2.mostOrthogonal viewRay pl2
if (pl2.intersect viewRay &projectedPoint) do case which of
(
1:
(
target.xPos = projectedPoint.x
target.yPos = projectedPoint.y
)
2:
(
target.width = projectedPoint.x - target.xPos
target.length = projectedPoint.y - target.yPos
)
)
)
)
if sketch3DDialog != undefined do destroyDialog sketch3DDialog
rollout sketch3DDialog " Sketch 3D" width:76 height:452
(
groupBox grp1 "Shapes:" pos:[4,4] width:68 height:104
groupBox grp2 "Tools:" pos:[4,112] width:68 height:180
groupBox grp3 "Options:" pos:[4,296] width:68 height:152
button btn_plane "r" pos:[8,20] width:24 height:24 toolTip:"Rectangle"
button btn_extrude "e" pos:[8,128] width:24 height:24 toolTip:"Extrude"
on btn_plane pressed do
(
if isValidNode sketch3D_plane_node do delete sketch3D_plane_node
sketch3D_plane_node = sketch3D_plane()
manipulateMode = off
manipulateMode = on
)
on btn_extrude pressed do
(
)
)
createDialog sketch3DDialog pos:[170,80] style:#(#style_toolWindow, #style_sysMenu)
Hi Rene, try to add a completeRedraw() at the end of the code into “on mouseMove” event.
- Enrico
nop , text is still hidding during resizing rectangle, or viewport is moving.
by the way you know how to start this plugin from custom interface?
in my case is not starting like tool ,but only shows up in scene center
I had a similar issue before adding the redraw function, now it works well on my system, trying it on 3ds Max 2009 x64.
To make the script available from Customize User Interface… and associate a shortcut or toolbar button to it, you need to create a MacroScript. Something like:
macroScript ScriptName
category:"MyCategory"
buttonText:"MyScript"
tooltip:"My Script"
(
plugin simpleManipulator sketch3D_plane
(
<manipulator code here>
)
rollout sketch3DDialog " Sketch 3D" width:76 height:452
(
<rollout code here>
)
on execute do -- MacroScript event handler
(
try (destroyDialog sketch3DDialog) catch ()
createDialog sketch3DDialog pos:[170,80] style:#(#style_toolWindow, #style_sysMenu)
)
)
I hope I got what you’re looking for.
- Enrico
Interface is not a problem , but I have trouble to run this plugin from inside correctly.
with this sketch3D_plane() will be gismo apear directly on scene with size [0,0,0]
I need something which will be start this plugin like a Tool
to let me chose place vhere will be created and drag his size manualy.
I hope is written now to make some sense …