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

Need a Lisp to create layouts in multiple drawings

9 REPLIES 9
Reply
Message 1 of 10
kylei7449
3201 Views, 9 Replies

Need a Lisp to create layouts in multiple drawings

http://forums.autodesk.com/t5/AutoCAD-2010-2011-2012-DWG/LISP-to-create-layouts-using-csv-file/m-p/4...

 

Moved post:

 

I have a csv file that has the drawing names and their layout names listed in columns A and B. Before I begin a project, I have to create the Sheet List (in Excel) and the csv file. The csv file is needed because I have a lisp routine that reads the csv and updates all my Title Block attributes in all my drawings. (VERY sweet program)  What I'm wanting to do, is create new layouts (using my dwt) based on the information in the csv file. So, when I start a new project all I need to do is create the base drawing files first. Then, in my csv file I've got those drawing names listed in Column A and their corresponding sheet titles (Layout names) in Column B. I run the lisp and it reads the csv and creates layouts in all those base drawings and naming the layouts with the sheet titles from column B.

Column A                                                      Column B

DRAWINGS                                                 SHEET TITLES

drawing1.dwg                                               A100

drawing1.dwg                                               A101

drawing"n".dwg                                            "n"500

Etc, etc.

I'm needig a way to automate creating hundreds of layouts at once. (very time consuming).So the lisp has to be able to read a csv (or Excel--doesn't really matter) and create new layouts (using my dwt) in as many drawing files represented in column A. [and filtered so it doesn't create dupilicates so I can run the routine at a later date when new sheets are added to the drawings] Capiche?

 

Anybody already have something like this they'd be willing to share? Thanks.

9 REPLIES 9
Message 2 of 10
hmsilva
in reply to: kylei7449

A quick one

 

(defun c:test ( / FILE FNAME LYTLST LYTNAME POS STR)
  (if (and (setq fname (getfiled "" "" "csv" 8))
	   (setq file (open fname "r"))
      );; and
    (progn
      (setq LytLst (layoutlist))
      (read-line file);; header
      (while (setq str (read-line file))
	(setq pos     (vl-string-position 9 str)
	      LytName (substr str (+ (vl-string-position 9 str) 2))
	);; setq
	(if (not (member LytName LytLst))
	  (command "_.layout" "N" LytName)
	);; if
      );; while
      (close file)
    );; progn
  );; if
  (princ)
);; test

hope that helps
Henrique

EESignature

Message 3 of 10
kylei7449
in reply to: hmsilva

It's been awhile and just now revisiting this issue::

Can't get this to run; anybody see the reason why??? (it will load and "run" but produces nothing/just ends quietly)

Again to state the objective: I need a lisp that will create layouts (from a template file), naming the new layouts reading from a list in the csv. So if there are 100 names in the csv, it will create 100 named layouts. Thx

Message 4 of 10
hmsilva
in reply to: kylei7449

Please disregard my previous post, I misunderstood your request.

Henrique

EESignature

Message 5 of 10
Kirk.Gustafson
in reply to: kylei7449

Dragging up an old post...  just so I understand, Column A is drawing names, which may have duplicates, and Column B - Sheet titles are actually the names of the layouts you want created, but only if they don't already exist?

 

Does your dwt have a layout that you want copied to create the new layouts, or do you want the layout created from scratch??

Message 6 of 10
kylei7449
in reply to: Kirk.Gustafson

Hi,

 

Let me refresh my brain on this issue...yes, I think you've got the gist of it. In a csv file (which is used to manage the attribs in my titleblocks) there are two columns that need to be used for this lisp's purpose. Column A lists the drawing file names (dwgs) and Column B lists the layout or sheet titles for those drawings. (it's a sheet set list basically) The titleblock/layout is in a drawing file (dwg) and that would be used to import the new layouts from.

 

The goal is to create a lisp that can be used at project's start so once I've created the csv (the sheet set list), all I'd  need do is run the lisp to automatically create the necessary layouts in however many drawings the project covers. Being able to read from the csv is the key. Thanks if you've got an idea on this.

Message 7 of 10
Kirk.Gustafson
in reply to: kylei7449

Ok, sounds interesting.  I've been creating a routine to import a polygon shape file, build a list of the polygons, and then create a layout for each polygon, clipped to the boundary of the polygon...

 

Can you explain what you meant in your sample data what you meant by drawing"n".dwg, "n"500?

 

Are you just suggesting that it needs to loop until finished?

Message 8 of 10
kylei7449
in reply to: Kirk.Gustafson

The "n" number of drawings and "n" number of layouts simply represent the cell data in the csv. Column A's cell data contains the drawing name(s) and Column B's cell data will have the corresponding layout names for each of those drawings. Thus, by reading the csv the lisp will create the layouts in each of the corresponding drawings. Since a project can have over 250 sheets being able to create layouts based off a csv would be a very valuable time saver.

Message 9 of 10
kylei7449
in reply to: kylei7449

No looping. Lisp terminates at the end of file.
Message 10 of 10
Anonymous
in reply to: kylei7449

(defun c:laytest ( / file fname lytlst lytname posinit posend aux str sep)
  (if (and (setq fname (getfiled "" "" "csv" 8))
	   (setq file (open fname "r"))
      )
      (progn
	(setq lytlst (layoutlist))
	(setq sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) (",")))
	(read-line file)
	(while (setq str (read-line file))
	  (setq posinit (vl-string-search sep str 0)
		aux (substr str (+ posinit 2))
		posend (vl-string-search sep aux 0)
		lytname (substr str (+ posinit 2) posend)
	  )
	  (if (not (member lytname lytlst))
	    (command "_.layout" "N" lytname)
	  )
	)
	(close file)
      )
    )
  (princ)
)
Tags (2)

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

Post to forums  

Autodesk Design & Make Report

”Boost