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

0 Members and 2 Guests are viewing this topic.

danallen

  • Guest
Re: Examples of usage GRREAD - let's share
« Reply #225 on: June 01, 2014, 08:57:37 AM »
I'm in agreement that stripping headers and posting someone else's routines in your code in multiple forums is pretty much stealing / taking credit (and extremely ungrateful) for someone else's work. When I grab code from forums and the author didn't bother to put in headers, I still make the effort to provide credit by referencing their username and url/thread the post was in.

Dan

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Examples of usage GRREAD - let's share
« Reply #226 on: June 01, 2014, 09:51:12 AM »
As a person who doesn't do any coding, I still understand the that the written
or unwritten "Honour Code" of coding has always been to give credit to the
ORIGINATOR of the code.

True there could be a tactful way to to bring this up; however is the person
that is engaged in this activity being tactful?  Do they deserve the courtesy
that they themselves fail to extend?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

ribarm

  • Water Moccasin
  • Posts: 2335
  • Marko Ribar, architect
Re: Examples of usage GRREAD - let's share
« Reply #227 on: June 01, 2014, 10:02:09 AM »
I've pointed the credits to Lee's codes that were used, but I suppose that for the codes I and reltro posted the credits should be ours... I just used Lee's subfunctions like I said to make main functions more useful... If you continue to insult me and others that attempt to make this forum better than you shouldn't be using www at all... The main point of www is to make all the people support each other and not the opposite... I've changed my postings of codes to the point I thought will don't discredit anyone in any way... I thought Lee would be happy to see that his subfunctions are used in many situations and now I find that this was just opposite... I sincerely think I shouldn't post anything I did, specially for the people like those that are selfish and not willing to show their gratitude to us that are posting and sharing codes for free... I won't stand back like I did before as I see now that I was wrong. I don't know why Lee Mac is sharing his knowledge if he isn't willing to accept the fact that it would be used for learning and using it in practical and theoretical ways... I am really greatly disappointed in Lee's way of providing help and in many others that are supporting this kind of attitude... I don't care if someone would use my codes in any way as I never make programs that are harmful in any way, further more I would be glad to see it it was used as I am sure the purpose would be totally beneficial and correct...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MP

  • Seagull
  • Posts: 17631
Re: Examples of usage GRREAD - let's share
« Reply #228 on: June 01, 2014, 10:03:51 AM »
Jeez, don't go hyperbolic John, no one's advocating that kind of dialog as normal exchange. Lee's response was appropriate in this context.

How about being as adamant that participants should do their very best to attribute code?
« Last Edit: June 01, 2014, 10:26:56 AM by MP »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17631
Re: Examples of usage GRREAD - let's share
« Reply #229 on: June 01, 2014, 10:13:40 AM »
M.R. - this is no problem with the way Lee shares his knowledge but the manner in which it was used -- which has been discussed ad nauseum.
« Last Edit: June 01, 2014, 11:31:22 AM by MP »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

danallen

  • Guest
Re: Examples of usage GRREAD - let's share
« Reply #230 on: June 01, 2014, 10:21:16 AM »
Marko,

It is as simple as leaving in reference/remarks to original author of code, not just in your message. You don't need to leave all the original author's comments in (unless they state code should remain unmodified), but you should leave at least one line reference to either swamp message url or Lee's website.

Dan

RAIN CODE

  • Guest
Re: Examples of usage GRREAD - let's share
« Reply #231 on: June 05, 2014, 05:16:38 AM »

I support Lee on this.

He may have lost his cool and over reacted.

When you copy or borrow someone code
with the author initial in the subr name, it
is best to leave it alone

when I copied CAB code over to my
program he didnt put his initial in the subr
name and I changed the whole subr name
but when I copied Lee Mac code over I
noticed his initial in front and I told myself
I think I better leave that alone untouched.

Lee have contributed alot to this
community and I respect Lee Mac for his effort.











rkmcswain

  • Swamp Rat
  • Posts: 954
Re: Examples of usage GRREAD - let's share
« Reply #232 on: June 26, 2014, 12:27:36 PM »
I'm with Lee 100% here.  This community has immense power because of the people who freely contribute and they have earned the right to be recognized for it.

Ditto that comment ^^^^^^^

cmwade77

  • Swamp Rat
  • Posts: 1207
