Jump to content

Combine lsp routine


tamipeab

Recommended Posts

I am using ACAD 2013. I am new to using lsp files. Is it possible to combine 3 lsp routines that I regularly run to prepare files for a different software program? Is it possible to use the combined lsp routine to batch process multiple files in a folder? Is it possible to modify the 1st code to open the new file automatically?

 

;changes layout to model space, appends filename, option to open new file 
(defun c:L2M ( / BASE LST OLD_DIA)
 (setq old_dia (getvar 'FILEDIA)
base (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)))
 )
 (setvar 'FILEDIA 1)
 (setq lst (layoutlist))
 (foreach l lst
   (command "_.ctab"
     l
     "exportlayout"
     (strcat base "-" l)
   )
 )
 (setvar 'FILEDIA old_dia)
 (princ)
)

 

;Sets linework to by layer, layers to color 7 white, detaches external references

(defun c:set7 ()
(setq uecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "setbylayer" "al" "" "n" "y")
(command "-layer" "c" "7" "*")
(command "-xref" "d" "*")
(setvar "cmdecho" uecho)
(princ)
)

 

;Justify text
(defun c:BL (justify title / ss)
 (princ (strcat "\nSelect *Text to " title " justify: "))
 (if (setq ss (ssget "_:L" '((0 . "ATTDEF,MTEXT,TEXT"))))
   (command "_.justifytext" ss "" justify)
 )
 (princ)
)
(defun c:JL (/) (_justifyIt "_ML" "Middle Left"))
(defun c:JC (/) (_justifyIt "_MC" "Middle Center"))
(defun c:JR (/) (_justifyIt "_MR" "Middle Right"))
(defun c:BL (/) (_justifyIt "_BL" "Bottom Left"))
(defun c:BC (/) (_justifyIt "_BC" "Bottom Center"))
(defun c:BR (/) (_justifyIt "_BR" "Bottom Right"))
(defun c:TL (/) (_justifyIt "_TL" "Top Left"))
(defun c:TC (/) (_justifyIt "_TC" "Top Center"))
(defun c:TR (/) (_justifyIt "_TR" "Top Right"))

 

I don't know who the code authors are to give credit.

Edited by tamipeab
Link to comment
Share on other sites

tamipeab,

 

#1.-Please use code wrapper when posting code.

#2.- Since all your lisp functions are defined as "c:..." you can place them all in one lisp file to load all at once.

Link to comment
Share on other sites

Open New Text Document.txt and change extension from .txt to .lsp then

copy your lisps, past them in the New Text Document.lsp then close and save your lisp.

Link to comment
Share on other sites

Easy way is to use a script can open and close as many as you like and run multiple lisps in the process.

 

open dwg1
(load "lisp1")
(load "lisp2")
close y
open dwg2
(load "lisp1")
(load "lisp2")
close y
and so on

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...