Author Topic: how to make my line command work as expected  (Read 3225 times)

0 Members and 1 Guest are viewing this topic.

danmc

  • Guest
how to make my line command work as expected
« on: March 07, 2017, 11:37:56 AM »
i am having troubles making this simple lisp routine work. here is the code:

Code: [Select]
(defun C:TDo2 ()
(setvar "osmode" 512)
(command "line" (getpoint "\n Pick Insertion Point")
(setvar "osmode" 128)(princ)
(getpoint "\n Pick Perp point")
"")
)

It creates the first line ok, but i want it  to end there. i thought that the "" would terminate the line command. what am i doing wrong?

ronjonp

  • Needs a day job
  • Posts: 7526
Re: how to make my line command work as expected
« Reply #1 on: March 07, 2017, 12:03:06 PM »
Give this a try. Welcome the TheSwamp :) .
Code - Auto/Visual Lisp: [Select]
  1. (defun c:tdo2 (/ *error* os p1 p2)
  2.   (defun *error* (msg)
  3.     ;; Reset snap setting on error
  4.     (and os (setvar 'osmode os))
  5.     (if   (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  6.       (princ (strcat "\nError: " msg))
  7.     )
  8.     (princ)
  9.   )
  10.   ;; Save current snap settings
  11.   (setq os (getvar 'osmode))
  12.   (setvar 'osmode 512)
  13.   ;; Check that both points are picked
  14.   (if (and (setq p1 (getpoint "\nPick Insertion Point: "))
  15.       (setvar 'osmode 128)
  16.       (setq p2 (getpoint p1 "\nPick Perp Point: "))
  17.       )
  18.     (entmakex (list '(0 . "Line") '(8 . "Line") (cons 10 (trans p1 1 0)) (cons 11 (trans p2 1 0))))
  19.   )
  20.   ;; Reset snap setting
  21.   (setvar 'osmode os)
  22.   (princ)
  23. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

danmc

  • Guest
Re: how to make my line command work as expected
« Reply #2 on: March 07, 2017, 01:05:20 PM »
Thanks for the welcome!

Good to be back in the saddle after 25 years away from Autocad.

There is a lot of code in your example so maybe i did a cut and paste wrong or something but I am getting an error: "; error: syntax error".

Can you look at your code (i did the cut and paste a second time, no luck) and see if there is a syntax error?

just as a note, what I am trying to accomplish (the long goal) is to cut a section of a wall and create a simple door to place in the cut wall. i made a program like this back in the day but no longer have access to that code. so to help me re-learn autolisp i thought that i would do this project.

thanks for all your help.