Re: Examples of usage GRREAD - let's share
« Reply #233 on: June 26, 2014, 01:01:37 PM »
Looking through this thread, I personally think Lee was actually very reasonable about this and I definitely feel that Lee is owed an apology for the way he was treated as well, he rightfully called someone out for not providing credit for his code (asking why they always removed his credit form his code when posting) and then was told that he overreacted. This doesn't seem right to me in the least, as far as I am aware, it has been a long standing policy of these boards to make sure that credit is included in any code that you post that uses other's code.

I have looked through some of the other posts that the person that Lee took issue with and it appears that this person expects credit to be given to them for their code, but removes credit to others when they reuse their code. They do give credit in their post and not in the code, but the credit should remain as remarks in the code, so that credit also gets copied over if someone else reuses the posted code.

I definitely don't think Lee overreacted, he puts a lot of time and effort into helping us all. I know my routines would be no where near what they are without him and I hope for the benefit of all of us those that didn't give the proper credit and those that treated Lee so harshly for asking for the credit will reach out to Lee to apologize for their poor behavior.

cmwade77

  • Swamp Rat
  • Posts: 1207
Re: Examples of usage GRREAD - let's share
« Reply #234 on: June 26, 2014, 01:16:52 PM »
Ah, well, I apologize for trying to keep the conversation civil then. Feel free to insult, abuse, attack, insult as you see fit.

…where were you guys during my "moderator cleanup effort", "subject lines are good", and "or is evil campaign"?
Lee did not insult or abuse, he simply asked why the person always removes his credit from his posts.

Based on the person's other posts, this does seem to be a valid question, as this person did appear to always remove the credit and given the amount that is missing the credit in their codes I think Lee was very tactful about it.

I still maintain there was nothing wrong with what Lee did. It also has brought this to our attention, so that we can be more careful about checking that person's code so that we can make sure that if we use it, we will give the appropriate credit.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10386
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.

Jeremy

  • Guest
Re: Examples of usage GRREAD - let's share
« Reply #236 on: June 29, 2014, 07:41:30 PM »
In the interest of getting us back to GRREAD .......

Code: [Select]
(vl-load-com)

;; I usually set these globally before any drawing session begins but I explicitly set them
;; here to make the code work for you.
(setq *ax-acad-object*     (vlax-get-acad-object)
      *ax-active-document* (vla-get-ActiveDocument *ax-acad-object*)
)

