Jump to content

Need lsp for auto ortho


sajid

Recommended Posts

I imagine that every time the OP draws a line or a polyline he wants AutoCAD to automatically assume that it will be drawn with Orthomode enabled. Think of it as an enhanced Line and/or Polyline command.

Link to comment
Share on other sites

Add the following to your acaddoc.lsp:

(defun c:auto-ortho-on nil
   (if (= 'vlr-command-reactor (type auto-ortho:reactor))
       (if (not (vlr-added-p auto-ortho:reactor))
           (vlr-add auto-ortho:reactor)
       )
       (setq auto-ortho:reactor
           (vlr-command-reactor nil
              '(
                   (:vlr-commandwillstart . auto-ortho:callback)
                   (:vlr-commandended     . auto-ortho:restore)
                   (:vlr-commandcancelled . auto-ortho:restore)
                   (:vlr-commandfailed    . auto-ortho:restore)
               )
           )
       )
   )
   (princ "\nAuto-Ortho Reactor enabled.")
   (princ)
)
(defun c:auto-ortho-off nil
   (if (= 'vlr-command-reactor (type auto-ortho:reactor))
       (vlr-remove auto-ortho:reactor)
   )
   (setq auto-ortho:reactor nil)
   (princ "\nAuto-Ortho Reactor disabled.")
   (princ)
)
(defun auto-ortho:callback ( obj arg )
   (if (wcmatch (strcase (car arg) t) "line,pline")
       (progn
           (setq auto-ortho:ortho (getvar 'orthomode))
           (setvar 'orthomode 1)
       )
   )
   (princ)
)
(defun auto-ortho:restore ( obj arg )
   (if (= 'int (type auto-ortho:ortho))
       (setvar 'orthomode auto-ortho:ortho)
   )
   (setq auto-ortho:ortho nil)
   (princ)
)
(vl-load-com) (c:auto-ortho-on)

The reactor is enabled by default; you can then manually enable/disable the reactor using the commands: auto-ortho-on & auto-ortho-off.

 

Orthomode will be enabled for the LINE & PLINE commands (the commands to trigger the reactor may be customised to suit).

 

Lee

Edited by Lee Mac
Link to comment
Share on other sites

I believe since AutoCAD 2012, once you've initiated a command (LINE, COPY, MOVE, etc) and picked your first point, hold the Shift key down and after one second, Ortho is enabled temporarily and vice versa if ORTHOMODE is 1 (enabled) it will temporarily disable Ortho. I tested in 2013 and 2014 and it works in both of those.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...