ehsantavassolian Posted November 16, 2024 Posted November 16, 2024 (edited) hello Is it possible to have osnap enabled when using this app so we can click at the beginning of the lines. https://www.lee-mac.com/grtext.html Edited November 18, 2024 by SLW210 Removed code as link was provided. Quote
Lee Mac Posted November 17, 2024 Posted November 17, 2024 You would need to implement your own Object Snap functionality, or perhaps leverage my existing GrSnap function. 1 Quote
ehsantavassolian Posted February 12 Author Posted February 12 I worked on this program a little When drawing a polyline, it shows the total length of the polyline and the distance to the mouse next to the mouse Is it possible to see how it can be made more functional and better? I want the snap point to be on when selecting a point to find the beginning of the lines I also want to see the mouse with the ruler to the last part of the drawn part (princ "\nSpecify point: ") (setq ename nil sumdist 0) (if (setq pt (getpoint "\nSpecify Specify point: ")) (progn (while (and pt (= (while (= 5 (car (setq pnt (grread nil 13 0)))) (redraw) (LM:DisplayGrText (cadr pnt) (LM:GrText (strcat (rtos (+ sumdist (distance pt (cadr pnt))) 2 2) )) 4 ;Color 15 ;x -31) ;y ) nil)) (command "_.pline" pt (cadr pnt) "") (if ename (command "_.pedit" ename "_j" (entlast) "" "" )) (setq ename (entlast)) (setq sumdist (+ sumdist (distance pt (cadr pnt)))) (setq pt (cadr pnt)) ) ) ) Quote
Steven P Posted February 12 Posted February 12 grrear doesn't do snaps so easily - if you look at Lee Macs link above to get the snaps I might have something - will have to look 1 Quote
Steven P Posted February 13 Posted February 13 I had a bit of time to look at this, I think this is what I added to Lees code above: (defun c:grsnap ( / ) ... Lee Macs code here until... (vl-load-com) (princ) (setq osf (LM:grsnap:snapfunction) osm (getvar 'osmode) ) (princ "\nPick point: ") (while (= 5 (car (setq grr (grread t 15 0)))) (redraw) (osf (cadr grr) osm) ) ; (if (listp (cadr grr)) ; (entmake (list '(0 . "POINT") (cons 10 (trans (osf (cadr grr) osm) 1 0)))) ; ) (redraw) (princ) (trans (osf (cadr grr) osm) 1 0) ) Quote
GLAVCVS Posted Tuesday at 11:10 PM Posted Tuesday at 11:10 PM It's fun to play with GRRead. But it's also laborious. I've been experimenting with your code this afternoon and have added a few things. But this code only supports references to endpoint objects. I didn't have enough time for more. This is the result. (defun c:santaVassolian (/ ename sumdist pt pnt ptGR polil tam dibuSnap) ;;; HERE 'LM:DisplayGrText' code .... ;;; .................................... (defun dibuSnap (pt color / xMin yMin xMax yMax) ;;; ONLY _end POINT (grvecs (list color (list (setq Xmin (- (car pt) tam)) (setq Ymin (- (cadr pt) tam)) ) (list Xmin (setq Ymax (+ (cadr pt) tam))) (list Xmin Ymax) (list (setq Xmax (+ (car pt) tam)) Ymax) (list Xmax Ymax) (list Xmax Ymin) (list Xmax Ymin) (list Xmin Ymin) ) ) T ) (princ "\nSpecify point: ") (setq ename nil sumdist 0 ) (if (setq pt (getpoint "\nSpecify Specify point: ")) (progn (princ "\nPick next point (right button for exit)...") (while (and pt (= (while (= 5 (car (setq pnt (grread nil 13 0)))) (redraw) (LM:DisplayGrText (cadr pnt) (LM:GrText (strcat (rtos (+ sumdist (distance pt (cadr pnt))) 2 2)) ) 4 ;Color 15 ;x -31 ) ;y (setq tam (* (* (getvar "PICKBOX") (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE")) ) ) 2 ) ) (if (listp (cadr pnt)) (grvecs (list 7 pt (if (and (setq ptGR (osnap (cadr pnt) "_end")) (and (<= (abs (- (car ptGR) (car (cadr pnt)))) tam ) (<= (abs (- (cadr ptGR) (cadr (cadr pnt)))) tam ) ) (dibuSnap ptGR 1) ) ptGR (progn (setq ptGR nil) (cadr pnt) ) ) ) ) ) ) nil ) ) (redraw) (if (= (car pnt) 3) (progn (if polil (if ptGR (entmod (append (entget polil) (list (cons 10 ptGR)) ) ) (entmod (append (entget polil) (list (cons 10 (cadr pnt))) ) ) ) (if (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 8 "0") (cons 90 2) '(70 . 128) '(62 . 256) (cons 10 pt) (if (setq ptGR (osnap (cadr pnt) "_end")) (cons 10 ptGR) (cons 10 (cadr pnt)) ) ) ) (setq polil (entlast)) ) ) ;;; (command "_.pline" pt (cadr pnt) "") ;;; (if ename ;;; (command "_.pedit" ename "_j" (entlast) "" "") ;;; ) ;;; (setq ename (entlast)) (setq sumdist (+ sumdist (distance pt (cadr pnt)))) (setq pt (if ptGR ptGR (cadr pnt) ) ) ) (setq pt nil); OBLIGA A SALIR ) ) ) ) (PRINC) ) 1 Quote
GLAVCVS Posted Tuesday at 11:18 PM Posted Tuesday at 11:18 PM (edited) I hope you find it useful. Or anyone who needs a starting point. Running, it looks more or less like this VID-20250219-WA0001.mp4 Edited Wednesday at 12:27 AM by GLAVCVS 1 Quote
ehsantavassolian Posted Wednesday at 06:53 AM Author Posted Wednesday at 06:53 AM 7 hours ago, GLAVCVS said: It's fun to play with GRRead. But it's also laborious. I've been experimenting with your code this afternoon and have added a few things. But this code only supports references to endpoint objects. I didn't have enough time for more. This is the result. (defun c:santaVassolian (/ ename sumdist pt pnt ptGR polil tam dibuSnap) ;;; HERE 'LM:DisplayGrText' code .... ;;; .................................... (defun dibuSnap (pt color / xMin yMin xMax yMax) ;;; ONLY _end POINT (grvecs (list color (list (setq Xmin (- (car pt) tam)) (setq Ymin (- (cadr pt) tam)) ) (list Xmin (setq Ymax (+ (cadr pt) tam))) (list Xmin Ymax) (list (setq Xmax (+ (car pt) tam)) Ymax) (list Xmax Ymax) (list Xmax Ymin) (list Xmax Ymin) (list Xmin Ymin) ) ) T ) (princ "\nSpecify point: ") (setq ename nil sumdist 0 ) (if (setq pt (getpoint "\nSpecify Specify point: ")) (progn (princ "\nPick next point (right button for exit)...") (while (and pt (= (while (= 5 (car (setq pnt (grread nil 13 0)))) (redraw) (LM:DisplayGrText (cadr pnt) (LM:GrText (strcat (rtos (+ sumdist (distance pt (cadr pnt))) 2 2)) ) 4 ;Color 15 ;x -31 ) ;y (setq tam (* (* (getvar "PICKBOX") (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE")) ) ) 2 ) ) (if (listp (cadr pnt)) (grvecs (list 7 pt (if (and (setq ptGR (osnap (cadr pnt) "_end")) (and (<= (abs (- (car ptGR) (car (cadr pnt)))) tam ) (<= (abs (- (cadr ptGR) (cadr (cadr pnt)))) tam ) ) (dibuSnap ptGR 1) ) ptGR (progn (setq ptGR nil) (cadr pnt) ) ) ) ) ) ) nil ) ) (redraw) (if (= (car pnt) 3) (progn (if polil (if ptGR (entmod (append (entget polil) (list (cons 10 ptGR)) ) ) (entmod (append (entget polil) (list (cons 10 (cadr pnt))) ) ) ) (if (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 8 "0") (cons 90 2) '(70 . 128) '(62 . 256) (cons 10 pt) (if (setq ptGR (osnap (cadr pnt) "_end")) (cons 10 ptGR) (cons 10 (cadr pnt)) ) ) ) (setq polil (entlast)) ) ) ;;; (command "_.pline" pt (cadr pnt) "") ;;; (if ename ;;; (command "_.pedit" ename "_j" (entlast) "" "") ;;; ) ;;; (setq ename (entlast)) (setq sumdist (+ sumdist (distance pt (cadr pnt)))) (setq pt (if ptGR ptGR (cadr pnt) ) ) ) (setq pt nil); OBLIGA A SALIR ) ) ) ) (PRINC) ) Wow, that's exactly what I wanted. Thank you so much for your effort. Quote
GLAVCVS Posted Wednesday at 12:51 PM Posted Wednesday at 12:51 PM I'm glad to know that it is useful to you. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.