bustr Posted March 25 Share Posted March 25 Nothing in the drawing I'm working on is drawn on snap. I would like to correct this. I have a lisp routine that can do this. It is shown below. However, I am using AutoCAD LT 2023 which doesn't allow lisp routines. Does anyone know of another way to do this? This lisp routine forces object onto a 1/16" snap. (defun ROUND (NMBR) (setq RMDR (rem NMBR SNPV)) (cond ((and (>= (abs RMDR) 0.0) (<= (abs RMDR) (/ SNPV 2.0))) (- NMBR RMDR) ) ((and (> (abs RMDR) (/ SNPV 2.0)) (< (abs RMDR) SNPV)) (+ NMBR (- SNPV RMDR)) ) ((or (= (abs RMDR) 0.0) (= (abs RMDR) (/ SNPV 2.0))) (+ NMBR 0.0) ) ) ; cond ) ; end of ROUND ;-------------------------------------------------------------------------------- ; THIS ROUTINE MOVES THE FOLLOWING TO THE NEAREST SNAP POINT: ; 1) ENDS OF LINES, 2) CENTERS OF ARCS AND CIRCLES 3) BLOCK & TEXT INSERT POINTS ; THIS WORKS ONLY ON A RECTANGULAR SNAP WHERE X & Y ARE EQUAL. ; ; NOTES: ADD PROVISION TO MAKE SURE HOR/VERT LINES REMAIN AS-IS ; MAKE SURE TO IGNORE ISOMETRIC DRAWINGS (defun C:16thSnapfix (/ SNPV ENTS CNTR EDAT ETYP STRT XVL1 YVL1 RND1 ENDP XVL2 YVL2 RND2 ARAD RAD1 VRCT PLST PLXV PLYV PLNW ) ;-------------------------------------------------------------------------------- (setq SNPV 0.0625) ; set SNAP value (setvar "SNAPUNIT" (list SNPV SNPV)) (setvar "CMDECHO" 0) (setvar "SNAPMODE" 1) (setvar "GRIDUNIT" (list 0.250 0.250)) (setvar "GRIDMODE" 1) (setvar "OSMODE" 0) (command "REGEN") (setvar "PLINETYPE" 2) ; set new plines to LWPOLYLINEs (command "CONVERT" "ALL" "ALL") ; convert all plines to LWPOLYLINEs (setq ENTS (ssget "X" '((-4 . "<OR") (0 . "ARC") (0 . "CIRCLE") (0 . "INSERT") (0 . "LINE") (0 . "*POLYLINE") (0 . "*TEXT") (-4 . "OR>") ) ) ) (setq CNTR (1- (sslength ENTS))) (while (>= CNTR 0) (progn (setq EDAT (entget (ssname ENTS CNTR))) (setq ETYP (cdr (assoc 0 EDAT))) (cond ;-------------------------------------------------------------------------------- ((or (= ETYP "LINE") (= ETYP "INSERT") (= ETYP "TEXT") (= ETYP "MTEXT") ) ; EVAL THE START POINT (setq STRT (assoc 10 EDAT) ; start point XVL1 (round (cadr STRT)) ; X value YVL1 (round (caddr STRT)) ; Y value ) (setq RND1 (list 10 XVL1 YVL1 0.0) ; build a code 10 list EDAT (subst RND1 (assoc 10 EDAT) EDAT) ; repl old list for new ) (entmod EDAT) ; update the entity ; EVAL THE END POINT (if (/= (assoc 11 EDAT) nil) (progn (setq ENDP (assoc 11 EDAT) ; end point XVL2 (round (cadr ENDP)) ; X value YVL2 (round (caddr ENDP)) ; Y value RND2 (list 11 XVL2 YVL2 0.0) ; build a code 11 list EDAT (subst RND2 (assoc 11 EDAT) EDAT) ; repl old list for new ) (entmod EDAT) ; update the entity ) ; progn ) ; if ) ; cond LINE, INSERT, TEXT ;-------------------------------------------------------------------------------- ((or (= ETYP "ARC") (= ETYP "CIRCLE")) (setq STRT (assoc 10 EDAT) ; start point XVL1 (round (cadr STRT)) ; X value YVL1 (round (caddr STRT)) ; Y value EDAT (subst (list 10 XVL1 YVL1 0.0) (assoc 10 EDAT) EDAT) ; repl old list for new ARAD (assoc 40 EDAT) ; radius RAD1 (round (cdr ARAD)) EDAT (subst (cons 40 RAD1) (assoc 40 EDAT) EDAT) ; repl old rad for new ) (entmod EDAT) ; update the entity ) ; 2nd cond ;-------------------------------------------------------------------------------- ((if (= ETYP "LWPOLYLINE") (progn (setq VRCT 0) ; vertex counter (setq PLST (assoc 10 EDAT)) ; the 1st vertex (while (/= VRCT (length EDAT)) (if (= (car (nth VRCT EDAT)) 10) (progn (setq PLST (nth VRCT EDAT) PLXV (round (cadr PLST)) ; X val PLYV (round (caddr PLST)) ; Y val PLNW (list 10 PLXV PLYV) ; new list EDAT (subst PLNW PLST EDAT) ) (entmod EDAT) ) ; progn ) ; if (setq VRCT (1+ VRCT)) ) ; while ) ; progn ) ; if ) ; 3rd cond ;-------------------------------------------------------------------------------- ) ; end of conds (setq CNTR (1- CNTR)) (princ) ) ; progn ) ; while (setvar "CMDECHO" 1) (princ) ) ; end defun Quote Link to comment Share on other sites More sharing options...
tombu Posted March 27 Share Posted March 27 Why not use the 2024 or just released 2025 version of AutoCAD LT with lisp included instead? https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-FB2F8870-8CC0-4062-AA06-9D2893F8E09E I've never used LT and couldn't imagine working without lisp functions. Quote Link to comment Share on other sites More sharing options...
bustr Posted March 27 Author Share Posted March 27 1 hour ago, tombu said: I have thought about upgrading. But, autocad has made so many "improvements" that I have to spend a week straightening out these things after a new installation. Why not use the 2024 or just released 2025 version of AutoCAD LT with lisp included instead? https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-FB2F8870-8CC0-4062-AA06-9D2893F8E09E I've never used LT and couldn't imagine working without lisp functions. Quote Link to comment Share on other sites More sharing options...
lrm Posted March 27 Share Posted March 27 Try the following and see if it shows any promise. The results are a function of the extents and location in WCS. Move [enter] all [enter] [enter] 1e16,1e16 [enter] [enter] Move [enter] all [enter] [enter] -1e16,-1e16 [enter][enter] Since the precision of AutoCAD is approcimately 15 signifcant digits this action moves object beyond its precision resultig in a rounding of coordinates. It may not do what you want and there could be surprises but its easy to try! Quote Link to comment Share on other sites More sharing options...
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.