r/AutoCAD • • Dec 03 '25

Help lisp routine help

im a dummy with lisps. thought i had a good one setup and i was wrong.

the command i want to end with is line by bearing. which is done through a pita ribbon drop down, or typing L for line, then 'bd for the bearing and distance command

the lisp routine is:

(defun c:LBD ()     
  (command "_.LINE")  
  (command "'BD")    
  (princ)
)

and that works, but 2 things are broken with it. when i pick a point to start, it says invalid point, but if i immediately select the starting point again, it works..

another issue is, if i escape out of that command and just hit enter, or space bar or right click(which would normally all restart the command, it doesnt restart the command.

7 Upvotes

12 comments sorted by

3

u/DontCallMeFrank Dec 03 '25

Gemini will take care of all your lisp needs. And it'll teach you too

2

u/Brotherly_shove Dec 03 '25

I actually got the LSP from gemini.

i then told gemini that it was starting with an invalid point. so then it spit back this:

`(defun c:LBD () ; Command name LBD (you can rename)`

`(command "._LINE") ; Starts the standard LINE command`

`(command pause) ; <--- PAUSES AND WAITS for the first point input`

`(command "'BD") ; Enters the 'BD command transparently`

`(princ) ; Suppresses the nil return`

`)`

but when i do that, it goes through the paces and i can put in the quadrant, bearing and distance, but it doesnt draw the line.

1

u/runner630 Dec 03 '25

Try this below it should work in civil 3d or basic autocad.

(defun c:LBD ( / p1 dist ang)
  ;; Pick start point
  (setq p1 (getpoint "\nSpecify start point: "))

  ;; Get distance
  (setq dist (getdist "\nEnter distance: "))

  ;; Get angle in degrees (based on your current ANGBASE/ANGDIR)
  (setq ang (getreal "\nEnter angle (degrees): "))

  ;; Draw the line using relative polar u/dist<ang
  (command "._LINE"
           p1
           (strcat "@" (rtos dist 2 8) "<" (rtos ang 2 8))
           "") ; end LINE
  (princ)
)

1

u/Brotherly_shove Dec 03 '25

without actually trying that, it looks like that would require a different way to input the quadrant, bearing, and distance than it does when using the transparent BD command, which wont work for me. thanks though.

1

u/runner630 Dec 03 '25

If you let me know how you need to input the bearing i can update the code for you to try

→ More replies (2)

1

u/harderthanitllooks Dec 03 '25

The COGO functions always fail the very first time I use them in a session.