Notifications
Clear all
[Closed] "SimpleManipulators"
Page 2 / 2
Prev
Nov 01, 2009 6:01 pm
I would like to do something like this:
but I dont know if is posible to make it
Nov 01, 2009 6:01 pm
“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
Nov 01, 2009 6:01 pm
- How to create a resizable base frame – progress: Done (thanks to Denis)
- Making Guide Lines (rulers) for position base – progress:80%
- posibility to snap base to guide line (ruler) –progress: -100%
- measuring: distance / angle
- slice surface
- straighten cut
- 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)
)
Nov 01, 2009 6:01 pm
- 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: 99% (thanks to Denis
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 :-)
Page 2 / 2
Prev