+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Forum Newbie
    Using
    AutoCAD LT 2012
    Join Date
    Mar 2012
    Location
    Pullman, WA
    Posts
    5

    Default Combine lsp routine

    Registered forum members do not see this ad.

    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?

    Code:
    ;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)
    )
    Code:
    ;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)
     )
    Code:
    ;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.
    Last edited by tamipeab; 28th Feb 2014 at 06:15 pm.

  2. #2
    Senior Member
    Computer Details
    Snownut's Computer Details
    Operating System:
    Windows 10 Home premium
    Computer:
    Lenovo
    Using
    not applicable
    Join Date
    Nov 2010
    Location
    New Hampshire
    Posts
    238

    Default

    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.

  3. #3
    Forum Newbie
    Using
    AutoCAD LT 2012
    Join Date
    Mar 2012
    Location
    Pullman, WA
    Posts
    5

    Default

    What is code wrapper? I've tried combining them but I don't know enough about lsp writing to make it work.

  4. #4
    Senior Member
    Computer Details
    Snownut's Computer Details
    Operating System:
    Windows 10 Home premium
    Computer:
    Lenovo
    Using
    not applicable
    Join Date
    Nov 2010
    Location
    New Hampshire
    Posts
    238

  5. #5
    Senior Member mostafa badran's Avatar
    Computer Details
    mostafa badran's Computer Details
    Operating System:
    win 7
    Computer:
    Dell
    CPU:
    Core I7
    RAM:
    12 GB
    Graphics:
    2 GB
    Primary Storage:
    350 GB
    Monitor:
    Fujitsu
    Discipline
    Electrical
    mostafa badran's Discipline Details
    Occupation
    Cad Operator
    Discipline
    Electrical
    Details
    Power & low current system.
    Using
    AutoCAD 2014
    Join Date
    May 2010
    Location
    KSA
    Posts
    231

    Default

    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.
    What doesn't kill you makes you stronger

  6. #6
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,716

    Default

    Registered forum members do not see this ad.

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

    Code:
    open dwg1
    (load "lisp1")
    (load "lisp2")
    close y
    open dwg2
    (load "lisp1")
    (load "lisp2")
    close y
    and so on
    A man who never made mistakes never made anything

Similar Threads

  1. combine 2 or more dwg in one
    By hosyn in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 9th Jul 2014, 05:10 am
  2. Combine three lisp routine into one routine.
    By BrianTFC in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 7th Feb 2012, 05:11 pm
  3. combine xref to dwg
    By sparkyuk in forum AutoCAD Beginners' Area
    Replies: 10
    Last Post: 23rd Oct 2009, 05:52 pm
  4. Combine IF
    By FazBear in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 20th May 2009, 10:11 am
  5. How can I combine 4 drawings into 1?
    By BOB'27T in forum AutoCAD Drawing Management & Output
    Replies: 11
    Last Post: 6th May 2008, 05:50 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts