Silvercloak Posted March 13, 2017 Posted March 13, 2017 One of the survey bosses here is asking me for a quick Lisp to draw a line using azimuth. He wants to do it with just one command instead of using the drop down inside the line toolbar. So I figured - fine this should be easy. If I type line, and use the ZD transparent command, I can do the same thing in a lisp. Unfortunately when I use the ZD transparent command, it doesn't draw the line until I do it twice. I don't get it - why can't it do it the FIRST time as it does when I click on the toolbar button? I'm sorry, this may be a really DUMB question, but can anyone help? If this doesn't make any sense - I'll try and explain more. Let me know. Here's the really lame code that I made... which should've been enough if the command would actually WORK the first time. (defun C:LTR () (command "LINE" pause "'zd" "") (PRINC) ) Silvercloak Quote
Tharwat Posted March 13, 2017 Posted March 13, 2017 Hi, Just a guess since I know nothing about Civil program, change the "'zd" to 'zd Quote
Silvercloak Posted March 13, 2017 Author Posted March 13, 2017 Thanks, but that doesn't work. It has to remain a transparent command. If I remove the "" it completely ignores the 'zd and becomes a regular line command. Quote
Roy_043 Posted March 13, 2017 Posted March 13, 2017 Maybe this will fix the issue: (defun C:LTR () (command "_.line" "\\" "'zd") (while (/= (logand (getvar 'cmdactive) 3) 0) (command "\\")) (princ) ) Or else try this: (defun C:LTR ( / pt) (if (setq pt (getpoint "\nSpecify first point: ")) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "_.line _non (getvar 'lastpoint) 'zd ") ) (princ) ) Quote
Silvercloak Posted March 13, 2017 Author Posted March 13, 2017 Thanks Roy!! The second one worked! I wish I knew the visual basic stuff. It's like greek to me right now. Silvercloak Quote
Silvercloak Posted March 13, 2017 Author Posted March 13, 2017 Maybe this will fix the issue: (defun C:LTR () (command "_.line" "\\" "'zd") (while (/= (logand (getvar 'cmdactive) 3) 0) (command "\\")) (princ) ) Or else try this: (defun C:LTR ( / pt) (if (setq pt (getpoint "\nSpecify first point: ")) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "_.line _non (getvar 'lastpoint) 'zd ") ) (princ) ) Sorry I spoke too soon. I think that 'lastpoint in there is messing things up. Whenever I run this command it's not using the getpoint that I gave it, instead it's going to the lastpoint I clicked BEFORE I ran this command. I'm trying to figure out the correct... replacement to your (getvar 'lastpoint) there but I'm not doing so great. silvercloak Quote
Roy_043 Posted March 13, 2017 Posted March 13, 2017 In BricsCAD the getpoint function updates the lastpoint variable. It seems that AutoCAD fails to do so. Revised code: (defun C:LTR ( / pt) (if (setq pt (getpoint "\nSpecify first point: ")) (progn (setvar 'lastpoint pt) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "_.line _non (getvar 'lastpoint) 'zd ") ) ) (princ) ) Quote
Silvercloak Posted March 13, 2017 Author Posted March 13, 2017 OMG I can't believe I didn't think of that. So frigging simple. I'm SO rusty. Thanks Roy. Silvercloak 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.