Jump to content
Guptil

Creating dwg files (dwg. format) using Excel sheet.

Recommended Posts

Guptil

I have a Excel sheet showing around 500 drawings numbers and i would like to create just dwg files with the same drawings numbers as shown in excel. any help in this regards will be highly appropriated.

Share this post


Link to post
Share on other sites
maratovich

Attach an example dwg file

Share this post


Link to post
Share on other sites
BIGAL

Like maratovich lots of missing answers here.

 

Do you just want to create blank dwgs with a new name ?

 

Do they need to have something drawn inside each one ?

 

Do they ned a title block created with dwg name ?

 

500 blank dwgs can be done outside autocad by copying a predefined dwg using a batch file. Take advantage of excel to create.

Share this post


Link to post
Share on other sites
SunnyTurtle

I would use a batch file like the one below

setLocal EnableDelayedExpansion
SET count=
for /f "tokens=* delims= " %%x in (c:\Temp\filelist.csv) do (
REM ["-----template file to be copyed-----"]["-----location of new files-----\%%x"]
cOPY "[color="red"]Template File[/color]"  "[color="red"]New file location[/color]\%%x" /y
)
endlocal

The filelist.csv would have to be in the following format.

drawing 1.dwg
drawing 2.dwg
drawing 3.dwg
drawing 4.dwg
drawing 5.dwg

Edited by SunnyTurtle
  • Thanks 1

Share this post


Link to post
Share on other sites
Guptil
Like maratovich lots of missing answers here.

 

Do you just want to create blank dwgs with a new name ?

 

Do they need to have something drawn inside each one ?

 

Do they ned a title block created with dwg name ?

 

500 blank dwgs can be done outside autocad by copying a predefined dwg using a batch file. Take advantage of excel to create.

 

Just Empty drawings with a name as shown in excel sheet.

Share this post


Link to post
Share on other sites
Guptil
I would use a batch file like the one below

setLocal EnableDelayedExpansion
SET count=
for /f "tokens=* delims= " %%x in (c:\Temp\filelist.csv) do (
REM ["-----template file to be copyed-----"]["-----location of new files-----\%%x"]
cOPY "[color="red"]Template File[/color]"  "[color="red"]New file location[/color]\%%x" /y
)
endlocal

The filelist.csv would have to be in the following format.

drawing 1.dwg
drawing 2.dwg
drawing 3.dwg
drawing 4.dwg
drawing 5.dwg

 

 

 

Where is thumbs up button..:D:thumbsup: :thumbsup:

 

Thanks allot. It works like a champ.

Share this post


Link to post
Share on other sites
SunnyTurtle
Where is thumbs up button..:D:thumbsup: :thumbsup:

 

Thanks allot. It works like a champ.

 

Glad to help :D

Share this post


Link to post
Share on other sites
Mushtaq86

Hi All,

Hope I am not too late here.

I am at rookie level at VBA in excel and totally new to VBA in CAD.

I am also have the same requirement as that of Mr. Guptil.

Till yesterday I was looking for a VBA code in excel.

Can anyone guide me through this.

 

Thanks in advance.

Share this post


Link to post
Share on other sites
maratovich

I am at rookie level at VBA in excel and totally new to VBA in CAD.

You need to study the connection from Excel to AutoCAD.

If there is no time - you can use it.

CF.png

CopyFile.zip

  • Thanks 1

Share this post


Link to post
Share on other sites
BIGAL

Nice maratovich

 

simple excel copy the E column to notepad save as a batch file .BAT and use CMD from windows all done.

Screen Shot 08-08-18 at 02.18 PM.jpg

Share this post


Link to post
Share on other sites
Mushtaq86

Dear Maratovich,

 

Thanks for the attachment. It is helpful to some extent.

Share this post


Link to post
Share on other sites
Mushtaq86

@ maratovich... thanks for the response and attachment.

 

@Bigal: thanks for the "batch" file process explanation.

Both options are helpful to an extent.

 

Anyways, i will keep on exploring other options and post here when find any suitable.

 

Cheers !!!!

Share this post


Link to post
Share on other sites
Mushtaq86

Dear Bigal,

Thanks for the explanation of batch process. Though renaming isn't accepting "spaces", it is also helpful to some extent.

Thanks again.

Share this post


Link to post
Share on other sites
hanhphuc
Posted (edited)

Here's another method creating multiple new drawing by LISP 


(defun c:newdwg (/ dwg dwgname str l i ls ok fold fn)
  ;hanhphuc 
  (if (not *start-End*)
    (setq *start-End* "1-10")
    )
   
  
  (if (and (setq dwgname "Drawing " ; <-- default output prefix 
		 dwg (getenv "lasttemplate"))
	   (setq str (getstring (strcat "\nEnter start-end number [" *start-End* "] : ")))
	   (setq *start-End*
		  (cond	((and (/= *start-End* "") (= str "")) *start-End*)
			((wcmatch str "#*-*#") str)
			(t "1-10")
			)
		 )
	   (setq l (read (strcat "(" (vl-string-translate "-" " " (read *start-End*)) ")")))
	   (setq i    (1- (car (vl-sort l '<)))
		 fold (acet-ui-pickdir)
		 )
	   )
    (progn
      (repeat (1+ (abs (apply '- l)))
      (setq ok (vl-file-copy dwg (setq fn (strcat fold "\\" dwgname (itoa (setq i (1+ i))) ".dwg"))))
      (if (not ok)
	(setq ls (cons fn ls))
	)
      )
      (princ (strcat "\nTotal "(itoa (- (apply 'max l)(length ls))) " new drawings created."))
    )
    (princ "\nInvalid file name or folder")
    )
  (if ls
    (progn (princ (strcat "\n" (itoa (length ls)) " duplicate files : "))
	   (foreach x (reverse ls) (terpri) (princ x))
	   )
    )
  (princ)
  )

In order to minimize user input,  get rid of 'getstring' for output drawing prefix 

also use minus sign '-'  as delimiter upon prompt for input. 

 

Command: NEWDWG

Enter start-end number [1-10] : 1-10
Total 7 new drawings created.

3 duplicate files :
C:\Users\hp\Desktop\CAD\Drawing 1.dwg
C:\Users\hp\Desktop\CAD\Drawing 2.dwg
C:\Users\hp\Desktop\CAD\Drawing 3.dwg

 

Edited by hanhphuc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×