;; test function
(defun c:activetext ( / gr cp obj oldh ip h hr)

   ;...initially create our mtext before actively moving it
   (setq hr   60)
   (setq cp   (getvar 'VIEWCTR))
   (setq oldh (getvar 'VIEWSIZE))
   (setq obj  (axdraw-mtext (pt-to-callout cp) cp 8))
   (vla-put-AttachmentPoint obj acAttachmentPointMiddleCenter)
   (vla-put-Height obj (/ oldh hr))
   (put-transparency nil 15)
   ;....move the text around
   (while (= 5 (car (setq gr (grread T 1 0))))
     (setq p  (cadr gr) ;this is the current cursor position
           ip (vla-get-InsertionPoint obj)
     )
     (vla-put-TextString obj (pt-to-callout p))
     ;...if we have zoomed in or out then readjust the text height to remain constant
     (if (/= oldh (setq h (getvar 'VIEWSIZE)))
       (progn
         (vla-ScaleEntity obj ip (/ h oldh))
         (setq oldh h)
       )
     )
     ;...if the cursor has moved then move the mtext to comply
     (if (not (equal ip p))(vla-move obj ip (vlax-3D-point p)))
   )

   (vla-Delete obj) ;now delete the text because we picked a point on the screen
   (princ)
)

;; Change the transparency of an entity
(defun put-transparency ( nam n / echo )
  (setq echo (getvar 'CMDECHO))
  (if (null nam)(setq nam (entlast)))
  (setvar 'CMDECHO 0)
  (vl-cmdf "._CHPROP" nam "TR" n "" "")
  (setvar 'CMDECHO echo)
)

;; Return the object for the space that the user is currently in.
(defun ActiveSpace nil
    (vlax-get-property (eval *ax-active-document*)
                       (if (= (getvar 'CVPORT) 1) 'PaperSpace 'ModelSpace)))


;; Place a piece of mtext into the drawing
(defun axdraw-mtext ( str ip wid )
  (vla-AddMtext (ActiveSpace) (vlax-3D-point (trans ip 1 0)) wid str)
)


;; Given a point format a text input for the coordinates of the point
(defun pt-to-callout ( p / x y xstr yxtr )
  (setq x    (car  p)
        y    (cadr p)
        xstr (strcat "X: " (rtos x 2 6))
        ystr (strcat "Y: " (rtos y 2 6))
  )
  (strcat xstr "\\P" ystr)
)

Lee Mac wrote a little example where he had text made out of grdraw vectors display the X and Y values as the user moved their cursor around. I have done the same task but I create an MTEXT entity using active-X methods and use the Move and ScaleEntity properties to change it on the fly. I mostly did this to see if there would be any appreciable slowdowns or not as I have not done something like this before. I also wanted to see if I could get the better display choices inherent in Mtext. I was quite happy to see that it works quite well. I used the CHPROP command to alter the transparency of the text. I wanted to use active-X but could not find any transparency property for drawing entities. Does anyone know how to do this in active-X?

My next target is to make a simple dialog box that is nothing more than a block composed of control blocks within it. Doing dialogs this way can free us from the DCL file altogether and give us more formatting options, but one thing at a time. :-D

hanhphuc

  • Newt
  • Posts: 64
Re: Examples of usage GRREAD - let's share (pointer with osnap)
« Reply #237 on: August 15, 2014, 09:29:22 PM »
;hp#13 <<grread revisited>>

(hp:pointer pt color en )

similar (getpoint ) for the 2nd point, just add grread visual effect (osnap can be changed default is "_nea")
;returns the list xyz of last point (depend on osnap mode)
Code: [Select]
;v1.1: add object
(defun hp:pointer (_pt c obj / p tp l ip vs) ; v1.1
 (if obj (setq obj(vlax-ename->vla-object obj)))
  (while (and (= (setq p (car (setq tp (grread t 15 0)))) 5) (setq l (cadr tp)))
    (redraw)
       (grvecs
(apply
'append
(mapcar
  ''((x)
     (list
      6
      _pt
      (polar _pt (* pi x)(* 50. (setq vs (/ (getvar "viewsize") (cadr (getvar "screensize"))))))
      )
     )
  '(0.0 0.5 1.0 1.5)
  ) ;_ end of mapcar
) ;_ end of apply
) ;_ end of grvecs


  (setq ip  (osnap l "_nea")
ip  (if ip
      ip
      l
      ) ;_ end of if

a   (angle _pt ip)
sz  (* 50. vs)
ang (/ pi 6.37)
d   (* sz 0.25)
ep  (polar ip (+ a pi) 0. );(* sz 0.5)
) ;_ end of setq
   (grvecs
     (apply 'append
    (mapcar ''((x) (list c ep x))
    (list (polar ip a sz ) (polar ep (+ a ang) d) (polar ep (- a ang) d))
    ) ;_ end of mapcar
    ) ;_ end of apply
     ) ;_ end of grvecs
   
  (if obj
  (vlax-put obj "InsertionPoint" (polar _pt (angle _pt ip) (+(distance _pt ip) 0.2 sz))))

    ) ;_ end of while
 
;;;  (redraw)

  ip
  ) ;_ end of defun

http://www.theswamp.org/index.php?topic=12813.225
;example call:
(hp:pointer (getvar "viewctr") 2 nil) ;<-- nil no entity
Code: [Select]
(defun c:test (/ tx)
(setq tx  (car (entsel)))
(hp:pointer (getpoint) 2 tx))
« Last Edit: August 16, 2014, 12:52:22 AM by hanhphuc »
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

ribarm

  • Water Moccasin
  • Posts: 2335
  • Marko Ribar, architect
Re: Examples of usage GRREAD - let's share
« Reply #238 on: August 19, 2014, 02:53:23 AM »
I've just wrote "myline" implementation of SNAPS for grread - I've found some functions in Lee's DynOff lisp and I've added my subs for polar, ortho and Lee's and Evgeniy's osnap... So this should now imitate almost exactly how "LINE" command works... Hope you'll like it and find it useful if you plan seriously implementation of SNAPS...

Code: [Select]
(defun c:myline ( / *error* osm omo aus ape doc drft osGrv o p s
                    osMark _getosmode get_osmode osmode-grvecs-lst _snap _polarangs _polar _ortho
                    pt gr gp oPt gps )

  (vl-load-com)

  (defun *error* (msg)
    (if osm (setvar 'osmode osm))
    (if omo (setvar 'orthomode omo))
    (if aus (setvar 'autosnap aus))
    (if ape (setvar 'aperture ape))
    (if msg (prompt msg))
    (redraw)
    (princ)
  )
 
  (setq osm (getvar 'osmode))
  (setq omo (getvar 'orthomode))
  (setq aus (getvar 'autosnap))
  (if (eq omo 1) (setq o t) (setq o nil))
  (if (eq (logand aus 8) 8) (setq p t) (setq p nil))
  (if (< 0 osm 16384) (setq s t) (setq s nil))
  (setq ape (getvar 'aperture))
  (setvar 'aperture 10)

  (defun _getosmode (os / lst)
      (foreach mode
         '(
              (0001 . "_end")
              (0002 . "_mid")
              (0004 . "_cen")
              (0008 . "_nod")
              (0016 . "_qua")
              (0032 . "_int")
              (0064 . "_ins")
              (0128 . "_per")
              (0256 . "_tan")
              (0512 . "_nea")
              (1024 . "_qui")
              (2048 . "_app")
              (4096 . "_ext")
              (8192 . "_par")
          )
          (if (not (zerop (logand (car mode) os)))
              (setq lst (cons "," (cons (cdr mode) lst)))
          )
      )
      (apply 'strcat (cdr lst))
  )

  (defun osMark (o / s)
    (setq s (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE")))
          o (cons (trans (car o) 1 3) (cdr o)))

    (grvecs (cdr (assoc (cadr o) osGrv))
            (list (list s 0. 0. (caar o))
                  (list 0. s 0. (cadar o))
                  (list 0. 0. s 0.)
                  (list 0. 0. 0. 1.))))

  (defun get_osmode nil ; by Evgeniy Elpanov
    (mapcar
      (function cdr)
        (vl-remove-if
          (function (lambda (x) (zerop (logand (getvar "OSMODE") (car x)))))
          '((0    . "_non")
            (1    . "_end")
            (2    . "_mid")
            (4    . "_cen")
            (8    . "_nod")
            (16   . "_qua")
            (32   . "_int")
            (64   . "_ins")
            (128  . "_per")
            (256  . "_tan")
            (512  . "_nea")
            (2048 . "_app")))))

  (defun osmode-grvecs-lst (col ass / -ass)
     ; By Evgeniy Elpanov (Modified by Lee Mac)
   
    (setq -ass (- ass))
   
    (list (list "_non"
                col (list 0.0 -ass) (list 0.0  ass)
                col (list -ass 0.0) (list ass 0.0))

          (list "_end"
                col (list -ass -ass) (list -ass  ass)
                col (list (1-  -ass) (1- -ass)) (list (1- -ass) (1+  ass))             
                col (list -ass  ass) (list  ass  ass)
                col (list (1-  -ass) (1+  ass)) (list (1+  ass) (1+  ass))             
                col (list  ass  ass) (list  ass -ass)
                col (list (1+   ass) (1+  ass)) (list (1+  ass) (1- -ass))             
                col (list  ass -ass) (list -ass -ass)
                col (list (1+   ass) (1- -ass)) (list (1- -ass) (1- -ass)))
         
          (list "_mid"
                col (list -ass -ass) (list    0. ass)
                col (list (1-  -ass) (1- -ass)) (list 0. (1+  ass))
                col (list    0. ass) (list  ass -ass)
                col (list 0. (1+  ass)) (list (1+  ass) (1- -ass))
                col (list  ass -ass) (list -ass -ass)
                col (list (1+   ass) (1- -ass)) (list (1- -ass) (1- -ass)))
         
          (list "_cen"
                7   (list (* -ass 0.2) 0.)  (list (*  ass 0.2) 0.)
                7   (list  0. (* -ass 0.2)) (list  0.  (*  ass 0.2))
                col (list    -ass   0.)     (list (* -ass 0.86) (* ass  0.5))
                col (list (* -ass 0.86) (* ass  0.5))  (list (* -ass  0.5) (* ass 0.86))
                col (list (* -ass  0.5) (* ass 0.86))  (list 0. ass)
                col (list 0. ass) (list (* ass 0.5)    (* ass 0.86))
                col (list (* ass 0.5)   (* ass 0.86))  (list (* ass 0.86) (* ass 0.5))
                col (list (* ass 0.86)  (* ass 0.5))   (list ass 0.)
                col (list ass 0.) (list (* ass 0.86)   (* -ass 0.5))
                col (list (* ass 0.86)  (* -ass 0.5))  (list (* ass 0.5) (* -ass 0.86))
                col (list (* ass 0.5)   (* -ass 0.86)) (list 0. -ass)
                col (list 0. -ass)(list (* -ass 0.5)   (* -ass 0.86))
                col (list (* -ass 0.5)  (* -ass 0.86)) (list (* -ass 0.86) (* -ass 0.5))
                col (list (* -ass 0.86) (* -ass 0.5))  (list -ass 0.))

          (list "_nod"
                col (list -ass -ass)    (list ass ass)
                col (list -ass ass)     (list ass -ass)
                col (list -ass 0.)      (list (* -ass 0.86) (* ass 0.5))
                col (list (* -ass 0.86) (* ass 0.5))   (list (* -ass 0.5) (* ass 0.86))
                col (list (* -ass 0.5)  (* ass 0.86))  (list 0. ass)
                col (list 0. ass) (list (* ass 0.5)    (* ass 0.86))
                col (list (* ass 0.5)   (* ass 0.86))  (list (* ass 0.86) (* ass 0.5))
                col (list (* ass 0.86)  (* ass 0.5))   (list ass 0.)
                col (list ass 0.) (list (* ass 0.86)   (* -ass 0.5))
                col (list (* ass 0.86)  (* -ass 0.5))  (list (* ass 0.5) (* -ass 0.86))
                col (list (* ass 0.5)   (* -ass 0.86)) (list 0. -ass)
                col (list 0. -ass)(list (* -ass 0.5)   (* -ass 0.86))
                col (list (* -ass 0.5)  (* -ass 0.86)) (list (* -ass 0.86) (* -ass 0.5))
                col (list (* -ass 0.86) (* -ass 0.5))  (list -ass 0.))

          (list "_qua"
                col (list 0. -ass)   (list -ass 0.)
                col (list 0. (1- -ass))   (list (1- -ass) 0.)
                col (list -ass 0.)   (list 0. ass)
                col (list (1- -ass) 0.)   (list 0. (1+ ass))
                col (list 0. ass)    (list ass 0.)
                col (list 0. (1+ ass))    (list (1+ ass) 0.)
                col (list ass 0.)    (list 0. -ass)
                col (list (1+ ass) 0.)    (list 0. (1- -ass)))

          (list "_int"
                col (list -ass -ass) (list ass ass)
                col (list -ass (1+ -ass)) (list ass (1+ ass))
                col (list (1+ -ass) -ass) (list (1+ ass) ass)
                col (list -ass ass)  (list ass -ass)
                col (list -ass (1+ ass))  (list ass (1+ -ass))
                col (list (1+ -ass) ass)  (list (1+ ass) -ass))

          (list "_ins"
                col (list (* -ass 0.1) (* -ass 0.1)) (list -ass (* -ass 0.1))
                col (list -ass (* -ass 0.1)) (list -ass ass)
                col (list -ass ass) (list (* ass 0.1) ass)
                col (list (* ass 0.1) ass)   (list (* ass 0.1) (* ass 0.1))
                col (list (* ass 0.1) (* ass 0.1))   (list ass (* ass 0.1))
                col (list ass (* ass 0.1))   (list ass -ass)
                col (list ass -ass) (list (* -ass 0.1) -ass)
                col (list (* -ass 0.1) -ass) (list (* -ass 0.1) (* -ass 0.1))
                col (list (1- (* -ass 0.1)) (1- (* -ass 0.1))) (list (1- -ass) (1- (* -ass 0.1)))
                col (list (1- -ass) (1- (* -ass 0.1))) (list (1- -ass) (1+ ass))
                col (list (1- -ass) (1+ ass)) (list (1+ (* ass 0.1)) (1+ ass))
                col (list (1+ (* ass 0.1)) (1+ ass)) (list (1+ (* ass 0.1)) (1+ (* ass 0.1)))
                col (list (1+ (* ass 0.1)) (1+ (* ass 0.1))) (list (1+ ass) (1+ (* ass 0.1)))
                col (list (1+ ass) (1+ (* ass 0.1)))   (list (1+ ass) (1- -ass))
                col (list (1+ ass) (1- -ass)) (list (1- (* -ass 0.1)) (1- -ass))
                col (list (1- (* -ass 0.1))   (1- -ass)) (list (1- (* -ass 0.1)) (1- (* -ass 0.1))))

          (list "_tan"
                col (list -ass ass) (list ass ass)
                col (list (1- -ass) (1+ ass)) (list (1+ ass) (1+ ass))
                col (list -ass 0.)  (list (* -ass 0.86) (* ass 0.5))
                col (list (* -ass 0.86) (* ass 0.5)) (list (* -ass 0.5) (* ass 0.86))
                col (list (* -ass 0.5) (* ass 0.86)) (list 0. ass)
                col (list 0. ass) (list  (* ass 0.5) (* ass 0.86))
                col (list (* ass 0.5)  (* ass 0.86)) (list (* ass 0.86) (* ass 0.5))
                col (list (* ass 0.86)  (* ass 0.5)) (list ass 0.)
                col (list ass 0.) (list (* ass 0.86) (* -ass 0.5))
                col (list (* ass 0.86) (* -ass 0.5)) (list (* ass 0.5) (* -ass 0.86))
                col (list (* ass 0.5) (* -ass 0.86)) (list 0. -ass)
                col (list 0. -ass)(list (* -ass 0.5) (* -ass 0.86))
                col (list (* -ass 0.5)(* -ass 0.86)) (list (* -ass 0.86) (* -ass 0.5))
                col (list (* -ass 0.86)(* -ass 0.5)) (list -ass 0.))

          (list "_per"
                col (list -ass -ass) (list -ass ass)
                col (list (1- -ass)  (1- -ass)) (list (1- -ass) (1+ ass))
                col (list ass -ass)  (list -ass -ass)
                col (list (1+ ass)   (1- -ass)) (list (1- -ass) (1- -ass))
                col (list -ass 0.)   (list 0. 0.)
                col (list -ass -1.)  (list 0. -1.)
                col (list 0. 0.)     (list 0. -ass)
                col (list -1. 0.)    (list -1. -ass))

          (list "_nea"
                col (list -ass -ass) (list ass ass)
                col (list -ass ass)  (list ass ass)
                col (list (1- -ass)  (1+ ass)) (list (1+ ass) (1+ ass))
                col (list -ass ass)  (list ass -ass)
                col (list ass -ass)  (list -ass -ass)
                col (list (1+ ass) (1- -ass)) (list (1- -ass) (1- -ass)))

          (list "_app"
                col (list -ass -ass) (list ass ass)
                col (list ass -ass)  (list -ass ass)
                col (list -ass -ass) (list -ass ass)
                col (list (1- -ass)  (1- -ass)) (list (1- -ass) (1+ ass))
                col (list -ass ass)  (list ass ass)
                col (list (1- -ass)  (1+ ass))  (list (1+ ass) (1+ ass))
                col (list ass ass)   (list ass -ass)
                col (list (1+ ass)   (1+ ass))  (list (1+ ass) (1- -ass))
                col (list ass -ass)  (list -ass -ass)
                col (list (1+ ass)   (1- -ass)) (list (1- -ass) (1- -ass)))))
             
  (defun _snap (p os)
    (if (osnap p (_getosmode os))
      (osnap p (_getosmode os))
      p
    )
  )

  (defun _polarangs (ang / n k a l)
    (if (/= ang 0.0)
      (progn
        (setq n (/ 360.1 (cvunit ang "radians" "degrees")))
        (setq k -1.0)
        (repeat (1+ (fix n))
          (setq a (* (setq k (1+ k)) ang))
          (setq l (cons a l))
        )
        l
      )
      (list 0.0)
    )
  )

  (defun _polar (p0 p flag ang / a b an)
    (if flag
      (progn
        (setq a (car (vl-sort (_polarangs ang) '(lambda ( a b ) (< a (angle p0 p) b)))))
        (setq b (last (vl-sort (_polarangs ang) '(lambda ( a b ) (< a (angle p0 p) b)))))
        (if (< (abs (- (angle p0 p) a)) (abs (- (angle p0 p) b))) (setq an a) (setq an b))
        (inters p0 (polar p0 an 1.0) p (polar p (+ an (* 0.5 pi)) 1.0) nil)
      )
      p
    )
  )

  (defun _ortho (p0 p flag)
    (if flag
      (_polar p0 p t (* 0.5 pi))
      p
    )
  )

  (setq doc   (vla-get-ActiveDocument
                (vlax-get-acad-object))
       
        drft  (vla-get-drafting
                (vla-get-preferences
                  (vlax-get-acad-object)))
       
        osGrv (osmode-grvecs-lst
                (vla-get-AutoSnapMarkerColor drft)
                  (vla-get-AutoSnapMarkerSize drft)))
 
  ;;;--------- main function ---------;;;

  (setq pt (getpoint "\nPick or specify point : "))
  (while (/= 3 (car (setq gr (grread 't 15 0))))
    (redraw)
    (cond
      ( (and (= (car gr) 5) (listp (setq gp (cadr gr))))
        (if (and (< 0 (getvar "OSMODE") 16384)
                 (setq oPt (vl-remove-if (function null)
                             (mapcar
                               (function
                                 (lambda (x / o)
                                   (if (setq o (osnap gp x))
                                     (list (distance gp o) o x gp)))) (get_osmode)))))

          (setq oPt (cdar (vl-sort oPt (function (lambda (a b) (< (car a) (car b)))))))
          (setq oPt (list (osnap gp "_non") "_non" gp)))

        (and oPt (OsMark oPt))
        (cond
          ( (and o p s)
            (setq gps (_snap (_ortho pt gp t) (getvar 'osmode)))
          )
          ( (and o (not p) s)
            (setq gps (_snap (_ortho pt gp t) (getvar 'osmode)))
          )
          ( (and (not o) p s)
            (setq gps (_snap (_polar pt gp t (getvar 'polarang)) (getvar 'osmode)))
          )
          ( (and (not o) (not p) s)
            (setq gps (_snap gp (getvar 'osmode)))
          )
          ( (and o p (not s))
            (setq gps (_ortho pt gp t))
          )
          ( (and o (not p) (not s))
            (setq gps (_ortho pt gp t))
          )
          ( (and (not o) p (not s))
            (setq gps (_polar pt gp t (getvar 'polarang)))
          )
          ( (and (not o) (not p) (not s))
            (setq gps gp)
          )
        )
        (grdraw pt gps 3 1)
      )
      ( (and (= (car gr) 2) (= (cadr gr) 6))
        (cond
          ( (< 0 osm 16384) (setq osm (+ osm 16384)) (setvar 'osmode osm) )
          ( (>= osm 16384) (setq osm (- osm 16384)) (setvar 'osmode osm) )
        )
        (if (eq s t) (setq s nil) (setq s t))
      )
      ( (and (= (car gr) 2) (= (cadr gr) 15))
        (cond
          ( (= omo 0) (setq omo 1) (setvar 'orthomode 1) )
          ( (= omo 1) (setq omo 0) (setvar 'orthomode 0) )
        )
        (if (eq o t) (setq o nil) (setq o t))
      )
      ( (and (= (car gr) 2) (= (cadr gr) 21))
        (cond
          ( (= aus 0) (setq aus 8) (setvar 'autosnap 8) )
          ( (= aus 8) (setq aus 0) (setvar 'autosnap 0) )
          ( (= aus 16) (setq aus 24) (setvar 'autosnap 24) )
          ( (= aus 24) (setq aus 16) (setvar 'autosnap 16) )
        )
        (if (eq p t) (setq p nil) (setq p t))
      )
      ( (and (= (car gr) 2) (= (cadr gr) 23))
        (cond
          ( (= aus 0) (setq aus 16) (setvar 'autosnap 16) )
          ( (= aus 8) (setq aus 24) (setvar 'autosnap 24) )
          ( (= aus 16) (setq aus 0) (setvar 'autosnap 0) )
          ( (= aus 24) (setq aus 8) (setvar 'autosnap 8) )
        )
      )
    )
  )
  (command "_.line" "_non" pt "_non" gps "")
  (*error* nil)
)

Kind regards, M.R.
« Last Edit: August 19, 2014, 07:01:26 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1778
  • BricsCAD 18
Re: Examples of usage GRREAD - let's share
« Reply #239 on: August 19, 2014, 04:29:16 AM »
@ ribarm: Function _getosmode is missing.