Gaudencio Posted September 15 Posted September 15 Hello good afternoon, First of all, I apologize but I don't have any kind of training in programming and I try to get by with the tools I have at my disposal (forums, YouTube, AI,...) I am a topographic engineer and I needed a lisp that would draw the grid the way I wanted, I have already developed much of it using the methods mentioned above but now I am stuck in creating the coordinate text. According to my analysis, it must be the justification of the text, I say this because even doing an isolated test on the creation of the text (entmake) the justification remains by default. The following image is a representation of the final result. I'll leave my humble lines of code attached so that a kind soul can help me Thank you for taking the time to read the post Grid__.lsp Quote
Saxlle Posted September 15 Posted September 15 (edited) Hi Gaudencio, I looked up in your "Grid__.lsp" and there is few things: - in my opinion I would exclude it 72 and 73 codes in "create-text" subfunction, because of this: If group 72 and/or 73 values are nonzero, then the first alignment point values are ignored and AutoCAD calculates new values based on the second alignment point and the length and height of the text string itself (after applying the text style). If the 72 and 73 values are zero or missing, then the second alignment point is meaningless. (https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-62E5383D-8A14-47B4-BFC4-35824CAE8363). If you leave the 72 and 73 codes, then you need to calculate a "good" second alignment point and include of (cons 11 "second points") in "create-text" subfunction. - so, when 72 and 73 code are excluded, the "create-text" subfunction will look this: (defun create-text (pos height rotation content) (entmake (list (cons 0 "TEXT") (cons 8 *layer*) ; Define the layer (cons 10 pos) ; Text position (cons 40 height) ; Text height (cons 50 rotation) ; Text rotation (cons 1 content) ; Text content )) ) - and then will look like this for creating a text (for rotation you need to define a rotation in radians, otherwise you need to create a subfunction to convert deegres in radians) ;; Draw the coordinate text in the corners ;; Bottom-left corner (create-text (list (+ minx 2) (+ miny 0.5)) text-size 0 (format-text-x minx)) ; X coordinate (Bottom Left) (create-text (list (+ minx 0.5) (+ miny 2)) text-size (/ pi 2) (format-text-y miny)) ; Y coordinate (Top Left) ;; Bottom-right corner (create-text (list (- maxx 2) (+ miny 0.5)) text-size 0 (format-text-x maxx)) ; X coordinate (Bottom Right) (create-text (list (- maxx 0.5) (+ miny 2)) text-size (/ pi 2) (format-text-y miny)) ; Y coordinate (Top Right) ;; Top-right corner (create-text (list (- maxx 2) (- maxy 0.5)) text-size 0 (format-text-x maxx)) ; X coordinate (Top Right) (create-text (list (- maxx 0.5) (- maxy 2)) text-size (+ pi (/ pi 2)) (format-text-y maxy)) ; Y coordinate (Top Right) ;; Top-left corner (create-text (list (+ minx 2) (- maxy 0.5)) text-size 0 (format-text-x minx)) ; X coordinate (Top Left) (create-text (list (+ minx 0.5) (- maxy 2)) text-size (+ pi (/ pi 2)) (format-text-y maxy)) ; Y coordinate (Top Left) For improvement of code, try to play with length of string to calculate a "good" positon of X and Y inside of grid based on variables "minx, maxx, miny and maxy". This will replace a "justification" of the text. Best regards. Edited September 15 by Saxlle Quote
BIGAL Posted September 15 Posted September 15 (edited) I have another it draws grids in layout paperspace by picking a view port. It includes drawing the grids on rotated views. Let me know if interested. Have you looked at using just plain command as you can do the justification when adding the text. You are only drawing 8 text so will be instant. Example code. (command "TEXT" "J" "BL" (getpoint "\nPick pt ") 2.5 90 (getstring "\nType text " T) ) Edited September 15 by BIGAL Quote
symoin Posted September 17 Posted September 17 On 9/16/2024 at 2:28 AM, BIGAL said: I have another it draws grids in layout paperspace by picking a view port. It includes drawing the grids on rotated views. Let me know if interested. Have you looked at using just plain command as you can do the justification when adding the text. You are only drawing 8 text so will be instant. Example code. (command "TEXT" "J" "BL" (getpoint "\nPick pt ") 2.5 90 (getstring "\nType text " T) ) YES PLEASE SHARE THE LISP CODE; THANKS Quote
BIGAL Posted September 18 Posted September 18 Send me a PM and can talk more, without bloating the post. 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.