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 February 28 Author Posted February 28 (edited) Heelp Edited February 28 by DraganK Quote
DraganK Posted February 28 Author Posted February 28 (edited) batter 4 digits.dwg batter 9 and 7 digits.dwg Thanks for help. Edited February 28 by DraganK Quote
DraganK Posted February 28 Author Posted February 28 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 February 28 Posted February 28 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 February 28 Author Posted February 28 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 February 28 Posted February 28 (edited) 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.001) "") (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.001)) (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.001 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.001 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)) ) ) (alert "Without Sset") ) (command "_.undo" "_en") ) (setvar "clayer" oldlay) (command "_.view" "_r" "_cur") (command "_.view" "_d" "_cur") (princ) ) Edited March 3 by GLAVCVS Quote
DraganK Posted February 28 Author Posted February 28 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 February 28 Posted February 28 My test was on Civil 3D 2021, in case it helps you to know. Quote
BIGAL Posted February 28 Posted February 28 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 March 2 Posted March 2 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
DraganK Posted March 3 Author Posted March 3 Dear friends, thank you for your help and testing Lisp. Today I tried to draw slopes in one drawing in two places, the first place is a line with 4-digit coordinates and it works great, and the second place is a line with 9-digit coordinates and it does not draw slopes. So I believe that the problem with my Civil 3D 2023 is in some setting. Thanks again for testing. Quote
GLAVCVS Posted March 3 Posted March 3 On 3/3/2025 at 1:47 PM, DraganK said: Dear friends, thank you for your help and testing Lisp. Today I tried to draw slopes in one drawing in two places, the first place is a line with 4-digit coordinates and it works great, and the second place is a line with 9-digit coordinates and it does not draw slopes. So I believe that the problem with my Civil 3D 2023 is in some setting. Thanks again for testing. Expand Try this: I've modified the previous code I tried to display a message if there is no selection set. Copy the code again and test it. If it doesn't display an alert with the message 'Without Sset' try something else: do a 'zoom extents' to make sure the code didn't draw the lines too far away. Did I explain myself correctly? 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.