Jump to content

Multiple Layouts in one file pls help me


sephiroth11983

Recommended Posts

Greetings,

 

i hope someone can help me concerning multiple layouts.

im just new to autolisp and im trying to create a lisp that can make multiple layouts in one file.. and will be renamed by numbers. (ex. is layouts 1001-1050)

 

 

i tried to use someone's lisp here but it also has problems.

 

 

 

im trying to remove the create a template since all i need to do is make the first layout (ex is 1001). then copy it upto the required number of layouts im gonna do...it is to time consuming copying,renaming, move to end the first layout expecially when making 100+ layouts in one file. can some help me do a string that i can use to just add a number to the first layout name upto to my required number of layouts... (ex is il make layout 1001. then the lisp will just do 1002,1003,1004 upto the desired number of layouts.)

 

im trying to make it but i still dont understand the use of substr, and the other text concerning the usage.

 

thanks you sirs.

 

Sephiroth11983

 

Note: Sorry i removed the code because i dont know here my vbulettin navigation bar is..so i cant place the code in its proper format..sorry for the honest mistake...i should have read the guidelines first before posting any messages...

 

But i do appreciate and thank the people who are always open to help..and really helped me concerning LISP and sharing their knowledge. thank you PbE and Bigal. sorry for the problems moderators and admins.

 

(defun C:lrnp ( / lnum tnum lname lnamec lname2 lname3 lname4 lname5 lname6 lname7 lname8 tmplt)
(setvar "tilemode" 1) ;changes to model space
(setq lnum(getint "\Ilang Sheets ang gusto mong gawin? How many Sheets? ")) ;prompt for number of layouts
(setq tnum(1- lnum))
(setq lname(getstring "\What is the naming convention (ie E1.1) :")) ;get naming convention
(setq lnamec(strlen lname)) ;counts number of characters in naming convention
(setq lname2(substr lname lnamec)) ;takes the last character of naming convention
(setq lname4(atoi lname2))
(setq lname8(+ lname4 lnum))
(SETQ TMPLT(GETSTRING "\SELECT LAYOUT FOR TEMPLATE (8.5x11) (11x17) (24x36): " )) ;requests paper size
(COMMAND "LAYOUT" (WRITE-LINE "T" SCRFILE) (WRITE-LINE "NTL Project Template (May 2010).dwt" SCRFILE) (WRITE-LINE TMPLT SCRFILE)) ;gets layout from main templait
(command "layout" (write-line "r" scrfile) (write-line tmplt scrfile) (write-line lname scrfile)) ;rename first created layout
(setq lname5(substr lname 1 (1- lnamec)))
(repeat tnum
   (setq lname8 (1- lname8 ))
   (setq lname6(itoa lname8 ))
   (setq lname7(strcat lname5 lname6))
   (command "layout" (write-line "c" scrfile) (write-line lname scrfile) (prin1 lname7)) ;copys layouts
   )
(princ "\Type 'LRNP' to run")    

(PRINC)
)

 

again this code is owned by another person, sorry i forgot who i got this from..i tried using his code as a background and study..then used masters Pbe and Bigals for new references..and new studies..i also wanna thank the person who made the original code...the LRNP command he made..

 

i guess i panicked when a moderator wanred me..i just saw where the # click for making the code..hahaha

Edited by sephiroth11983
due to posting guidelines
Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • sephiroth11983

    7

  • pBe

    6

  • BIGAL

    3

  • SLW210

    2

If you are starting from a new drawing it could be as simple as this:

 

