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

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12372
  • London, England
Re: Examples of usage GRREAD - let's share
« Reply #135 on: March 31, 2011, 08:45:15 AM »
Or

Code: [Select]
(cadr (ssgetfirst))

alanjt

  • Needs a day job
  • Posts: 5328
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #136 on: March 31, 2011, 08:49:13 AM »
Or

Code: [Select]
(cadr (ssgetfirst))
even better.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

pBe

  • Bull Frog
  • Posts: 377
Re: Examples of usage GRREAD - let's share
« Reply #137 on: March 31, 2011, 09:26:21 AM »
Or

Code: [Select]
(cadr (ssgetfirst))

Thats how i usually do it. My question really is, telling the object to recognize a lisp routine (not just "query" rouitines) while grips is "hot" , notice the command prompt when you pressed return it changes from ***stretch*** to ***move*** and so forth, i'm just wondering if grread might have a take on that.  anyhoo

thanks and nice thread btw


alanjt

  • Needs a day job
  • Posts: 5328
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #138 on: April 12, 2011, 11:58:16 AM »
Wrote a more practical one and thought I'd do a crappy GRREAD example:

Code: [Select]
(defun c:Test (/ _grAngle _ss2lst lst gr pt)

  (vl-load-com)

  (defun _grAngle (a b) (grdraw (trans a 0 1) (cadr gr) 1 -1) (angle a b))

  (defun _ss2lst (ss / i l)
    (if (eq (type ss) 'PICKSET)
      (repeat (setq i (sslength ss))
        (setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))
      )
    )
  )

  (if (setq lst (_ss2lst (ssget "_:L" '((0 . "INSERT")))))
    (while (eq 5 (car (setq gr (grread T 15 0))))
      (setq pt (trans (cadr gr) 1 0))
      (redraw)
      (foreach o lst (vla-put-rotation o (_grAngle (vlax-get o 'InsertionPoint) pt)))
    )
  )
  (redraw)
  (princ)
)

Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12372
  • London, England
Re: Examples of usage GRREAD - let's share
« Reply #139 on: April 12, 2011, 12:02:57 PM »
That looks fun!  :lol:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10386
Re: Examples of usage GRREAD - let's share
« Reply #140 on: April 12, 2011, 12:46:35 PM »
Interesting tool Alan. Not sure when I'd use it but you never know. 8-)
In the tool box it goes.
Thanks
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5328
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #141 on: April 12, 2011, 01:35:17 PM »
That looks fun!  :lol:
:-D

Interesting tool Alan. Not sure when I'd use it but you never know. 8-)
In the tool box it goes.
Thanks
Thanks Alan. :) I won't ever use it - no OSnaps. I just thought I'd do a fun one.

Code: [Select]
(defun c:RBP (/ ss pt)
  ;; Rotate Blocks to Point
  ;; Alan J. Thompson
  (if (and (setq ss (ssget "_:L" '((0 . "INSERT"))))
           (setq pt
                  (if (eq 1 (sslength ss))
                    (getpoint (trans (cdr (assoc 10 (entget (ssname ss 0)))) 0 1) "\nSpecify base point: ")
                    (getpoint "\nSpecify base point: ")
                  )
           )
      )
    ((lambda (p)
       (vlax-for x (setq ss (vla-get-activeselectionset
                              (cond (*AcadDoc*)
                                    ((setq *AcadDoc* (vla-get-activedocument
                                                       (vlax-get-acad-object)
                                                     )
                                     )
                                    )
                              )
                            )
                   )
         (vla-put-rotation x (angle (vlax-get x 'InsertionPoint) p))
       )
       (vla-delete ss)
     )
      (trans pt 1 0)
    )
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

kruuger

  • Swamp Rat
  • Posts: 616
Re: Examples of usage GRREAD - let's share
« Reply #142 on: April 12, 2011, 04:00:13 PM »
Wrote a more practical one and thought I'd do a crappy GRREAD example:

Code: [Select]
(defun c:Test (/ _grAngle _ss2lst lst gr pt)

  (vl-load-com)

  (defun _grAngle (a b) (grdraw (trans a 0 1) (cadr gr) 1 -1) (angle a b))

  (defun _ss2lst (ss / i l)
    (if (eq (type ss) 'PICKSET)
      (repeat (setq i (sslength ss))
        (setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))
      )
    )
  )

  (if (setq lst (_ss2lst (ssget "_:L" '((0 . "INSERT")))))
    (while (eq 5 (car (setq gr (grread T 15 0))))
      (setq pt (trans (cadr gr) 1 0))
      (redraw)
      (foreach o lst (vla-put-rotation o (_grAngle (vlax-get o 'InsertionPoint) pt)))
    )
  )
  (redraw)
  (princ)
)


haha, good stuff to learn mr. alanjt  :-)
kruuger

alanjt

  • Needs a day job
  • Posts: 5328
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #143 on: April 12, 2011, 04:36:31 PM »
haha, good stuff to learn mr. alanjt  :-)
kruuger
enjoy. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

pBe

  • Bull Frog
  • Posts: 377
Re: Examples of usage GRREAD - let's share
« Reply #144 on: April 15, 2011, 09:23:43 AM »
While trying out GRREAD, I notice cant snap to an object
is it possible to activate running osnap while in grread?


Code: [Select]
(defun c:test (/ CreateList _grAngle adoc Plines obj cnt ent ObjectPointList
           PtAngleList Xpoint gr NewLine
           )
;;; pBe April 2011 ;;;
  (vl-load-com)
  (defun CreateList (p) (setq ObjectPointList (cons (cdr p) ObjectPointList)))
;;; Alanjt ;;;
  (defun _grAngle (a b) (grdraw (trans a 0 1) (cadr gr) 1 -1) (angle a b))
;;;  ;;;
  (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
  (if (setq Plines (ssget ":L" '((0 . "LWPOLYLINE"))))
    (progn
      (repeat (setq cnt (sslength Plines))
        (setq obj (ssname Plines (setq cnt (1- cnt)))
          ent (entget obj))
        (mapcar
          'CreateList
          (vl-remove-if-not '(lambda (x) (= (car x) 10)) ent)
          )
        (ssdel obj Plines)
        )
      (if ObjectPointList
        (progn
;;; Alanjt ;;;
          (while (eq 5 (car (setq gr (grread T 15 0))))
            (setq Xpoint (trans (cadr gr) 1 0))
            (redraw)
            (foreach pts ObjectPointList (_grAngle pts Xpoint))
            )
;;;                  ;;;
          (redraw)
          (foreach
             itm ObjectPointList
            (setq
              NewLine
               (vla-addline
                 (vlax-get (vla-get-activelayout adoc) 'Block)
                 (vlax-3d-point Xpoint)
                 (vlax-3d-point itm)
                 )
              )
            )
          )
        )
      )
    )
  (princ)
  )

Thanks

Lee Mac

  • Seagull
  • Posts: 12372
  • London, England
Re: Examples of usage GRREAD - let's share
« Reply #145 on: April 15, 2011, 09:25:40 AM »
OSnap, Ortho, Tracking, DynamicInput, etc aren't available when using grRead, instead one must attempt to 'imitate' them:

http://www.theswamp.org/index.php?topic=12813.msg157794#msg157794

pBe

  • Bull Frog
  • Posts: 377
Re: Examples of usage GRREAD - let's share
« Reply #146 on: April 15, 2011, 09:30:25 AM »
Thanks Lee
 :-)

alanjt

  • Needs a day job
  • Posts: 5328
  • Standby for witty remark...
Re: Examples of usage GRREAD - let's share
« Reply #147 on: April 18, 2011, 04:12:13 PM »
Elevation label :)

Textstring field changes when elevation of text object is changed - the object field references itself.



Code: [Select]
(defun c:ZLBL (/ pt txt pt2 gr ang)
  ;; Alan J. Thompson, 04.18.11
  (vl-load-com)
  (if
    (and (setq pt (getpoint "\nSpecify point: "))
         (setq txt (vla-addMText
                     (vlax-get-property
                       (cond (*AcadDoc*)
                             ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
                       )
                       (if (eq 1 (getvar 'cvport))
                         'PaperSpace
                         'ModelSpace
                       )
                     )
                     (setq pt2 (vlax-3d-point (trans pt 1 0)))
                     0.
                     ""
                   )
         )
    )
     (progn
       (vla-put-textstring
         txt
         (strcat "%<\\AcObjProp Object(%<\\_ObjId "
                 (itoa (vla-get-objectID txt))
                 ">%).InsertionPoint \\f \"%lu2%pt4%pr2\">%"
         )
       )
       (vla-regen *AcadDoc* acActiveViewport)
       (while (eq 5 (car (setq gr (grread T 15 0))))
         (mapcar
           (function (lambda (p v) (vlax-put-property txt p v)))
           '(Rotation AttachmentPoint InsertionPoint)
           (if (or (<= (setq ang (angle pt (cadr gr))) (/ pi 2.)) (>= ang (* pi 1.5)))
             (list ang 4 pt2)
             (list (+ pi ang) 6 pt2)
           )
         )
       )
     )
  )
  (princ)
)
« Last Edit: April 18, 2011, 04:54:30 PM by alanjt »
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

chlh_jd

  • Guest
Re: Examples of usage GRREAD - let's share
« Reply #148 on: April 26, 2011, 09:23:22 AM »
Hi all , here is a new to use Left (+1) and Right (-1)  mouse button .
how can we changed into mousewheel method forward or backward scroll ?
Code: [Select]
(defun c:test (/ en ent str pt)
  (if (and (setq en (car (entsel "Select Integer Number Text :")))
   (setq ent (entget en))
   (setq str (cdr (assoc 1 ent)))
   (numberp (eval (read str)))
   (equal (atoi str) (atof str))
      )
    (while (and (setq pt (grread t 4 2))
  (not (and (= 2 (car pt))
    (or (= 13 (cadr pt)) (= 32 (cadr pt)))
       )
  ) ;_Enter Space
     )
(cond ((= (car pt) 3);_Mouse Left button
       (setq str (rtos (1+ (atoi str)) 2 0))
       (setq ent (subst (cons 1 str) (assoc 1 ent) ent))
       (entmod ent)
       )
      ((or (= (car pt) 11) (= (car pt) 25));_Mouse Right button
       (setq str (rtos (1- (atoi str)) 2 0))
       (setq ent (subst (cons 1 str) (assoc 1 ent) ent))
       (entmod ent)
       )
      )
    )
    (princ)
  )
  (princ)
)

chlh_jd

  • Guest
Re: Examples of usage GRREAD - let's share
« Reply #149 on: April 26, 2011, 09:25:02 AM »
 is
Code: [Select]
(grread 1 13 1) can be used ?
« Last Edit: April 26, 2011, 09:35:43 AM by chlh_jd »