Author Topic: Examples of usage GRREAD - let's share  (Read 200461 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #120 on: March 14, 2011, 08:52:18 AM »
Excellent , Alan ! :-)
You have used the better method grdraw to show middle routine . I can learn a lot from your code
Enjoy. I had a bit of fun writing it.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

GDF

  • Water Moccasin
  • Posts: 2081
Re: Examples of usage GRREAD - let's share
« Reply #121 on: March 14, 2011, 03:16:32 PM »
Excellent , Alan ! :-)
You have used the better method grdraw to show middle routine . I can learn a lot from your code
Enjoy. I had a bit of fun writing it.

Nice routine.

To activate the PW command grread function, I have to hit the space bar after selecting the polyline.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #122 on: March 14, 2011, 03:19:46 PM »
Excellent , Alan ! :-)
You have used the better method grdraw to show middle routine . I can learn a lot from your code
Enjoy. I had a bit of fun writing it.

Nice routine.

To activate the PW command grread function, I have to hit the space bar after selecting the polyline.
Thanks.
Yes, it allows for multiple LWPolyline selection, so you have to right-click/enter/spacebar after selecting all desired LWPolylines.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Pad

  • Bull Frog
  • Posts: 342
Re: Examples of usage GRREAD - let's share
« Reply #123 on: March 15, 2011, 04:54:59 AM »
Thanks for the two leader arrow routines Alan.  Very useful.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #124 on: March 15, 2011, 08:45:58 AM »
Thanks for the two leader arrow routines Alan.  Very useful.
Enjoy.  :-)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #125 on: March 30, 2011, 10:51:50 AM »
Similar to the new option to 2011 or being able to TAB through a list of ENames like one can TAB through different usable OSnaps in an area.

Code: [Select]
(defun AT:CycleThroughENames (lst / l n i g e)
  ;; Cycle through a list of ENames to choose one
  ;; lst - list of ENames
  ;; Alan J. Thompson, 03.29.11
  (if (>= (setq l (length lst)) 2)
    (progn
      (princ "\n<Tab> to cycle through entities: ")
      (redraw (setq i (nth (setq n 0) lst)) 3)
      (while (progn (setq g (grread nil 10))
                    (cond ((equal g '(2 9))
                           (redraw i 4)
                           (redraw (setq i (nth (setq n (rem (1+ n) l)) lst)) 3)
                           T
                          )
                          ((or (member g '((2 32) (2 13))) (eq (car g) 25)) (redraw (setq e i) 4))
                          (T (redraw i 4))
                    )
             )
      )
      e
    )
    (car lst)
  )
)

EDIT: Minor change to follow a suggestion by Lee.

Test subroutines (and a quick sub to convert the selection set to a list):
Code: [Select]
(defun ss->lst (ss / i l)
  (if (eq (type ss) 'PICKSET)
    (repeat (setq i (sslength ss)) (setq l (cons (ssname ss (setq i (1- i))) l)))
  )
)

(defun c:Test (/ ent)
  (if (setq ent (AT:CycleThroughENames (ss->lst (ssget))))
    (sssetfirst nil (ssadd ent))
  )
  (princ)
)

(defun c:Test2 (/ pt ent)
  (if (and (setq pt (getpoint "\nSpecify point: "))
           (setq ent (AT:CycleThroughENames (ss->lst (ssget "_C" pt pt))))
      )
    (sssetfirst nil (ssadd ent))
  )
  (princ)
)

« Last Edit: March 30, 2011, 12:07:52 PM by alanjt »
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Examples of usage GRREAD - let's share
« Reply #126 on: March 30, 2011, 11:18:57 AM »
Nice one Alan :-) It reminds me of a snippet I posted here  :-)

Looking back at it, it could probably be shortened to just:

Code: [Select]
(defun c:msel ( / ss i l )
  (and
    (setq ss (ssget))
    (setq i -1 l (sslength ss))
    (princ "\nPress Tab to Cycle Through Selection <Exit>: ")
    (while (= 9 (cadr (grread nil 10))) (sssetfirst nil (ssadd (ssname ss (setq i (rem (1+ i) l))))))
  )
  (princ)
)
« Last Edit: March 30, 2011, 11:27:26 AM by Lee Mac »

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #127 on: March 30, 2011, 11:58:00 AM »
Quote
(rem (1+ i) l)
Clever. :kewl: You've proved me useless.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Examples of usage GRREAD - let's share
« Reply #128 on: March 30, 2011, 12:19:50 PM »
Quote
(rem (1+ i) l)
Clever. :kewl: You've proved me useless.

Thanks Alan  8-)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #129 on: March 30, 2011, 02:11:21 PM »
These would probably make more sense. I was getting caught up in worrying with it only returning an EName if the user right-clicked, hit enter or the spacebar, but that's kind of silly. If they selected the objects, they're bound to want to, regardless...

Code: [Select]
(defun AT:CycleThroughENames (lst / l i n)
  (if (>= (setq l (length lst)) 2)
    (progn (princ "\n<Tab> to cycle through entities: ")
           (redraw (setq i (nth (setq n 0) lst)) 3)
           (while (eq (cadr (grread nil 10)) 9)
             (mapcar 'redraw (list i (setq i (nth (setq n (rem (1+ n) l)) lst))) '(4 3))
           )
           (redraw i 4)
           i
    )
    (car lst)
  )
)



(defun AT:CycleThroughSS (ss / l i e)
  (if (eq (type ss) 'PICKSET)
    (if (eq (setq l (sslength ss)) 1)
      (ssname ss 0)
      (progn (princ "\n<Tab> to cycle through entities: ")
             (redraw (setq e (ssname ss (setq i 0))) 3)
             (while (eq (cadr (grread nil 10)) 9)
               (mapcar 'redraw (list e (setq e (ssname ss (setq i (rem (1+ i) l))))) '(4 3))
             )
             (redraw e 4)
             e
      )
    )
  )
)

Thanks for the example to put my head on a little straighter, Lee.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Examples of usage GRREAD - let's share
« Reply #130 on: March 31, 2011, 07:33:44 AM »
Nice one Alan, you're welcome :-)

pBe

  • Bull Frog
  • Posts: 402
Re: Examples of usage GRREAD - let's share
« Reply #131 on: March 31, 2011, 08:13:22 AM »
Question:

Can grread retrieve infos from a "gripped" object?



Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Examples of usage GRREAD - let's share
« Reply #132 on: March 31, 2011, 08:28:21 AM »
Can grread retrieve infos from a "gripped" object?

What 'infos' would you be looking to retrieve?

grread is simply a function to monitor user input.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #133 on: March 31, 2011, 08:33:23 AM »
Question:

Can grread retrieve infos from a "gripped" object?



You can select the 'gripped' object with (ssget "_I") and extract info from there.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

pBe

  • Bull Frog
  • Posts: 402
Re: Examples of usage GRREAD - let's share
« Reply #134 on: March 31, 2011, 08:40:44 AM »
You can select the 'gripped' object with (ssget "_I") and extract info from there.

grread is simply a function to monitor user input.

I understand, just wondering that's all  :-)

Thank you gentlemen