(defun c:mkl (/ cnt lnum)
 (setvar 'cmdecho 0)
 (while
   (progn
     (initget 7)
     (setq cnt	 1000
    lnum (getint "\nHow Many Layouts: ")
     )
     (if (<= lnum (length (layoutlist)))
(princ "\nNumber is below/equal current number of Layout:")
nil
     )
   )
 )
 (foreach itm (layoutlist)
   (command "layout"
     "rename"
     itm
     (strcat (itoa (setq cnt (1+ cnt))))
   )
 )
 (repeat (- lnum (length (layoutlist)))
   (command "layout" "new" (strcat (itoa (setq cnt (1+ cnt)))))
 )
 (princ)
)

 

EDIT:

Is there a situation that you need to add a layout on an existing drawing? were your layout tabs always have that name convention?

 

The code posted above will still work only problem is the list generated by (layoutlist) will be sorted automatically, and that isn't always good. (but in your case i think its okay)

Edited by pBe
Link to comment
Share on other sites

this is a great lisp, a good guide for me the study...mostly we make the first layout first then we make multiple layout copies from that.... how can i copy that layout sir? im still reading the basics of lee-mac.. (coz im a noob T_T) i hope someone can send me a guide about how to make the lisp..expecially if its complicated like this...

 

but what u gave me really game me more guide..il study this..thanks Master pBe

Link to comment
Share on other sites

this is a great lisp, a good guide for me the study...mostly we make the first layout first then we make multiple layout copies from that.... how can i copy that layout sir? im still reading the basics of lee-mac.. (coz im a noob T_T) i hope someone can send me a guide about how to make the lisp..expecially if its complicated like this...

 

but what u gave me really game me more guide..il study this..thanks Master pBe

 

Come to think of it, all i did was create a new layout. :lol: Copy a layout you say? its easy really. but do this apply to new drawings only? for an existing one, do you copy the first layout tab [1001] or the last?

Link to comment
Share on other sites

actually, i make the first layout, place the titleblock then viewport then callouts.. then i copy that first layout named 1001....upto example 150 layouts(depends on size of project)... and i do that copy layout again and again and again then rename rename move to end etc... than i tried to edit a certain lsp but its still complicated for me...

 

then i make another layout from new file named 2001..then do it again upto example 150 again.. (2001,2002,2003,2004 layout names)

 

i can use ur lisp the first you gave me..then i found an lsp copying all items in one layout then paste all in the other layouts.for now, thats what im doing.

 

im reading beginner's tutorial in lisp thru pdf..coz im not yet familiar in making complex command..all i know is create basic commands like make a greeting (the alert statement ) hahaha

Link to comment
Share on other sites

After you do your thang on the first layout tab. type copyl :)

 

(defun c:copyl (/ cnm lnum)
 (initget 7)
 (setq	cnm  ([b][color="purple"]last[/color][/b] (layoutlist))
lnum (getint "\nNumber of Layouts to Add: ")
 )
 (repeat lnum
   (command "_layout"
     "_copy"
     cnm
     (setq cnm (itoa (1+ (atoi cnm))))
   )
 )
)

 

This code assumes everything is in order. layout names are named using numerical value and only one layout tab exist.

This can be modified to your needs , like add another layout tab for existing drawings, in which case should copy the LAST layout tab to follow the last number.

 

EDIT: car to last

Link to comment
Share on other sites

WOW!!! :D:D:D

 

This is the exact lisp i need!!! thankyou Master pBe!!! im continuosly reading the lsp for beginners..i do hope to encounter the commands you masters type (ex. are the atoi, ssget, substr..) i still dont know them...basic things i now for now is the defun...but making multiple commands inside that defun is a long way to go.

 

a noob thing i can do for now is make a greeting alert after loading lsp example is (alert "Compiled for work") .. :D. then try to edit old commands renaming them with new ones. thankyou MASTER pBe!!!

Link to comment
Share on other sites

WOW!!! :D:D:D

 

This is the exact lisp i need!!! thankyou MASTER pBe!!!

 

You are welcome sephiroth11983 :) and enough of the Master salutation :lol:

I'm a noob myself when it comes to programming, i have a loooong way to go. But i'm glad i could help a fellow noob.

 

Cheers

Link to comment
Share on other sites

One of the extra things you may like to add is when creating a new layout tab you can update your title block at same time with this layout name, so the original may have been 121 now the new one will show 122. It could also renumber the max number of sheets in the title. It would be pretty easy to add to Pbe code. Post if you want this option name of your titleblock.

