"SimpleManipulators"


#1

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:


Example script for custom gizmo
#2

are width and length in pixels or in units?


#3

is not for unwrap, the units (cm) will be used


#4

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?


#5

is in 3d space ,is base of a cube. The same way , when you create a spline rectangle.


#6

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


#7

Excelent!!!
Finaly I can continue with a good base!

many thanks Denis. It is something new for me , alone I wil never get it :slight_smile:


#8

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)
   

#9

Hi Rene, try to add a completeRedraw() at the end of the code into “on mouseMove” event.

  • Enrico

#10

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


#11

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

#12

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 … :smiley:


#13

I would like to do something like this:

but I dont know if is posible to make it :slight_smile:


#14

“SimpleManipulators” is not so simple for me as I expect.
I started with GW [color=white]Viewport Drawing Methods[/color]

here is the first step: How to create a base


 (
 
 	struct SKETCH_PRIMITIVE_SHAPES
 	(
 		start_point, rect_size,
 		
 		fn roundVal val pos =
 		(
 			((val*pos)as integer)*(pos/(pos*pos)as float)
 		),
 		fn drawRect  = --rect_size rect_color =
 		(
 			if start_point == undefined or rect_size == undefined do return false
 			
 			local col =red
 			local p1=[0,0,0] + start_point
 			local p2=[rect_size.x,0,0] + start_point
 			local p3=[rect_size.x,rect_size.y,0] + start_point
 			local p4=[0,rect_size.y,0] + start_point
 			
 			gw.setTransform (Matrix3 1)
 			p = gw.hTransPoint p1
 			
 			gw.hMarker p #smallHollowBox color:[255,255,255]
 			p = gw.hTransPoint p3
 			gw.hMarker p #smallHollowBox color:[255,255,255]
 
 			p = gw.hTransPoint p2
 			gw.htext p ("width: "+(roundVal rect_size.x 1000) as string) color:yellow
 			p = gw.hTransPoint p4
 			gw.htext p ("length: "+(roundVal rect_size.y 1000) as string) color:yellow
 			
 			gw.setColor #line red
 			gw.Polyline #(p1, p2, p3, p4) true rgb:#(col, col, col, col) 
 			
 			gw.enlargeUpdateRect #whole --updateRect
 			gw.updateScreen()
 		)
 	)
 	
 	struct CREATE_GEOMETRY
 	(
 		fn createPrimitive type pos:[0,0,0] size:[100,100,100] clr:(color 40 100 200)=
 		(
 			case type of
 			(
 				#plane:in coordsys grid plane pos:(pos + [size.x/2, size.y/2, pos.z]) length:(abs size.y) width:(abs size.x) lengthsegs:1 widthsegs:1 renderScale:1 density:1 wirecolor:clr
 				#rectangle:in coordsys grid rectangle pos:pos
 				#point:in coordsys grid point pos:pos
 				#text :in coordsys grid 
 				(
 					tsize = 1
 					text pos:pos text:"" wirecolor:yellow size:tsize
 				)
 			)
 		)
 	)
 	
 	local SPS = SKETCH_PRIMITIVE_SHAPES()
 	local CG = CREATE_GEOMETRY()
 	local ABORT = false
 	local BUILD = false
 	
 	tool drawRectTool
 	(
 		--on start do (print "begin")
 		on mousePoint click do
 			case click of
 			(
 				1: 
 				(
 					SPS.start_point = gridPoint --nodeTM.translation =
 					unregisterRedrawViewsCallback SPS.drawRect
 					registerRedrawViewsCallback SPS.drawRect
 					completeRedraw()
 					
 				)
 				2: 
 				(
 					BUILD = true
 					#stop
 				)
 			)
 		on mouseMove click do
 			case click of
 			(
 					2:
 					(
 						SPS.rect_size = gridDist
 						CompleteRedraw()
 					)
 					--gridPoint
 			)
 		on mouseAbort click do
 		(
 			print build
 			unregisterRedrawViewsCallback SPS.drawRect
 			if BUILD do 
 			(
 				local p = CG.createPrimitive #plane pos:SPS.start_point size:SPS.rect_size
 				convertToPoly p
				p.name = uniqueName "model rect base"
 				select p
 			)
 			completeRedraw()
 			ABORT = true	
 		)
 	)
 	
 	while not ABORT and not keyboard.escPressed do (startTool drawRectTool)
 )
 

the next steps is :
2) put some Guide Lines during creation (like the picture in previous post)
3) posibility to snap rectangle to “guide line ruller” (units cm)…

