Jump to content

Dim Layer lisp


ankurpraja

Recommended Posts

Hello,

I have this lisp routine to create any dimension in a particular layer regardless of what the current layer is. And in this lisp there a provision to start and stop this function. Which i don't want.

 

Can anyone help me removing this start/stop function? Which means once i load the app, it is already active. No additional command required to start and stop. I am not at all familiar with Autolisp so don't know how to do it.

 

And is it possible to preload any lisp when creating new file or opening existing file?

 

 

(vl-load-com)

(defun DimReactor:Start ()
 (or *DimReactor*
     (setq *DimReactor*
            (vlr-command-reactor
              nil
              '(
                (:vlr-commandcancelled . DimReactor:CommandEnded)
                (:vlr-commandended . DimReactor:CommandEnded)
                (:vlr-commandfailed . DimReactor:CommandEnded)
                (:vlr-commandwillstart . DimReactor:CommandWillStart)
               )
            )
     )
 )
 (prompt "\nDimension reactor loaded. ")
 (princ)
)

(defun DimReactor:CommandEnded (rea cmd)
 (if
   (and
     *DimReactorLayer*
     (wcmatch
       (strcase (car cmd))
       "DIMA*,DIMB*,DIMC*,DIMD*,DIMI*,DIMJ*,DIML*,DIMO*,DIMR*,DIMSP*,QDIM"
     )
   )
    (progn
      (setvar 'clayer *DimReactorLayer*)
      (setq *DimReactorLayer* nil)
    )
 )
)

(defun DimReactor:CommandWillStart (rea cmd / layerName)
 (if
   (wcmatch
     (strcase (car cmd))
     "DIMA*,DIMB*,DIMC*,DIMD*,DIMI*,DIMJ*,DIML*,DIMO*,DIMR*,DIMSP*,QDIM"
   )
    (progn
      (setq *DimReactorLayer* (getvar 'clayer))
      (vla-add
        (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
        (setq layerName "Dimension Line")
      )
      (setvar 'clayer layerName)
    )
 )
)

(defun c:DimReactorStart ()
 (DimReactor:Start)
)

(defun c:DimReactorStop ()
 (if *DimReactor*
   (progn
     (vlr-remove *DimReactor*)
     (setq *DimReactor* nil)
   )
 )
 (prompt "\n** Dimension reactor stopped ** ")
 (princ)
)

;; Uncomment next line to start automatically.
;;(DimReactor:Start)
(princ)

Edited by ankurpraja
Link to comment
Share on other sites

Hi,

 

Please modify your post by adding Codes tags [#] so just select your codes and hit the hatch button # and automatically would wrap the codes.

 

Remove the two commands

<c:Dimreactorstart , c:Dimreactorstop>

with all their codes and just add the following function at the end of your lisp file.

 

(dimreactor:start)

 

To run the codes automatically on start up, just add the codes into you acaddoc.lsp that should be existed into your Support Folder.

Link to comment
Share on other sites

It looks like Tharwat has already got you back on the tracks, but fyi, one of my favorite LeeMac lisps is LAYER DIRECTOR.

 

Everyone on the planet should be using it, seriously.

 

It will do this for you, among other very useful things, like putting all Text on your TEXT layer (or wherever you tell it to, in advance), all your Viewports on a particular layer.

If the layer that is specified in the lisp doesn't yet exist in the drawing, it will create the layer, with the settings you have defined when setting up the lisp for your own personal needs. For instance, you probably want all your LEADERS on which layer?

Check out the link, it is absolutely awesome.

Thanks Lee! :beer:

You just need to give a little thought to what commands you want defined for any given layer, and the color and name for the layers.

This lisp works on the fly, you don't need to think about it, it will put things where you told it to, without any user interaction, and go right back to the layer you were on before calling whichever command, maybe DimRadial, for instance.

If you are like me, you will want this to LOAD automatically, so you never need to think about layers again.

I have loaded it into the Startup Suite, so everytime I boot up Autocad, it comes along for, and really smooths out the ride.

One can easily see the high regard I have for LeeMac's fine work.

Probably 95% of the lisps in my lisp directory are his, and for good reason, they ROCK!

Thanks again Lee! :beer:

 

In order to better understand what this lisp does, and how to personalize it for your preferences, download it to your LISP folder, then open it with NOTEPAD. Lee includes a very helpful description of what it does.

My Layer Director personal presets.JPG

load lisp into your Startup Suite.jpg

Edited by Dadgad
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...