Have a LISP Automatically Activate

Have a LISP Automatically Activate

sneenanKFX38
Contributor Contributor
1,178 Views
8 Replies
Message 1 of 9

Have a LISP Automatically Activate

sneenanKFX38
Contributor
Contributor

Hi all!

 

So I'm new to LISP's and how they work, from what I've found and used they're great so far. I am trying something though; my company uses certain layers for multileaders and dimensions and such and I'd like that to be an automatic when a file is opened. I have a LISP file to turn it on and off, but I'd like it to just be the case when I open up to a project. I tried adding it to my acaddoc.lsp file, but maybe I didn't copy it properly. I've attached my acaddoc.lsp file and the one I would like to just work to set default layers. Any help is appreciated!

 

P.S.

Also, if anyone has a link to a lisp that counts tabs regardless of tab names that'd be great (ex: 01 of 05)! We don't use sheet set manager.

0 Likes
1,179 Views
8 Replies
Replies (8)
Message 2 of 9

scot-65
Advisor
Advisor
Without looking at your attachments.

Look into these following built in functions for the newer AutoCAD versions:
TEXTLAYER
DIMLAYER
HPLAYER
CENTERLAYER

Where these layers are not defined, these variables will create
the layers but will not set color or linetype. You will have to follow
up on this.

If you require other layer defaults, you can create a utility that
will set the desired layer, run the command, and reset the layer.
Other method would be to let the object be created in the default
environment and "Last" to the desired property.

Search within this board for phrases such as
(while (> (getvar "CMDACTIVE") 0) (command pause)) ...[or command ""]

Hope this helps.

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

Message 3 of 9

Kent1Cooper
Consultant
Consultant

Does it work if you just add this to acaddoc.lsp?

 

(load "drf")

Kent Cooper, AIA
0 Likes
Message 4 of 9

paullimapa
Mentor
Mentor

in addition to @Kent1Cooper reply after loading if you want to automatically turn it on then add this line after:

(c:reaon)

As for layout numbering, attached is TabNumber.lsp

You'll need matching Block with attribute placed on each layout for this to work.

See following thread where this is discussed:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/auto-renaming-page-number-in-layouts...

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automatic-current-sheet-numbering-in...

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-auto-page-number-layout-tabs/m-...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 9

Sea-Haven
Mentor
Mentor

Like the others for custom lisps that you want to run on start I use Appload and add a custom lisp to the Startup suite, this will run when you open or start CAD, the custom lisp can have a lot of defuns or little programs in it that you use all the time, I never change the Acaddoc.lsp. In the custom lisp you can use the Autoload function this allows you to type a command and it loads the correct lisp matching the command name. 

 

My autoload.lsp has like 23 defuns and about same autoloads.

 

 

(autoload "COPY0" '("COPY0"))
(autoload "COPYCOMMAND" '("ZZZ"))
(autoload "COVER" '("COVER"))
(autoload "DIMFLIP" '("DIMFLIP"))

 

 

Re making dims and text for one of my clients we have menu options. Behind the scenes correct layer set or added.

 

SeaHaven_0-1721275009103.png

Not sure what you want to do with count tabs

 

(setq tabs (layoutlist))
(princ (strcat "\nThere are " (rtos (length tabs) 2 0) "layout tabs "))

 

 

Message 6 of 9

sneenanKFX38
Contributor
Contributor

The tabnumber lisp is fantastic and just what I'm looking for in that regard! My only issue is that we have some tabs in the same drawing that we do not include on our outgoing drawings. By that, I mean we have our layout pages (circled in green) and then 4 extra at the end for sketches and in-house use (circled in red); I'd like to not include these in the total count. So looking at the screenshot, it would hopefully read "## of 05" instead of "## of 09". Is that a possibility or should I see about creating a separate template for these tabs? Thanks so much!

sneenanKFX38_0-1728658820629.png

 

0 Likes
Message 7 of 9

sneenanKFX38
Contributor
Contributor
I just discovered the startup suite and that makes it a lot simpler to autoload what I need. When I get more comfortable with lisps I'll mess with the acaddoc just because it'll be easier to field throughout the office. Thanks!
0 Likes
Message 8 of 9

paullimapa
Mentor
Mentor

I’d say start a separate template for those tabs 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 9

Sea-Haven
Mentor
Mentor

Are you using a server in your office as each user can point to the server so only 1 version, of the autoload.

 

Like @paullimapa you can use the layout command to import a layout from another dwg. Just use the "T" template option.

If you do these extra layouts all the time could mod the rename layouts to ask how many layouts to ignore. A simple fix.

When plotting I use "Plot by range" so can put in 1 - 8 etc and will be plotted, just ask if you want more details a lisp.

0 Likes