if anybody have some ideas , will be much appreciated :slight_smile:


#15
  1. How to create a resizable base frame – progress: Done (thanks to Denis)
  2. Making Guide Lines (rulers) for position base – progress:80%
  3. posibility to snap base to guide line (ruler) --progress: -100%
  4. measuring: distance / angle
  5. slice surface
  6. straighten cut
  7. extrude / bolean / push

  GLOBAL sketch3DDialog
  (
  	-----------------------------
  	struct MATH_OPERATION
  	(
  		fn roundVal val pos = ((val*pos)as integer)*(pos/(pos*pos)as float),
  		fn roundPoint3 p3 pos =[roundVal p3.x pos, roundVal p3.y pos, roundVal p3.z pos]
  	)
  	local MO = MATH_OPERATION()
  	-----------------------------
  	struct DRAW_GUIDE_LINES
  	(
  		start_point, rect_size, draw_point,
  		
  		fn drawRect  =
  		(
  			if rect_size == undefined do return false
  			
  			local col =red
  			local p1=[0,0,0] + start_point
  			local p2=[rect_size.x,0,0] + start_point
  			local p3=[rect_size.x,rect_size.y,0] + start_point
  			local p4=[0,rect_size.y,0] + start_point
  			
  			gw.setTransform (Matrix3 1)
  			
  			local p = gw.hTransPoint p1
  			gw.hMarker p #smallHollowBox color:[255,255,255]
  			
  			p = gw.hTransPoint p3
  			gw.hMarker p #smallHollowBox color:[255,255,255]
  
  			p = gw.hTransPoint p2
  			gw.htext p ("width: "+(abs rect_size.x) as string+"  ") color:yellow
  			p = gw.hTransPoint p4
  			gw.htext p ("length: "+(abs rect_size.y) as string+"  ") color:yellow
  			
  			gw.setColor #line col
  			gw.Polyline #(p1, p2, p3, p4) true rgb:#(col, col, col, col) 
  			
  			gw.enlargeUpdateRect #whole --updateRect
  			gw.updateScreen()
  		),
  		fn drawGuideLines = --cross
  		(
  			if draw_point == undefined or rect_size == undefined do return false
  			
  			gw.setTransform (Matrix3 1)
  			local cros_size = [1000, 1000] 
  
  			local p = gw.hTransPoint (draw_point+1)
  			gw.htext p ("pos: "+ draw_point as string+"  ") color:yellow
  			
  			gw.setColor #line gray
  			gw.Polyline #([-cros_size.x,0,0]+draw_point,[cros_size.x,0,0]+draw_point) false --Line X
  			gw.setColor #line gray
  			gw.Polyline #([0,-cros_size.y,0]+draw_point,[0,cros_size.y,0]+draw_point) false --Line Y
  			gw.enlargeUpdateRect #whole
  			gw.updateScreen()
  		)
  	)
  	local DGL = DRAW_GUIDE_LINES()
  	-----------------------------
  	struct CREATE_GEOMETRY
  	(
  		fn createPrimitive type pos:[0,0,0] size:[100,100,100] clr:(color 40 100 200)=
  		(
  			case type of
  			(
  				#plane:in coordsys grid plane pos:(pos + [size.x/2, size.y/2, pos.z]) length:(abs size.y) width:(abs size.x) lengthsegs:1 widthsegs:1 renderScale:1 density:1 wirecolor:clr
  				#rectangle:in coordsys grid rectangle pos:pos
  				#point:in coordsys grid point pos:pos
  				#text :in coordsys grid 
  				(
  					tsize = 1
  					text pos:pos text:"" wirecolor:yellow size:tsize
  				)
  			)
  		)
  	)
  	local CG = CREATE_GEOMETRY()
  	-----------------------------
  	local ABORT = false
  	local BUILD = false
  	-----------------------------
  	tool drawRectTool
  	(
  		local round_value = 100 , snap_value  = 10
  		--on start do ()
  		on mousePoint click do
  			case click of
  			(
  				1:	
  				(
  					DGL.start_point = MO.roundPoint3 gridPoint round_value --nodeTM.translation =
  					unregisterRedrawViewsCallback DGL.drawGuideLines
  					registerRedrawViewsCallback DGL.drawGuideLines
  					completeRedraw()
  				)
  				2: 
  				(
  					DGL.start_point = MO.roundPoint3 gridPoint round_value
  					unregisterRedrawViewsCallback DGL.drawRect
  					registerRedrawViewsCallback DGL.drawRect
  					completeRedraw()
  				)
  				3: 
  				(
  					BUILD = true
  					completeRedraw()
  					#stop
  				)
  			)
  		on mouseMove click do
  			--case click of
  			(
  					--2:
  					--(
  						DGL.rect_size = MO.roundPoint3 gridDist round_value
  						DGL.draw_point = MO.roundPoint3 gridPoint round_value
  						CompleteRedraw()
  					--)
  			)
  		on mouseAbort click do
  		(
  			unregisterRedrawViewsCallback DGL.drawGuideLines
  			unregisterRedrawViewsCallback DGL.drawRect
  			if BUILD do 
  			(
  				local p = CG.createPrimitive #plane pos:DGL.start_point size:DGL.rect_size
  				convertToPoly p
  				p.name = uniqueName "model rect base"
  				select p
  			)
  			completeRedraw()
  			ABORT = true	
  		)
  	)
  	
  	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
  		checkButton ckb_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 ckb_plane changed state do
  		(
  			if state do
  			(
  				ABORT = false
  				while not ABORT and not keyboard.escPressed do (startTool drawRectTool)
  				ckb_plane.checked = false
  			)
  		)
  		on btn_extrude pressed  do
  		(
  		
  		)
  	)
  	createDialog sketch3DDialog pos:[170,80] style:#(#style_toolWindow, #style_sysMenu)
  )
  

