Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Redefining dimensions on startup

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
435 Views, 7 Replies

Redefining dimensions on startup

I have the following lisp:

(defun S::STARTUP()
(command (setvar "cmdecho" 0))
(command "-layer" "new" "A-Anno-Dims" "C"
"11" "A-Anno-Dims" "L" "Continuous"
"A-Anno-Dims" ""
)
;;;DIMALIGNED
(command "_undefine" ".acad_dim.dimaligned")
(defun c:dimaligned ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimaligned" pause pause pause ".layerp")
)
;;;DIMANGULAR
(command "undefine" ".acad_dim.dimangular")
(defun c:dimangular ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimangular" pause pause pause ".layerp")
)
;;;DIMARC
(command "undefine" ".acad_dim.dimarc")
(defun c:dimarc ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimarc" pause pause ".layerp")
)
;;;DIMBASELINE
(command "undefine" ".acad_dim.dimbaseline")
(defun c:dimbaseline ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimbaseline")
)
;;;DIMCONTINUE
(command "undefine" ".acad_dim.dimcontinue")
(defun c:dimcontinue ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimcontinue")
)
;;;DIMDIAMETER
(command "undefine" ".acad_dim.dimdiameter")
(defun c:dimdiameter ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimdiameter" pause pause ".layerp")
)
;;;DIMLINEAR
(command "undefine" ".acad_dim.dimlinear")
(defun c:dimlinear ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimlinear" pause pause pause ".layerp")
)
;;;DIMJOGGED
(command "undefine" ".acad_dim.dimjogged")
(defun c:dimjogged ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimjogged" pause
pause pause pause
".layerp"
)
)
;;;DIMJOGLINE
(command "undefine" ".acad_dim.dimjogline")
(defun c:dimjogline ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimjogline" pause pause ".layerp")
)
;;;DIMRADIUS
(command "undefine" ".acad_dim.dimradius")
(defun c:dimradius ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimradius" pause pause ".layerp")
(princ)
)
;;;THE FOLLOWING ROUTINE WILL REDEFINE THE MTEXT & DTEXT COMMANDS
;;;TO MAKE THE LAYER A-ANNO-NOTE CURRENT RUN THE TEXT
;;;COMMAND & SET THE PREVIOUS LAYER CURRENT
;;;First updated 2008-05-01
;;;Last updated 2008-06-23
(command "-layer" "new" "A-Anno-Note" "C"
"white" "A-Anno-Note" "L" "Continuous"
"A-Anno-Note" ""
)
;;;MTEXT
(command "undefine" "Mtext")
(defun c:Mtext ()
(command "-layer" "Thaw" "A-Anno-Note" "ON" "A-Anno-Note" "")
(setvar 'clayer "A-Anno-Note")
(initdia)
(command ".acad_mtext.mtext" pause pause "_layerP")
)
(command "undefine" "Dtext")
(defun c:Dtext ()
(command "-layer" "Thaw" "A-Anno-Note" "ON" "A-Anno-Note" "")
(setvar 'clayer "A-Anno-Note")
(command ".Dtext" pause pause pause "_LayerP")
)
(defun c:Dt ()
(command "-layer" "Thaw" "A-Anno-Note" "ON" "A-Anno-Note" "")
(setvar 'clayer "A-Anno-Note")
(command ".Dtext" pause pause pause "_LayerP")
(princ)
)
)

I have added it to my acad2008doc.lsp file. The idea of the lisp is that it will ensure that text is placed on the layer A-Anno-Note and dimensions are placed onto the layer A-Anno-Dims.

In the first drawing (template or opened drawing from explorer) the Text commands are redefined but the Dimension commands are not. In all subsequent drawings both the text and the dimensions commands are redefined.

I am guessing that the dimensions are loaded into autoCAD later in the run of things that the acad2008doc.lsp file.

i have tried placing the code into acad2008.lsp and the acad.mnl file with the same results.

i also tried placing it in its own file in a support directory, no luck.

Can anyone recommend another way of loading this to get it to work on the first drawing?

Thanks In Advance

Drew
North Vancouver
7 REPLIES 7
Message 2 of 8
EC-CAD
in reply to: Anonymous

I don't know if it will work as expected.. but you could try
putting all that code into acaddoc.lsp, and remove the
over-all (defun S::STARTUP .... and the closing )
.. I think that would fire-up on every drawing, including the
first..

Bob
Message 3 of 8
Anonymous
in reply to: Anonymous

Thanks Bob, unfortunately not, its the 2nd drawing again that it starts working on correctly.

Another direction i am thinking of now, prehaps I can force load the origional dimension arx's or whatever they are prior to redefining them.... does that sounds logical?

Drew
Message 4 of 8
EC-CAD
in reply to: Anonymous

Oh, I see what you mean. You need to redefine
some commands that aren't quite 'loaded' yet.
Hmmm.
I guess I can't help out there.
Maybe force SDI=1

Bob
Message 5 of 8
Anonymous
in reply to: Anonymous

That did it...

(arxload "acdim.arx")

I put this in front of the other junk and it all worked great.

Drew
Message 6 of 8
EC-CAD
in reply to: Anonymous

I'll have to make a note of that.

:)
Bob
Message 7 of 8
Anonymous
in reply to: Anonymous

1)Never modify acad2008doc.lsp. Its not yours to modify. Use acaddoc.lsp
instead.
2)Undefining all the dim commands and defining your own will lose all the
flexibility of the built-in commands. Layer management will probably work
better with some sort of reactors or code at close to sort entities to
target layers. Tool palettes work very well also.
3) using defun to define s:startup is a mistake because it won't work well
with other lsp files loaded that also create/add to s::startup file. See
the developer help for explanation. Use this as an example instead
(incomplete)
(defun-q acaddocstart () ;in acaddoc.lsp
;;This attempts to use a dim command and cancels
;;It is one way to load the dim module before undefining.
(command "dimlinear")(command)(command)
(command "undefine" "dimaligned" "undefine"
"dimangular" "undefine" "dimarc"
"undefine" "dimbaseline" "undefine"
"dimcontinue" "undefine" "dimdiameter"
"undefine" "dimlinear" "undefine"
"dimjogged" "undefine" "dimjogline"
"undefine" "dimradius"
)
;;other code to define the new command versions
)
;;add your startup to the s::startup code with setq.
(setq s::startup (append s::startup acaddocstart))

