Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel to draw in AutoCAD 1

Status
Not open for further replies.

malakin

Civil/Environmental
May 22, 2001
33
I am looking to produce profiles, cross sections etc in AutoCAD by inserting a line of commands from an excel spreadsheet. How exactly is it done?
 
Replies continue below

Recommended for you

Are you trying to enter AutoCAD commands one by one (like a script) or trying to get the parameters for creating these objects?
 
Years ago, I was able to link Autocad and Excel so for instance, the flange length, web height and both thicknesses were in Excel cells as values, like 4.5 and 0.25 and the Autocad drawing would change if the Excel cell values changed. It was a two-way link so if I stretched the I-beam flange, the cells in Excel would change. I used it to calculate beam properties and strengths in Excel for various sections in Autocad.

Is this similar to what you are trying to do?
 
I have not used it in the two way manner described for the flange. This sounds a little more complex than what I have done. I would be very interested to know how you did this. What I have done is to copy a column (highlight total column) of command figures produced in excel and paste into AutoCAD command line to produce a grahical representation of elevations (a cross section or profile) with grid etc. Hope we can figure this out as it is very useful.
 
Piece of cake with and Excel Macro. Here is how you can use a button to process each command in the column.

From your Excel WB:
1: View > Toolbars > Control Toolbox
2: Select the Command Button from the toolbar and
draw one on the worksheet
3: Double-Click the button (fires up VB Editor)
4: Add this code
Code:
Sub RunAutoCADCommands()
    Dim iRow As Long
    Dim sCmd As String
    'Connect to AutoCAD
    Dim cadApp As Object
    Dim cadDoc As Object
    Set cadApp = GetObject(, "AutoCAD.Application")
    Set cadDoc = cadApp.ActiveDocument
    'Issue Commands
    iRow = 1
    Do While Range(&quot;A&quot; & iRow) <> &quot;&quot;
        cadDoc.SendCommand (Range(&quot;A&quot; & iRow))
        iRow = iRow + 1
    Loop
    'Done
    MsgBox &quot;Done Processing Commands&quot;
    Set cadDoc = Nothing
    Set cadApp = Nothing
End Sub
NOTE: This processes all commands in column A, starting with row 1. Modify as needed.
5: Switch back to the worksheet. You can highlight the button, select Properties from the toolbar to change the name displayed.
6: Exit Design Mode (a button on the toolbar)
7: With a drawing open in AutoCAD, hit the button.

Hope that helps... DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Oops! The Sub name should not be added. The sub will automatically come up with something like this:
Code:
Private Sub CommandButton1_Click()

End Sub
Just put the code in this sub, rather than RunAutoCADCommands(). DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Malakin,
If I understand you correctly, you have columns for an X & Y coordinate points. There is a simple way to paste these into Acad to create a pline to draw a cross-section or profile that doesn't involve lisp routines.
1) using concatenate or & in excel create a column with &quot;x,y&quot; in a text format. (eg. =A1&&quot;,&quot;&B1)
2) copy the entire column for the profile or cross-section
3) start a pline command in Acad
4) go to the text window (F2), under EDIT hit PASTE.
cross-section drawn.
 
Is there a way to use this same methodology to Autocad blocks through excel.
For example:

Using Excel as a database which can update drawings that have the associated links through the blocks.

Idea is that what you update in excel, it will update all the other drawings where blocks are linked to the excel. Similiar to the Xref.

another example

-Excel Data Sheet
|
- Drawing 1 _ Plan Drawing
|
- Text linked in a block attribute to Excel Sheet
- Drawing 2 _ Profile Drawing
|
- Text linked in a block attribute to Excel Sheet
- Drawing 3 _ Details
|
- Text linked in a block attribute to Excel Sheet
- Drawing 4 _ Tables
|
- Text linked in a block attribute to Excel Sheet

All Driven by Excel and Attribute Blocks.

Maybe the block setup could be a genearic type block. All we need to put in the attribute area is the approperate Excel Cell (A11) and that value will show up in the autocad block attribute drawing.
 
You would probably have to write a program to create the dynamic link. I do not think that they can be linked without customization.

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
How hard would it be to write this program. Do you think this is a easy program? Do you think there are already programs out there that can do this? so using vlisp and macros... not possible?

thanks...
 
It is not extremely complicated, but it's not an simple task either. It would take some time to configure and write. I am not sure if anything like this already exists, but it is possible with VBA.

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
You can use this as an example: (Replace the word &quot;dot&quot;, used twice, with an actual &quot;.&quot;)
Start a new drawing, then copy what is in the red box only and paste it at the command line. By seeing how this is done, you can get an idea of how to draw other things from Excel.

Flores
 
I do like how everything is automated with the excel... Even survyors could use this... does this method work with connecting lines?

but

can autocad attributes be linked to a ACCESS database or excell...

I know if you paste the excel cell into autocad and you go to plot... looks pretty crappy... but if its in a block its clean..

any ideas?
 
lol i can not get the link from there site to download the LISP... but yes it does sound like something that will work!
 
will give it a try... lol

Link is not working again...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor