View Full Version : Dynamic Object Creation - Cursor Shadowing
pnorman
2005-05-12, 09:07 PM
I have an existing lisp macro but would like to add some command line features like the Detail Component Manager.
How can I create say a closed LWPOLYLINE and have it follow the cursor until the user pics a point?
I know how to code for the polyline just not for the hover with cursor part.
(I also know how to use initget and getpoint etc).
If anyone can point me in the right direction that would be great. Don't worry about lots of code, just some clues would be good.
Here's an example:
(initget "Top Middle Bottom Options")
(setq P1 (getpoint "nInsert point or [Top/Middle/Bottom](Options...): "))
So if the user enters T, M, or B the image of the polyline would change accordingly but not be placed into the drawing until they actually pic a point. Also if they enter "O" they will be sent back to a dialog box (I know how to do the dialog part)
Here's my logic:
1: define polyline shape (but do not insert)
2: run getpoint with polyline shadowing cursor
3: modify cursor shadow after T, M or B input
4: place polyline only if P1 is a pick point (I can probably work this out too)
I know how to do all the if/while etc its just the shadow/hover cursor part I don't know?!
Thanks
PS I am VBA illiterate!! Yes I know, time to get with the program! :)
PSS Is that really too much to ask! http://forums.augi.com/images/icons/icon11.gif
RobertB
2005-05-12, 10:26 PM
Look at the (grvecs) in conjunction with (grread). Bone up on matrices.
kennet.sjoberg
2005-05-12, 11:04 PM
create the polyline, then use the move command that pause for the user pic
and erase entlast if necessary
: ) Happy Computing !
kennet
pnorman
2005-05-12, 11:13 PM
Ok Thanks Robert, but!...
So before using:
(command "_.pline" P1 "_w" "0" "" P2 P3 "_a" P4 "_l" P5 "_a" P6 "_l" P7 "_a"............
to draw the polyline,
I use grvecs to create an image of the pl with grread to define P1 and a matrix to supply P2, P3 etc....??? or something like that??
What about arcs in grvecs?
Is there much benefit in using a "vl" function to draw the polyline?
Thanks
pnorman
2005-05-12, 11:16 PM
Thanks kennet, I had thought of that but feel that method is a bit messy and would require a lot more cleaning up and error checking. Am looking for an alternative if I can find one.
Appreciate the input.
kennet.sjoberg
2005-05-12, 11:34 PM
Yes You are probably right
(command "_.UNDO" "BEgin" )
(command "_.pline" P1 "_w" "0" "" P2 P3 "_a" P4 "_l" P5 "_a" P6 "_l" P7 "_a"............
(command "._move" (entlast) "" P1 "pause" )
(command "_.UNDO" "End" )
(command "_.U" )
(if (= (getvar "LASTPOINT" ) ...P8
: ) Happy Computing !
kennet
scwegner
2005-05-12, 11:53 PM
How about acet-ss-drag-move?
pnorman
2005-05-13, 12:01 AM
How about acet-ss-drag-move?http://forums.augi.com/images/icons/icon5.gif
What about it? do you mean the lisp code?
Help me find it...???
Thanks
scwegner
2005-05-13, 12:24 AM
http://forums.augi.com/images/icons/icon5.gif
What about it? do you mean the lisp code?
Help me find it...???
Thanks It's one of the express tool utility functions that you should have. Basically, if you use that instead of getpoint, it shows the ghost of what you're moving while you select a point. The syntax would be something like:
(setq endpt (acet-ss-drag-move ss basept "\nWhere you want it, yo?" 0))
There's also acet-ss-drag-rotate and acet-ss-drag-scale. AfraLISP (http://www.afralisp.com/lisp/acet-utils.htm) has a full description of all of them. As kennet pointed out, you can fake it with move, but there really isn't a substitute for scale.
pnorman
2005-05-13, 12:28 AM
Look at the (grvecs) in conjunction with (grread). Bone up on matrices.Am I right in assuming that osnaps won't work while grread is running?
scwegner
2005-05-13, 12:34 AM
Am I right in assuming that osnaps won't work while grread is running?
Right. Which is one of the many reasons people tend to avoid it.
pnorman
2005-05-13, 12:37 AM
And (setq endpt (acet-ss-drag-move ss basept "\nWhere you want it, yo?" 0)) doesn't actually move "ss" so I would need:
(if endpt (command "move" SS "" basept endpt))
Right?
scwegner
2005-05-13, 12:46 AM
And (setq endpt (acet-ss-drag-move ss basept "\nWhere you want it, yo?" 0)) doesn't actually move "ss" so I would need:
(if endpt (command "move" SS "" basept endpt))
Right?
Right -all it does is add the ghosted image while you select a point. It has it's advantages though. With acet-ss-drag-move you don't have to worry about cmdecho issues and it leaves you with a point variable which you may want later on. Like I said, it's not the only way for moving things, but it is the only option for scaling.
pnorman
2005-05-13, 12:56 AM
Right -all it does is add the ghosted image while you select a point. It has it's ....Very nice function!
But correct me if I'm wrong: I would still have to draw the polyline, add it to selection set "ss" and then use acet-ss-drag-move, and if the user cancels or does not pick a point I would have to delete the original polyline.
I was wondering if there was a way to do it by defining the pl directly at the cursor (like an insert).
I don't want the rubber band line drawn by acet-ss-drag-move
Try inserting a CISC W610x113 (section) from the Detail component Manager (ADT 2005) and you will see what I mean.
Thanks
PS (if I use move I will get the rubber band line also :( )
PSS Can I get the code for acet-ss-drag-move and edit it to suit?
scwegner
2005-05-13, 01:23 AM
But correct me if I'm wrong: I would still have to draw the polyline, add it to selection set "ss" and then use acet-ss-drag-move, and if the user cancels or does not pick a point I would have to delete the original polyline.
I was wondering if there was a way to do it by defining the pl directly at the cursor (like an insert). I don't know of a way to avoid drawing it first if you want to be able to see it. Remember that when you do insert, you're not defining it "at the cursor" -it's defined in another file. User cancelling out should be taken care of by your error handler -just include an undo.
I don't want the rubber band line drawn by acet-ss-drag-move
Try inserting a CISC W610x113 (section) from the Detail component Manager (ADT 2005) and you will see what I mean. I can't. I'm using old-school vanilla 2000i. But you can get rid of the rubberband, change highlighting, etc. to however you want it. Rubberbanding is controlled by the presence of a 0, 1, or 2 after the prompt in the acet-ss-drag-move syntax (read that AfraLISP description). Redraw can help you deal with the display of the selected objects. Try this example to give you an idea:
(defun c:test ()
(setq ss (ssget))
(setq pt (getpoint "\nSpecify basepoint: "))
(setq count -1)
(repeat (sslength ss) (redraw (ssname ss (setq count (1+ count))) 2))
(setq pt2 (acet-ss-drag-move ss pt "Specify new point: "))
(command "move" ss ""pt pt2)
(setq count -1)
(repeat (sslength ss) (redraw (ssname ss (setq count (1+ count))) 4))
(princ)
)
PSS Can I get the code for acet-ss-drag-move and edit it to suit? Haven't a clue. I know squat about arx.
This may not be worthwhile for you but I'm just trying to give you as many options as possible. Obviously, using Kennet's suggestion would be far simpler.
pnorman
2005-05-13, 03:01 AM
Thanks scwegner.
That's certainly a step in the right direction.
I appreciate the help.
If only I knew how to write the code for "acet-ss-drag-move" myself.
I will let you know how I get on.
RobertB
2005-05-13, 03:47 AM
Am I right in assuming that osnaps won't work while grread is running?Correct. Sorry that it didn't address your additional requirements.
RobertB
2005-05-13, 03:59 AM
But correct me if I'm wrong: I would still have to draw the polyline, add it to selection set "ss" and then use acet-ss-drag-move, and if the user cancels or does not pick a point I would have to delete the original polyline.
I was wondering if there was a way to do it by defining the pl directly at the cursor (like an insert).
I don't want the rubber band line drawn by acet-ss-drag-move
A simple error handler can clean up the mess if the user cancels.
To avoid the rubberband: (acet-ss-drag-move ss myPt "\nMerrily dragging: ")
pnorman
2005-05-13, 04:16 PM
Thanks everyone. Give me a few days and I will post what I come up with.
Cheers
Phill
http://forums.augi.com/images/icons/icon14.gif
PS Would it be unwise to rely on the future existance/availability of acet-ss-drag-move?
RobertB
2005-05-13, 08:34 PM
PS Would it be unwise to rely on the future existance/availability of acet-ss-drag-move?For a commercial app, yes. For your own shop, you ought to be ok.
CAB2k
2005-05-13, 10:56 PM
;;; MOCOROSC.lsp
;;; Move, Copy, Rotate, Scale the selection set.
;;;
;;; This routine makes use of the express tools routines acet-ss-drag-move,
;;; acet-ss-drag-rotate, acet-ss-drag-scale, found in "acetutil.arx" and
;;; assumes it has been loaded with (arxload "acetutil").
;;; Parameters passed to this routine are the selection set of objects and
;;; a base point. Nothing is returned by this routine.
;;;
(defun mocorosc (ss p1 / na p2 n d p lst j p3)
(setq p2 t)
(setq n 0)
;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
;; Main Loop
;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
(while p2
(setq na (entlast))
(if (not lst)
(setq lst (list (list ss p1)))
) ;if
(setvar "lastpoint" p1)
(acet-ss-redraw ss 3)
(initget 128 "Rotate Scale Base Undo eXit")
(setq p2 (acet-ss-drag-move
ss
p1
"\nSecond point or \n[Rotate/Scale/Base/Undo] <exit>: "
nil
) ;acet-ss-drag-move
) ;setq
(acet-ss-redraw ss 4)
;; if p2 is a point a copy is made
(if (= p2 "eXit")
(setq p2 nil)
) ;if
(cond
((= p2 "Undo")
(if (= n 0)
(princ "\nNothing to undo.")
(progn
(command "_.undo" "1")
(setq n (- n 1)
lst (cdr lst)
ss (car lst)
p1 (cadr ss)
ss (car ss)
) ;setq
) ;progn else
) ;if
) ;cond #1
;;=================== SCALE ======================
((= p2 "Scale")
(initget 128 "Rotate Scale Base Undo eXit")
(setq p2 (acet-ss-drag-scale
ss
p1
"\nSecond point or \n[Rotate/Scale/Base/Undo] <exit>: "
nil
) ;acet-ss-drag-move
) ;setq
(if (= (type p2) 'real)
(progn
(command "_.scale" ss "" p1 p2)
(setq n (+ n 1)
lst (cons (list ss p1) lst)
) ;setq
)
)
) ;cond #2
;;=================== COPY ======================
((equal 'list (type p2))
(command "_.copy" ss "" p1 p2)
(setq n (+ n 1)
ss (acet-ss-new na)
p1 p2
lst (cons (list ss p1) lst)
) ;setq
) ;cond #3
;;=================== ROTATE ======================
((= p2 "Rotate")
(initget 128 "Rotate Scale Base Undo eXit")
(setq p2 (acet-ss-drag-rotate
ss
p1
"\nSecond point or \n[Rotate/Scale/Base/Undo] <exit>: "
nil
) ;acet-ss-drag-move
) ;setq
(if (= (type p2) 'real)
(progn
(command "_.rotate" ss "" p1 (* 180.0 (/ p2 pi)))
(setq n (+ n 1)
lst (cons (list ss p1) lst)
) ;setq
)
)
) ;cond #4
;;=================== BASE ======================
((= p2 "Base")
(setq p (getpoint "\nPick a new Base Point."))
(if (and p (= (type p) 'list))
(setq p1 p
n (+ n 1)
lst (cons (list ss p1) lst)
)
)
) ;cond #5
;;=================== ERROR ======================
(p2
(princ "\nInvalid input.")
) ;cond #6
) ;cond close
) ;while
;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
) ;defun acet-copym
;|
(defun c:test (/ ss p)
(prompt "\nSelect objects:")
(if (and (setq ss (ssget))
(setq p (getpoint "\Pick base point:"))
)
(mocorosc ss p)
)
(princ)
)
|;
pnorman
2005-05-17, 01:56 AM
Well here's what I have come up with. It's only an excerpt from the whole program.
Seems to be working fine so far. Thanks to all for their help.
(unload_dialog PPN_DCL_ID)
(if (= WHAT_NEXT 1)
(progn
(ppn_getdata (car *PPN_COMPID*) (cadr *PPN_COMPID*)) ;get the section data
(setq SP (getvar "VIEWCTR") P1 SP)
(ppn_draw_wf_s SP) ;draw the polyline
(setq OBJ1 (vlax-ename->vla-object (entlast)))
(setq SS (ssget "L"))
(redraw (ssname SS 0) 2)
(setq INSPT nil)
(while (/= (type INSPT) 'LIST)
(initget "T M B O")
(setq INSPT (acet-ss-drag-move SS P1 "\nInsert point or [Top/Middle/Bottom](Options...): "))
(cond
((= INSPT "T")
(setq P1 (list (car SP) (+ (cadr SP) D) (caddr SP)))
)
((= INSPT "M")
(setq P1 (list (car SP) (+ (cadr SP) (/ D 2.00)) (caddr SP)))
)
((= INSPT "B")
(setq P1 SP)
)
((= INSPT "O")
(setq WHAT_NEXT 2 INSPT '(0 0)) ;exit loop & return to dialog
(vla-delete OBJ1)
)
)
)
(if (/= WHAT_NEXT 2)(vla-move OBJ1 (vlax-3d-point P1) (vlax-3d-point INSPT)))
)
)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.