wrote in message news:5975965@discussion.autodesk.com...
I have the following lisp:

(defun S::STARTUP()
(command (setvar "cmdecho" 0))
(command "-layer" "new" "A-Anno-Dims" "C"
"11" "A-Anno-Dims" "L" "Continuous"
"A-Anno-Dims" ""
)
;;;DIMALIGNED
(command "_undefine" ".acad_dim.dimaligned")
(defun c:dimaligned ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimaligned" pause pause pause ".layerp")
)
;;;DIMANGULAR
(command "undefine" ".acad_dim.dimangular")
(defun c:dimangular ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimangular" pause pause pause ".layerp")
)
;;;DIMARC
(command "undefine" ".acad_dim.dimarc")
(defun c:dimarc ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimarc" pause pause ".layerp")
)
;;;DIMBASELINE
(command "undefine" ".acad_dim.dimbaseline")
(defun c:dimbaseline ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimbaseline")
)
;;;DIMCONTINUE
(command "undefine" ".acad_dim.dimcontinue")
(defun c:dimcontinue ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimcontinue")
)
;;;DIMDIAMETER
(command "undefine" ".acad_dim.dimdiameter")
(defun c:dimdiameter ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimdiameter" pause pause ".layerp")
)
;;;DIMLINEAR
(command "undefine" ".acad_dim.dimlinear")
(defun c:dimlinear ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimlinear" pause pause pause ".layerp")
)
;;;DIMJOGGED
(command "undefine" ".acad_dim.dimjogged")
(defun c:dimjogged ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimjogged" pause
pause pause pause
".layerp"
)
)
;;;DIMJOGLINE
(command "undefine" ".acad_dim.dimjogline")
(defun c:dimjogline ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimjogline" pause pause ".layerp")
)
;;;DIMRADIUS
(command "undefine" ".acad_dim.dimradius")
(defun c:dimradius ()
(command "-layer" "Thaw" "A-Anno-Dims" "ON" "A-Anno-Dims" "")
(setvar 'clayer "A-Anno-Dims")
(command ".acad_dim.dimradius" pause pause ".layerp")
(princ)
)
;;;THE FOLLOWING ROUTINE WILL REDEFINE THE MTEXT & DTEXT COMMANDS
;;;TO MAKE THE LAYER A-ANNO-NOTE CURRENT RUN THE TEXT
;;;COMMAND & SET THE PREVIOUS LAYER CURRENT
;;;First updated 2008-05-01
;;;Last updated 2008-06-23
(command "-layer" "new" "A-Anno-Note" "C"
"white" "A-Anno-Note" "L" "Continuous"
"A-Anno-Note" ""
)
;;;MTEXT
(command "undefine" "Mtext")
(defun c:Mtext ()
(command "-layer" "Thaw" "A-Anno-Note" "ON" "A-Anno-Note" "")
(setvar 'clayer "A-Anno-Note")
(initdia)
(command ".acad_mtext.mtext" pause pause "_layerP")
)
(command "undefine" "Dtext")
(defun c:Dtext ()
(command "-layer" "Thaw" "A-Anno-Note" "ON" "A-Anno-Note" "")
(setvar 'clayer "A-Anno-Note")
(command ".Dtext" pause pause pause "_LayerP")
)
(defun c:Dt ()
(command "-layer" "Thaw" "A-Anno-Note" "ON" "A-Anno-Note" "")
(setvar 'clayer "A-Anno-Note")
(command ".Dtext" pause pause pause "_LayerP")
(princ)
)
)

I have added it to my acad2008doc.lsp file. The idea of the lisp is that it
will ensure that text is placed on the layer A-Anno-Note and dimensions are
placed onto the layer A-Anno-Dims.

In the first drawing (template or opened drawing from explorer) the Text
commands are redefined but the Dimension commands are not. In all subsequent
drawings both the text and the dimensions commands are redefined.

I am guessing that the dimensions are loaded into autoCAD later in the run
of things that the acad2008doc.lsp file.

i have tried placing the code into acad2008.lsp and the acad.mnl file with
the same results.

i also tried placing it in its own file in a support directory, no luck.

Can anyone recommend another way of loading this to get it to work on the
first drawing?

Thanks In Advance

Drew
North Vancouver
Message 8 of 8
scot-65
in reply to: Anonymous

If SDI=0, then you need to set the following:
ACADLSPADOC=1 Loads ACAD.lsp every time (overrides LISPINIT).
LISPINIT=1 Loads ACAD.lsp for current session only.

Of course you will need to rename your file to ACAD.lsp to do this.
As shown from another reply, S::STARTUP is not necessary unless you execute a command while the editor is starting up (example Zoom Extents). S:STARTUP is the very last section to load during the starting process.

Have a look at this... it will not limit the commands inside your routines:
(command "DText")(while (> (getvar "cmdactive") 0) (command pause) )

Instead of redefining the commands, create shortcut keystrokes (similar to the PGP file). Once these routines are on the keyboard, it is just a matter of incorporating these into the Screen Menu, pull-down or toolbar areas (and design center). You have the advantage of already having the images for the dimension toolbar buttons... just recreate your own.

Good Luck!

Two hands working the editor is always faster than one.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost