DraganK Posted December 13, 2024 Posted December 13, 2024 (edited) Hello, I need help. I use the lisp Batter to draw slope tick lines and the lisp works great if my drawings are in coordinates that have 3 or 4 digits. Example (100.00,200.00) or (5100.00, 5100.00) but the coordinate system that uses UTM zone 34 has 9 and 7 digits (34455000.00, 4951000.00) simply the lisp does all the operations but does not draw the slope lines. If I move the entire drawing to coordinates with 3 or 4 digits the lisp works great, I noticed that if the drawing is in coordinates with 5 or more digits the lisp does not draw tick line. My knowledge of auto lisp is very little so if someone can help me and correct the codes in lisp I would be very grateful. sorry for my bad English (defun c:batter () (setq oldlay (getvar "clayer")) (setvar "osmode" 0) (command "-view" "s" "cur") (command "ucs" "w") (if (not (tblsearch "layer" "BATTER")) (command "_.layer" "_make" "BATTER" "_color" "8" "" "") ) (setvar "clayer" "BATTER") (setvar "cmdecho" 0) (setvar "aunits" 0) (setvar "angbase" (/ pi 2)) (setvar "angdir" 1) (if (not lint) (setq lint 10.0)) (setq int (getdist (strcat "\nInterval <" (rtos lint 2 3) ">: "))) (if int (setq lint int) (setq int lint)) (command "line" (list 0.0 0.0) (list 0.0 0.0001) "") (if (tblsearch "block" "tadtick") (command "block" "tadtick" "y" (list 0.0 0.0) (entlast) "") (command "block" "tadtick" (list 0.0 0.0) (entlast) "") ) (while (setq refent (entsel "\nSelect reference line: ")) (command "undo" "group") (redraw (car refent) 3) (initget 1 "Cut Fill") (setq reply (getkword "\n[C]ut or [F]ill batter: ")) (setq s (ssget)) (command "measure" refent "b" "tadtick" "y" int) (setq p (ssget "p") cn 0) (if s (progn (while (< cn (sslength p)) (setq en (entget (ssname p cn)) p0 (cdr (assoc 10 en)) pt1 p0 pt2 nil b (cdr (assoc 50 en))) (entdel (ssname p cn)) (setq p1 (polar p0 (+ (/ pi 2) b) 0.0001)) (command "line" p0 p1 "") (command "extend" s "" (list (entlast) p1) "") (setq xent (entget (entlast))) (setq xdist (distance (cdr (assoc 10 xent)) (cdr (assoc 11 xent)))) (if (not (equal xdist 0.0001 0.0001)) (setq pt2 (cdr (assoc 11 xent))) (progn (command "extend" s "" (list (entlast) p0) "") (setq xent (entget (entlast))) (setq xdist (distance (cdr (assoc 10 xent)) (cdr (assoc 11 xent)))) (if (not (equal xdist 0.0001 0.0001)) (setq pt2 (cdr (assoc 10 xent))) ) ) ) (entdel (entlast)) (if pt2 (if (= reply "Fill") (if (= (rem cn 2) 0) (command "line" pt1 pt2 "") (command "line" pt1 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)) "") ) (if (= (rem cn 2) 0) (command "line" pt2 pt1 "") (command "line" pt2 (polar pt2 (angle pt2 pt1) (/ (distance pt2 pt1) 2)) "") ) ) ) (setq cn (1+ cn)) ) ) ) (command "undo" "en") ) (setvar "clayer" oldlay) (command "-view" "r" "cur") (command "-view" "d" "cur") (princ) ) (prompt "\nDraw cut/fill batter slope lines.") batter.lsp Edited December 13, 2024 by SLW210 Added Code Tags! Quote
Tsuky Posted December 13, 2024 Posted December 13, 2024 Hi, My suggestion as an alternative. Entities selections can be polylines lines arcs circles ellipses and splines in 2D or 3D. The wrapping lines will be in 2D or 3D depending on the source. Try it if it suits you!... slope3D.lsp Quote
DraganK Posted December 13, 2024 Author Posted December 13, 2024 Tsuky - Thanks for the alternative , but it's not what I need for the job, I hope someone else will join in and try to fix the error in the code. Quote
SLW210 Posted December 13, 2024 Posted December 13, 2024 In the future please use code tags for your code. (<> in the editor toolbar) Quote
BIGAL Posted December 13, 2024 Posted December 13, 2024 Maybe try this one batterticks-1.lsp tick.dwg Quote
DraganK Posted December 16, 2024 Author Posted December 16, 2024 BIGAL thanks for the lisp, but it doesn't draw what I need, I have to shorten every other line, it's easier to move my drawing and draw the slopes line and then return to the old coordinate system. Quote
DraganK Posted 9 hours ago Author Posted 9 hours ago (edited) Heelp Edited 9 hours ago by DraganK Quote
DraganK Posted 8 hours ago Author Posted 8 hours ago (edited) batter 4 digits.dwg batter 9 and 7 digits.dwg Thanks for help. Edited 8 hours ago by DraganK Quote
DraganK Posted 7 hours ago Author Posted 7 hours ago 6 minutes ago, GLAVCVS said: Does your drawing contain blocks? The drawing has no blocks, the drawings I posted only have 4 lines between which I draw slopes. In the drawing where the coordinates have 4 digits the lisp works but in the other drawing with 9 and 7 digits it does not work. Sorry for my bad English Quote
GLAVCVS Posted 7 hours ago Posted 7 hours ago I have made the necessary modifications to make the command calls compatible with other languages and the code works fine for me in your 2 drawings. Are you using an English version of AutoCAD or another language? Quote
DraganK Posted 7 hours ago Author Posted 7 hours ago 1 minute ago, GLAVCVS said: I have made the necessary modifications to make the command calls compatible with other languages and the code works fine for me in your 2 drawings. Are you using an English version of AutoCAD or another language? Using English version Civil 3d 2023. Quote
GLAVCVS Posted 7 hours ago Posted 7 hours ago This is the code I tried And it works (defun c:batter (/ oldlay int refent reply s p cn en p0 pt1 pt2 b p1 xdist xent) (setq oldlay (getvar "clayer")) (setvar "osmode" 0) (command "_.view" "_s" "_.cur") (command "_.ucs" "_w") (if (not (tblsearch "layer" "BATTER")) (command "_.layer" "_make" "BATTER" "_color" "8" "" "") ) (setvar "clayer" "BATTER") (setvar "cmdecho" 0) (setvar "aunits" 0) (setvar "angbase" (/ pi 2)) (setvar "angdir" 1) (if (not lint) (setq lint 10.0) ) (setq int (getdist (strcat "\nInterval <" (rtos lint 2 3) ">: "))) (if int (setq lint int) (setq int lint) ) (command "_.line" (list 0.0 0.0) (list 0.0 0.0001) "") (if (tblsearch "block" "tadtick") (command "_.block" "tadtick" "_y" (list 0.0 0.0) (entlast) "") (command "_.block" "tadtick" (list 0.0 0.0) (entlast) "") ) (while (setq refent (entsel "\nSelect reference line: ")) (command "_.undo" "_group") (redraw (car refent) 3) (initget 1 "Cut Fill") (setq reply (getkword "\n[C]ut or [F]ill batter: ")) (setq s (ssget)) (command "_.measure" refent "_b" "tadtick" "_y" int) (setq p (ssget "p") cn 0 ) (if s (progn (while (< cn (sslength p)) (setq en (entget (ssname p cn)) p0 (cdr (assoc 10 en)) pt1 p0 pt2 nil b (cdr (assoc 50 en)) ) (entdel (ssname p cn)) (setq p1 (polar p0 (+ (/ pi 2) b) 0.0001)) (command "_.line" p0 p1 "") (command "_.extend" s "" (list (entlast) p1) "") (setq xent (entget (entlast))) (setq xdist (distance (cdr (assoc 10 xent)) (cdr (assoc 11 xent))) ) (if (not (equal xdist 0.0001 0.0001)) (setq pt2 (cdr (assoc 11 xent))) (progn (command "_.extend" s "" (list (entlast) p0) "") (setq xent (entget (entlast))) (setq xdist (distance (cdr (assoc 10 xent)) (cdr (assoc 11 xent)) ) ) (if (not (equal xdist 0.0001 0.0001)) (setq pt2 (cdr (assoc 10 xent))) ) ) ) (entdel (entlast)) (if pt2 (if (= reply "Fill") (if (= (rem cn 2) 0) (command "_.line" pt1 pt2 "") (command "_.line" pt1 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)) "" ) ) (if (= (rem cn 2) 0) (command "_.line" pt2 pt1 "") (command "_.line" pt2 (polar pt2 (angle pt2 pt1) (/ (distance pt2 pt1) 2)) "" ) ) ) ) (setq cn (1+ cn)) ) ) ) (command "_.undo" "_en") ) (setvar "clayer" oldlay) (command "_.view" "_r" "_cur") (command "_.view" "_d" "_cur") (princ) ) Quote
DraganK Posted 7 hours ago Author Posted 7 hours ago Lisp worked in Autocad 2013 and now in Civil 2023 it doesn't work, probably it's a problem with the plugins I have. Thank you very much for your help. Quote
GLAVCVS Posted 5 hours ago Posted 5 hours ago My test was on Civil 3D 2021, in case it helps you to know. Quote
BIGAL Posted 2 minutes ago Posted 2 minutes ago Worked for me Bricscad V25. Just a comment got an error message about view may be my Bricscad. But batter worked Cannot find view: _CUR Cannot find view: _.VIEW Cannot find view: _D Cannot find view: _CUR View to restore: 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.