Link to comment
Share on other sites

Master Bigal,

 

i think i like your advice, and how can i edit alayout using alphanumeric layout names..like A101,A102.. actually the LISP that master pbe created was for numeric layout names only.

 

thank you for being a great help to us cad users...i hope i can be able to create my own LISP soon.

Link to comment
Share on other sites

One of the extra things you may like to add is when creating a new layout tab you can update your title block at same time with this layout name, .

 

Indeed a brilliant idea. but i would go with Fields on this one

 

%<\AcVar ctab>%

 

Master Bigal,

i think i like your advice, and how can i edit a layout using alphanumeric layout names..like A101,A102.. actually the LISP that pbe created was for numeric layout names only.

 

That can be easily fix sephiroth11983 :)

Link to comment
Share on other sites

Here is a start, code BY Lee-mac will pull out numbers then can change and add back to "A" etc i can be changed to get alpha alues as well the numbers 47-58 are the assci codes for 0-9

A starts at 65 a starts at 97

;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url]       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  s - String to process                                     ;;
;;------------------------------------------------------------;;
;;  Returns:  List of numerical values found in string.       ;;
;;------------------------------------------------------------;;
(defun LM:ParseNumbers ( s )
 (
   (lambda ( l )
     (read
       (strcat "("
         (vl-list->string
           (mapcar
             (function
               (lambda ( a b c )
                 (if
                   (or
                     (< 47 b 58)
                     (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                     (and (= 46 b) (< 47 a 58) (< 47 c 58))
                   )
                   b 32
                 )
               )
             )
             (cons nil l) l (append (cdr l) (list nil))
           )
         )
         ")"
       )
     )
   )
   (vl-string->list s)
 )
)

(princ (LM:parsenumbers "A102"))

Link to comment
Share on other sites

(defun _numberatend (str)
 (atoi
   (substr str
    (1+ (strlen (vl-string-right-trim "0123456789" str)))
   )
 )
)

 

(_numberatend "A102") 102

 

(defun _number+ (str n / x)
 (setq x (vl-string-right-trim "0123456789" str))
 (strcat x
  (itoa
    (+ n (atoi (substr str (1+ (strlen x)))))
  )
 )
)

 

(_Number+ "A102" 1) "A103"

Link to comment
Share on other sites

Sir SLW210,

 

sorry for the mistake, i wasnt able to read about the guidelines..il be changing it up..i just got home from work...

Link to comment
Share on other sites

To Maestro PbE and Bigal:

 

Thanks again for the additional codes..im trying to make trial and errors in making basic codes...(mostly i get the errors hahahaha)

 

but its fun making the LISP..its like taking ur imagination in cad in a whole new level (T_T why didnt i know about LISP sooner :(:cry:)

 

but i guess its still not too late..il try some new code then i hope ul still be willing to check on them soon. Take care and more power.

Link to comment
Share on other sites

Sir SLW210,

 

sorry for the mistake, i wasnt able to read about the guidelines..il be changing it up..i just got home from work...

 

No problem, just a friendly reminder.

 

Welcome to CADTutor!

Link to comment
Share on other sites

  • 9 years later...
On 10/20/2012 at 4:03 PM, pBe said:

After you do your thang on the first layout tab. type copyl :)

 

 


(defun c:copyl (/ cnm lnum)
 (initget 7)
 (setq	cnm  ([b][color="purple"]last[/color][/b] (layoutlist))
lnum (getint "\nNumber of Layouts to Add: ")
 )
 (repeat lnum
   (command "_layout"
     "_copy"
     cnm
     (setq cnm (itoa (1+ (atoi cnm))))
   )
 )
)
 

 

 

This code assumes everything is in order. layout names are named using numerical value and only one layout tab exist.

This can be modified to your needs , like add another layout tab for existing drawings, in which case should copy the LAST layout tab to follow the last number.

 

EDIT: car to last

Why is this I am getting an error message

Command: COPYL
; error: no function definition: [B][COLOR=

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