GRREAD & Command Line options

GRREAD & Command Line options

StormyC
Advocate Advocate
1,255 Views
9 Replies
Message 1 of 10

GRREAD & Command Line options

StormyC
Advocate
Advocate

How do you use GRREAD to trap the clicking of command line options.

 

e.g. if you create a polyline using the command PLINE and select a start point you get command line options [Arc Halfwidth ....] etc and left clicking those options or typing the letter in blue results in the selection of that option.

 

I would like to replicate that for one of my own commands using Lisp... I have the code running that dispalys the options, traps keyboard presses etc. but can't get grread to kick out the option selected by left clicking it..... only the fact that the AutoCAD interface have been clicked. [ grread returns '(11 -1) ]

 

Any ideas?

0 Likes
1,256 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant

I don't have any bright ideas about getting that from (grread), but in some cases maybe you can look at what (getvar 'lastprompt) returns, which for non-command-ending options [such as, in the case of Polylines, options other than Enter or Close] should allow you to discern which option was chosen.

Kent Cooper, AIA
0 Likes
Message 3 of 10

Lee_Mac
Advisor
Advisor

Given that the ability to click keyword options has only been present in relatively recent versions of AutoCAD, and also the fact that the command-line may now be positioned anywhere floating on the screen, and furthermore given that the Vanilla AutoLISP API has not been developed since AutoCAD 2000, I don't think this functionality was ever implemented.

 

Lee

0 Likes
Message 4 of 10

dbroad
Mentor
Mentor

GRREAD is a very low-level interface.  If you need high-level user interaction, then consider (getpoint, getcorner, getint, getreal, getdist, getstring, or getkword).  These input functions allow command line options via (initget).  Otherwise, forget it.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 5 of 10

marko_ribar
Advisor
Advisor

Maybe, take a look into this topic...

 

http://www.theswamp.org/index.php?topic=48180.0

 

M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 6 of 10

stevor
Collaborator
Collaborator

You can get the key and button strokes,

and the current cursor coords,

with grread, in a loop,

but it will be much slower than with the mentioned high level inputs.

A simple example:

 

 ; input yes no
 (defun i_yn (qstr ynflg / tf nf it ig k) ;
  (princ (strcat qstr (if ynflg " N or < Y > " " Y or < N > ")))
  (while (and (setq it (car (setq ig (grread T)))) (/= 6 it )
              (setq ik (cadr ig)) ; key maybe
              (not (and (= 2 it) (or    ; key board
                (setq nf (or (= 110 ik)(= 78 ik) ) )
                (setq tf (or (= 121 ik)(= 89 ik) ) )
                (= 13 ik)   (= 32 ik) ) )  )
               (not (= it 11)) ) ) ; end while  ; mou R
   (setq ynflg (cond (nf nil) (tf t) (t ynflg) ) )
   (princ (if ynflg " Y " " N "))  ynflg ) ;

 

See:

http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-2484FFE3-95B3-4C2B-AF79-BE7772B07419

and others by google.

 

 

 

 

S
0 Likes
Message 7 of 10

StormyC
Advocate
Advocate

Thanks for your replies;

 

Kent1Cooper - nice idea, sadly doesn't work in this instance.

 

Lee - Seems you may be right...

 

dbroad -  I'm not sure i can get the same functionality by using those;  I have a list of points and I need to monitor the cursor location and draw a cross at the point thats closest to the cursor, update when the cursor moves and place an object on the closest point when left clicking. 

 

Marko - seems the poster in that thread has the same query as I and there isn't a solution posted yet.... but thanks.

 

Short of rewriting the entire routine in .net I'm still at a loss of how to achieve the command line selections...

0 Likes
Message 8 of 10

StormyC
Advocate
Advocate

Thanks stevor, im currently using that functionality - just wondered if the 'left click options' were available... but thanks.

0 Likes
Message 9 of 10

stevor
Collaborator
Collaborator
So much for the Quick Reply; 4 hours later and still not posted. Anyway, there are examples of the grread: http://www.theswamp.org/index.php?topic=12813.0 http://www.cadtutor.net/forum/showthread.php?36906-GrRead-Text-Editor... http://www.lee-mac.com/star.html Left mouse button, LM, seems to be key = 3 (defun c:grt ( / pgrl pvn gpl ) (redraw) (if (setq p1 (getpoint "\n Start Pt ")) (setq pvn p1 runf t vrd (/ (getvar 'viewsize) 20.0) )) (while runf (setq grl (grread t) kn (car grl) vn (cadr grl)) ; (princ"\n ")(prin1 grl) (cond ((and (= kn 5) (not (equal vn pvn vrd ))) (if pvn (grdraw vn pvn 1)) (setq gpl (cons vn gpl) pvn vn) ; (princ"\n ")(prin1 grl) ; (gr_Cdc pvn 2 2) ; in http://auscadd.com/free-lsp-1.html ) ((and (equal kn 2) ) (princ " 2 ")) ((and (equal kn 11) ) (princ " CM 11, value: ")(prin1 vn) ) ((and (equal kn 3) ) (princ "\n LM 3 ") ; Left (prin1 grl) (if (setq p2 (cadr grl)) (grdraw pvn p2 2)) ; (redraw) (gr_plc gpl 2) (gr_xdc pvn 1 1) (setq runf nil ) ) ((and (equal kn 25) ) (princ "\n RM 25 ")) ; or UpButtom in Command Box w/o a LM in it first ) ;(setq pgrl grl) ) (princ) ) (C:grt)))
S
0 Likes
Message 10 of 10

StormyC
Advocate
Advocate

Thanks Stevor

 

Cant really make much sense of that for my purposes.  ie command line option selection - I think Lee is likely to be correct. - thanks for the effort though.

0 Likes