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.lspFetching info... 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.lspFetching info... 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.lspFetching info... tick.dwgFetching info... 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 Friday at 12:51 PM Author Posted Friday at 12:51 PM (edited) Heelp Edited Friday at 12:54 PM by DraganK Quote
GLAVCVS Posted Friday at 01:18 PM Posted Friday at 01:18 PM Hi Attach a drawing with which your code works 1 Quote
DraganK Posted Friday at 01:45 PM Author Posted Friday at 01:45 PM (edited) batter 4 digits.dwg batter 9 and 7 digits.dwg Thanks for help. Edited Friday at 01:46 PM by DraganK Quote
DraganK Posted Friday at 02:00 PM Author Posted Friday at 02:00 PM On 2/28/2025 at 1:52 PM, GLAVCVS said: Does your drawing contain blocks? Expand 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 Friday at 02:21 PM Posted Friday at 02:21 PM 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 Friday at 02:24 PM Author Posted Friday at 02:24 PM On 2/28/2025 at 2:21 PM, 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? Expand Using English version Civil 3d 2023. Quote
GLAVCVS Posted Friday at 02:35 PM Posted Friday at 02:35 PM 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 Friday at 02:55 PM Author Posted Friday at 02:55 PM 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 Friday at 04:09 PM Posted Friday at 04:09 PM My test was on Civil 3D 2021, in case it helps you to know. Quote
BIGAL Posted Friday at 09:55 PM Posted Friday at 09:55 PM 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
marko_ribar Posted 11 hours ago Posted 11 hours ago On 2/28/2025 at 9:55 PM, BIGAL said: 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: Expand Just guessing... This line : (command "_.view" "_s" "_.cur") Should be (without point after _ and brfore "cur") : (command "_.view" "_s" "_cur") 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.