See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Excel file with drawing locations and Open up those drawings

  1. #1
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Excel file with drawing locations and Open up those drawings

    I was just wondering if there was a way to get autocad to take an excel file with drawing locations and open up these drawings, run specified lisp programs, then save and close these files as dxf's to the correct directory. If anyone can help I would appreciate it. There is no code because i have no idea where to start.

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,788
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    That shouldn't be too difficult, however is it necessary to store this information in Excel format? If it's just a list of drawings, reading from a .TXT file would be easier.

    You could also create a script file to make the edits you want, then use ScriptPro from Autodesk to run this script on multiple drawings.
    R.K. McSwain | CAD Panacea |

  3. #3
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    No it is not necessary to use an excel file it was basically just an example of a format. A .txt file would be sufficient. I am just trying to save time because i have 2000 drawings i need to open and convert with certain lisp commands and thought maybe i could do a type of batch run. I am not familiar with script files of ScriptPro.

  4. #4
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    927
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    You can get into Excel data more easily with VBA, but if you want to use Lisp, you could try using a .csv file, that can be read line by line by AutoCad and is readable to Excel, I use this quite alot.

    I wrote a program a little while back to place colour coded luminance values at specified locations across a site, I have attached it here with a little "how-to" and some sample data all wrapped up in a zip file, feel free to plagiarise it all you want (a credit would be nice though). Hope it helps you get started.
    Attached Files Attached Files
    ^^ Ceci n'est pas une post ^^

  5. #5
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    I'm sorry that is a bunch of foreign language to me I am fairly new at being introduced to Lisp and can do some basic routines, but nothing of this stature. Thanks for your help if I knew what i was doing it would probably help a whole lot more. The thing is that i can see in my head what i want it to do but can't put it down.

    The program just needs to open up drawings from any sort of text file, run certain lisp commands and save as .dxf and close. Also this has to be done over 2,000 files.

    Again thanks for all the help.

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,517
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    Quote Originally Posted by Lions60
    I'm sorry that is a bunch of foreign language to me I am fairly new at being introduced to Lisp and can do some basic routines, but nothing of this stature. Thanks for your help if I knew what i was doing it would probably help a whole lot more. The thing is that i can see in my head what i want it to do but can't put it down.

    The program just needs to open up drawings from any sort of text file, run certain lisp commands and save as .dxf and close. Also this has to be done over 2,000 files.

    Again thanks for all the help.
    Don't worry about the 2000 files for the moment. Write down in plain english what you want to accomplish. Those steps can then be broken down into smaller steps. These smaller steps are the basis of your program. The syntax isn't that difficult.

    Here are some similar threads that may help.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    Ok i have ScriptPro on my computer now i need to know what is included in a script and how to write one. Is it the same as an autolisp routineand if so can i jsut paste the routine in.

  8. #8
    I could stop if I wanted to
    Join Date
    2015-08
    Posts
    263
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    Hi,

    You can try the following code. I have tried to explain it in detail.

    Code:
     
    (defun c:GenScr (/ dwgPath dwgList dwgName numDwgs count scrFile)
    ;;; Path should be like "c:\\projects\plots\\" or "c:/projects/plots/"
    ;;; Substitute your path here.
    (setq dwgPath "C:\\projects\\plot\\"	; sets the path
    		dwgList (vl-directory-files dwgPath "*.dwg") ; get the list of all the drawings
    )
    	 (if dwgList	 ; if dwg files exists there
    (progn
    (setq numDwgs (length dwgList) ; number of drawings
    		 count 0	 ; initiate counter
    scrFile (open (strcat dwgPath "Runme.scr") "w") ; open a script file in the same folder
    )
    (repeat numDwgs	 ; for all the drawings
    (setq dwgName (strcat dwgpath (nth count dwgList))) 
    (write-line ".Open" scrFile)	; write to script file
    (write-line dwgName scrFile)
     
    ;;;If you need to load a lisp routine in each dwg
    (write-line "(load \"MyLispFile.Lsp\")" scrFile) ; load any required lisp routine
    ;;;
    ;;; Enter your commands here.
    (write-line "MyCommand" scrFile)
    ;;;
    ;;; Preset the dxf file format before you proceed.
    ;;; May require minor modification depending on you
    ;;; AutoCAD version Notice the two spaces after dxfout
    ;;; in the following line acts like <enter>.This will 
    ;;; accept the default file name and default format
    (write-line ".Dxfout " scrFile)
    ;;; Better to save the drawing for uninterrupted scripting
    (write-line ".Qsave" scrFile)
    (setq count (1+ count))	; next dwg
    )
    (close scrFile)	 ; close when done
    ;;; Make sure that the current dwg won't prompt for
    ;;; save changes!
    (command ".script" (strcat dwgpath "Runme.scr"))	 ; run the script
    )	 ; progn
    	 )		; if
    	 (princ)
    )		; defun
    Hope this will serve your purpose.

    Regards,
    Abdul Huck
    Last edited by abdulhuck; 2006-07-26 at 07:46 AM.

  9. #9
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    927
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    Nice little piece of coding, Abdul. Note that what Abdul has written is a Lisp routine and not a script, so you will have to APPLOAD it and run it, rather than SCRIPT and run.

    I think I can infer from the ealier posts that there is a large number of drawings to be processed here, are they all in one directory? Abdul's program seems to work on this basis (correct me if I am wrong, please Abdul), are your drawings all in one place, or do you have the text file that lists out all their locations? It would not be too difficult to read the text file line by line and work in multiple folders.
    ^^ Ceci n'est pas une post ^^

  10. #10
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: Excel file with drawing locations and Open up those drawings

    Currently I have all of the drawings in one directory for the ease of me finding which ones i need to change. I do understand that Abdul's code is a lisp routine but in it he keeps calling out a script file. Is this something already in ACad or is this where i would list a script file if one was written. I do thank you for the code it gives me some insight on what's going on. The part that say "enter my commands here" what commands do i enter because the lisp routines should be taking care of everything i need done in the drawing. Or is this where i could load multiple lisp routines.
    Last edited by Lions60; 2006-07-26 at 11:46 AM.

Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 2012-08-08, 05:50 PM
  2. Replies: 3
    Last Post: 2012-06-17, 09:42 PM
  3. Excel - Cannot Open A Pasted Excel File
    By omorah in forum AutoCAD General
    Replies: 2
    Last Post: 2008-08-08, 06:50 PM
  4. Excel Formula to open drawing layout tab
    By wpeacock in forum AutoCAD General
    Replies: 3
    Last Post: 2008-07-23, 05:29 PM
  5. get already open excel file
    By jcoon in forum VBA/COM Interop
    Replies: 2
    Last Post: 2004-08-22, 04:20 PM

Posting Permissions

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