Jump to content

Create Folders and a Dwg Name the same as the folder from an Excel Cell Value


rcb007

Recommended Posts

I am trying to come up with a method to have a routine read an excel cell value in column A. (There might be 50+ Values in Column A). Then create a folder and a drawing with the same name within the folder.

 

I have found some ways using Excel VBA to create the folders, but not so much with lisp. 

 

Would anyone have any suggestions on how to possible get this to work or not? Thank you for your help! Hopefully I am going down the right direction on this.

Link to comment
Share on other sites

http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-68a2.htm

 

you can make directory with vl-mkdir

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-a-new-drawing-from-lisp/m-p/787043/highlight/true#M12701

 

you can make dwg file with vla-add

 

(defun c:makeempty ( / filepath filename)
  (setq filepath "c:\\test3\\")
  (setq filename "test3.dwg")
  (ex:makeempty filepath filename)
  (princ)
)

(vl-load-com)

(defun ex:makeempty ( filepath filename / doc )
  (vl-mkdir filepath)
  (setq fullpath (strcat filepath filename))
  (setq doc (vla-get-templatedwgpath (vla-get-Files (vla-get-preferences (vlax-get-acad-object)))))
  (setq doc (findfile (strcat doc "\\acad.dwt")))
  (setq doc (vla-add (vla-get-documents (vlax-get-acad-object)) doc))
  (vla-saveAs doc fullpath)
  (vla-activate (vla-item (vla-get-documents (vlax-get-acad-object)) filename))
)

 

 

https://www.cadtutor.net/forum/topic/74681-cad-output-excel-specified-page/?do=findComment&comment=591539

and you can get excel cell value (current activated cell) and can move it.

 

Edited by exceed
  • Like 1
Link to comment
Share on other sites

I don't do Excel to AutoCAD really but recently it has caused a lot of questions - my answer is based on an apparent difficulty reading and writing to a spreadsheet via a LISP..

 

So if you can make a folder with Excel easily... why not do that then? In my way of working I would have a look through the spreadsheet first just to check that it looks OK, simple thing then to run a small macro while you are there.

 

Getting a list of data from a spreadsheet column is easier and if you can do that to get a list of new folders, you can make a couple of simple changes to Exceeds example code above to add an empty dwg to each of the folders in a location.

Link to comment
Share on other sites

Did you google use excel to open a new Autocad dwg should be a VBA example out there. 

 

You can open a new excel work book from Acad lisp so opposite must exist.

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