Author Topic: CursorCoodinates with Choicemenu  (Read 3165 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
CursorCoodinates with Choicemenu
« on: November 05, 2014, 10:18:45 AM »
Hello!
I try to do a request routine which can show me cursorCoordinates solong I take a choice, in my example 1 - 2 - 3 or 4
If I enter keys 1 - 2 - 3 or 4 it works but I want It is going by pressing with mouse in commandline too. How can I do that or not ?!
Code: [Select]
(defun c:foo()
 (setq cText
(entget
  (ssname
    (ssget "X"
   (entmake (list (cons 0 "TEXT") (cons 1 "TEST") (cons 7 "Standard")(cons 8 "0")(cons 10 '(0 0 0))(cons 40 0.001)(cons 62 7))))
    0
    )
  )
       )
 (princ "\nTake a choice! [1/2/3/4]: ")
  (while (setq drag (grread t 4 0))
    (if (/= (type (setq a (cadr drag))) 'LIST)
      (cond
        ((= a 49)
         (alert "select 1")
         )
        ((= a 50)
         (alert "select 2")
         )
        ((= a 51)
         (alert "select 3")
         )
        ((= a 52)
         (alert "select 4")
         )
)
      (progn
(setq cText
       (subst (cons 10 (cadr drag))
      (assoc 10 cText)
      (subst (cons 1 (strcat "Coord:" (vl-princ-to-string (cadr drag))))
     (assoc 1 cText)
     (subst (cons 40 (* 1 (/ (getvar 'VIEWSIZE) 100) (/ (car (getvar "SCREENSIZE")) (cadr (getvar "SCREENSIZE" )))))
    (assoc 40 cText)
    cText
    )
     )
      )
      )
(entmod cText)
)
      )
    )
  )

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: CursorCoodinates with Choicemenu
« Reply #1 on: November 06, 2014, 09:28:30 AM »
If I type:
Code: [Select]
(progn
  (princ "\nTake a choice! [1/2/3/4]: ")
  (while (setq code_12 (grread (setq code (grread))))
    (princ (strcat "\t" (vl-princ-to-string code)))
    (princ (strcat " " (vl-princ-to-string  code_12)))
    )
  )
and click in the commandline 1 - 2 - 3 or 4, it appears (11 -1).
What means (11 -1), I didnīt find that in help by AUXmenu ?!
« Last Edit: November 06, 2014, 09:35:43 AM by cadplayer »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: CursorCoodinates with Choicemenu
« Reply #2 on: November 06, 2014, 10:14:44 AM »
I don't know what do you want to accomplish with 1-2-3-4 options... I would personally decide between (grread) and (getkword)... You can force (grread) to accept choice output 11 code and pass that code to temporarily stop (grread) and invoke (getkword), so that after you double click output would be "1", "2", "3", or "4" and when that happens turn back (grread) on and process condition for selected option, just like you typed 1,2,3 or 4 while (grread) is active...

Not tested, but according to your post, this should function... Just thinking humbly...
HTH
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: CursorCoodinates with Choicemenu
« Reply #3 on: November 06, 2014, 11:45:25 AM »
What I meant was actually something like this...

Code: [Select]
(defun c:foo ( / cText drag a b )
  (setq cText (entget (entmakex (list (cons 0 "TEXT")
                                      (cons 1 "TEST")
                                      (cons 7 "Standard")
                                      (cons 8 "0")
                                      (cons 10 '(0 0 0))
                                      (cons 40 0.001)
                                      (cons 62 7)
                                )
                      )
              )
  )
  (princ
    "\nTake a choice with keyboard or double click with mouse! [1/2/3/4]: "
  )
  (while (setq drag (grread t 4 0))
    (if (or (/= (type (setq a (cadr drag))) 'LIST)
            (= (car drag) 11)
            b
        )
      (cond
        ((or (= a 49) (= b "1")) (setq b nil) (alert "select 1"))
        ((or (= a 50) (= b "2")) (setq b nil) (alert "select 2"))
        ((or (= a 51) (= b "3")) (setq b nil) (alert "select 3"))
        ((or (= a 52) (= b "4")) (setq b nil) (alert "select 4"))
        (t
         (initget 1 "1 2 3 4")
         (setq b (getkword))
         (princ
           "\nTake a choice with keyboard or double click with mouse! [1/2/3/4]: "
         )
        )
      )
      (progn (setq cText
                    (subst
                      (cons 10 (cadr drag))
                      (assoc 10 cText)
                      (subst
                        (cons
                          1
                          (strcat "Coord:" (vl-princ-to-string (cadr drag)))
                        )
                        (assoc 1 cText)
                        (subst (cons 40
                                     (* 1
                                        (/ (getvar 'VIEWSIZE) 100)
                                        (/ (car (getvar "SCREENSIZE"))
                                           (cadr (getvar "SCREENSIZE"))
                                        )
                                     )
                               )
                               (assoc 40 cText)
                               cText
                        )
                      )
                    )
             )
             (entmod cText)
      )
    )
  )
  (princ)
)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: CursorCoodinates with Choicemenu
« Reply #4 on: November 06, 2014, 11:49:46 AM »
@ cadplayer:
Not the answer to your question, but what is wrong with AutoCAD's built-in coordinate display?

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: CursorCoodinates with Choicemenu
« Reply #5 on: November 07, 2014, 01:54:14 AM »
Thank you both and Marko for your nicely work.
@roy
Itīs only a simple example for using commandline-menu inside grread with clicking mouse.
@Marko
You have understood me correctly and it works.
A question is, why is not so easy to do that with one-click with mouse in commandline.
Quote
(progn
  (princ "\nTake a choice! [1/2/3/4]: ")
  (while (setq code (grread))
    (princ (strcat "\t" (vl-princ-to-string code)))
    )
  )
By clicking in commandline only (11 -1). That means if I understood accurate AUX-menu-item is not definition correctly ?! It can be only a positiv value to locate mouse exactly. Is it a bug in grread ?!