[Closed] Done startObjectCreation
So I’m using the startObjectCreation method of a plane so that the user can drag out a plane. But after its done I’d like to edit it, problem I’m having is that when I call the startObject it immediately does the rest of whats in the function, and if I use the isCreatingObject it will run past it because at the time there is something being created. Is there a way to call a function as soon as the plane is finished being placed?
The code I’m using:
on dragBt pressed do
(
getBitmap("drag")
maxOps.autogrid = autoGridCb.state
picture_Frame = startObjectCreation plane returnNewNodes:#first newNodeCallback:setPlaneProps
if not (isCreatingObject()) then
(
print "its in"
extrudeFrame()
)
-- picture_Frame.length = (picture_Frame.width * (in_bitmap.height / in_bitmap.width)) as float
)
I’m also trying to apply an image’s size ratio to the size of the plane, but this isn’t working at the moment because its saying the plane’s width is an invalid command, hence the last line of commented out code.
Any help would be greatly appreciated
Thanks
D3Mi
Anybody have any ideas?
As an update I’ve tried mouse tools and mouse track and neither seem to be able to function at the same time the drag tool is functioning. I also tried a loop that stopped the code from progressing while isCreatingObject() is true but that just crashed everything… so I’m kind of out of ideas at the moment. Any help would be greatly appreciated.
here is how to do this kind of things:
try(destroydialog planeBuilder) catch()
rollout planeBuilder "Plane Builder by denisT" width:200
(
spinner ratio_sp "Ratio: " range:[0.0001, 1e9, 2] type:#float fieldwidth:56 align:#right offset:[4,0]
spinner widthsegs_sp "Width Segs: " range:[1, 1e9, 1] type:#integer fieldwidth:56 align:#right offset:[4,4]
spinner lengthsegs_sp "Length Segs: " range:[1, 1e9, 1] type:#integer fieldwidth:56 align:#right offset:[4,-2]
checkbutton start_bt "Start Creation" width:182 align:#right offset:[4,0]
local p, planes = #()
tool build
(
on mousePoint click do case click of
(
1: p = plane pos:worldPoint width:0 height:0 widthsegs:widthsegs_sp.value lengthsegs:lengthsegs_sp.value
default: #stop
)
on mouseMove click do case click of
(
default:
(
p.width = (p.length = gridDist.y) * ratio_sp.value
)
)
)
on start_bt changed state do if state do undo "Build" on
(
start_bt.enabled = off
planes = #()
while (starttool build) == #stop do
(
if isvalidnode p do append planes p
)
select (planes = for p in planes where isvalidnode p collect p)
start_bt.enabled = not (start_bt.state = off)
)
)
createdialog planeBuilder
delete objects
ps. use RightClick to stop creation
Thanks for the reply. Is there any way to call the end of a drag? I need to create one at a time and then run some code immediately after creation. Or I found another way too, using the startObjectCreation and its working pretty well. You have to right click to stop the drag though, is there a method to stop object creation?
do you see “while” loop in my code? inside there you can do whatever you want with last created plane (in our case it’s the value of the variable “p”).
why not? i made it for multiple creation… if you don’t need it just remove “while” loop
on start_bt changed state do if state do undo "Build" on
(
start_bt.enabled = off
if (starttool build) == #stop and isvalidnode p do select p
start_bt.enabled = not (start_bt.state = off)
)
also do you see the line
default: #stop
?
it might be used do something finally. like:
default:
(
p.name = "p_" + timestamp() as string
#stop
)