#16
  1. How to create a resizable base frame – progress: Done (thanks to Denis :slight_smile:
    2) Making Guide Lines (rulers) for position base – progress:80%
    3) posibility to snap base to guide line (ruler) --progress: 99% (thanks to Denis :slight_smile:
    4) measuring: distance / angle --progress:0%
    5) cutting: slice surface / straighten cut --progress:0%
    6) modify: extrude / bolean / push --progress:0%

     GLOBAL sketch3DDialog
(
	-----------------------------
	struct MATH_OPERATION
	(
		fn roundVal val pos = ((val*pos)as integer)*(pos/(pos*pos)as float),
		fn roundFloat d pre:0.1 =
		(
			d = (d as float)/pre
			local v = if (d - (v1 = floor d)) > ((v2 = ceil d) - d) then v2 else v1 
			v*pre
		),
		fn roundPoint3 p3 pre:0.1 =[roundFloat p3.x pre: pre, roundFloat p3.y pre: pre, roundFloat p3.z pre: pre]
	)
	local MO = MATH_OPERATION()
	-----------------------------
	struct DRAW_GUIDE_LINES
	(
		start_point, rect_size, draw_point, draw_rect_enabled = false, snap_value = 0.1,
		
		fn drawRect  =
		(
			if not draw_rect_enabled do return false
			
			local col =red
			local p1=[0,0,0] + start_point
			local p2=[rect_size.x,0,0] + start_point
			local p3=[rect_size.x,rect_size.y,0] + start_point
			local p4=[0,rect_size.y,0] + start_point
			
			gw.setTransform (Matrix3 1)
			
			local p = gw.hTransPoint p1
			gw.hMarker p #smallHollowBox color:[255,255,255]
			
			p = gw.hTransPoint p3
			gw.hMarker p #smallHollowBox color:[255,255,255]

			p = gw.hTransPoint p2
			gw.htext p ("width: "+(abs rect_size.x) as string+"  ") color:yellow
			p = gw.hTransPoint p4
			gw.htext p ("length: "+(abs rect_size.y) as string+"  ") color:yellow
			
			gw.setColor #line col
			gw.Polyline #(p1, p2, p3, p4) true rgb:#(col, col, col, col) 
			
			gw.enlargeUpdateRect #whole --updateRect
			gw.updateScreen()
		),
		fn drawGuideLines = --cross
		(
			if draw_point == undefined do return false
			--(
				--draw_point = [mouse.screenpos.x, mouse.screenpos.y, 0]
			--)
			gw.setTransform (Matrix3 1)
			local cros_size = [10000, 10000] 

			local p = gw.hTransPoint (draw_point+1)
			gw.htext p ("pos2: "+ draw_point as string+"  ") color:yellow
			
			gw.setColor #line gray
			gw.Polyline #([-cros_size.x,0,0]+draw_point,[cros_size.x,0,0]+draw_point) false --Line X
			gw.Polyline #([0,-cros_size.y,0]+draw_point,[0,cros_size.y,0]+draw_point) false --Line Y
			
			if start_point != undefined do
			(
				p = gw.hTransPoint (start_point+1)
				gw.htext p ("pos1: "+ start_point as string+"  ") color:yellow
				gw.Polyline #([-cros_size.x,0,0]+start_point,[cros_size.x,0,0]+start_point) false --Line X
				gw.Polyline #([0,-cros_size.y,0]+start_point,[0,cros_size.y,0]+start_point) false --Line Y
			)
			gw.enlargeUpdateRect #whole
			gw.updateScreen()
		)
	)
	local DGL = DRAW_GUIDE_LINES()
	-----------------------------
	struct CREATE_GEOMETRY
	(
		fn createPrimitive type pos:[0,0,0] size:[100,100,100] clr:(color 40 100 200)=
		(
			case type of
			(
				#plane:in coordsys grid plane pos:(pos + [size.x/2, size.y/2, pos.z]) length:(abs size.y) width:(abs size.x) lengthsegs:1 widthsegs:1 renderScale:1 density:1 wirecolor:clr
				#rectangle:in coordsys grid rectangle pos:pos
				#point:in coordsys grid point pos:pos
				#text :in coordsys grid 
				(
					tsize = 1
					text pos:pos text:"" wirecolor:yellow size:tsize
				)
			)
		)
	)
	local CG = CREATE_GEOMETRY()
	-----------------------------
	local ABORT = false
	-----------------------------
	tool drawRectTool
	(
		local round_value = 100
		on start do 
		(
			DGL.start_point = undefined
			DGL.draw_rect_enabled = false
			unregisterRedrawViewsCallback DGL.drawGuideLines
			unregisterRedrawViewsCallback DGL.drawRect
			completeRedraw()
			print "start"
		)
		on mousePoint click do
		(
			format "click mousePoint:%
" click
			case click of
			(
				1:
				(			
					DGL.start_point = MO.roundPoint3 gridPoint pre: DGL.snap_value
					DGL.draw_point = DGL.start_point
					DGL.rect_size = MO.roundPoint3 gridDist pre: DGL.snap_value
				)
				2:	
				(					
					unregisterRedrawViewsCallback DGL.drawGuideLines
					unregisterRedrawViewsCallback DGL.drawRect	
					
					registerRedrawViewsCallback DGL.drawGuideLines					
					registerRedrawViewsCallback DGL.drawRect
					
					DGL.draw_rect_enabled = true
					completeRedraw()
				)
				3: 
				(
					local p = CG.createPrimitive #plane pos: DGL.start_point size: DGL.rect_size
					convertToPoly p
					p.name = uniqueName "model rect base"
					select p
					completeRedraw()
					#stop
				)
			)
		)
		on mouseMove click do
		(
			if click > 1 do
			(
				DGL.draw_point = MO.roundPoint3 gridPoint pre: DGL.snap_value
				DGL.rect_size = MO.roundPoint3 gridDist pre: DGL.snap_value
				CompleteRedraw()
			)
		)
		on mouseAbort click do
		(
			print "stop"
			unregisterRedrawViewsCallback DGL.drawGuideLines
			unregisterRedrawViewsCallback DGL.drawRect
			completeRedraw()
			ABORT = true	
		)
	)
	
	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
		checkButton ckb_plane "r" pos:[8,20] width:24 height:24 toolTip:"Rectangle"
		button btn_extrude "e" pos:[8,128] width:24 height:24 toolTip:"Extrude"
		spinner spn_snap "" pos:[12,340] width:48 height:16 range:[0,100,10] type:#float scale:0.1
		label lbl3 "Snap:" pos:[12,324] width:40 height:12
		on ckb_plane changed state do
		(
			if state do
			(
				ABORT = false
				DGL.snap_value = spn_snap.value
				try   (while not ABORT and not keyboard.escPressed do (startTool drawRectTool))  --numPoints:4
				catch (stopTool drawRectTool)
				ckb_plane.checked = false
			)
		)
		on btn_extrude pressed  do
		(

		)
		on spn_snap changed val do DGL.snap_value = val
		on sketch3DDialog close do
		(
			unregisterRedrawViewsCallback DGL.drawGuideLines
			unregisterRedrawViewsCallback DGL.drawRect
			ABORT = true
			stopTool drawRectTool
			completeRedraw()
		)
	)
	createDialog sketch3DDialog pos:[170,80] style:#(#style_toolWindow, #style_sysMenu)
)
     
 If anybody have some ideas to make it better, will be much appreciated :-)

#17

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.