See the top rated post in this thread. Click here

Page 1 of 4 1234 LastLast
Results 1 to 10 of 40

Thread: excel data to draw line in autocad.

  1. #1
    Member
    Join Date
    2010-07
    Posts
    3
    Login to Give a bone
    0

    Default excel data to draw line in autocad.

    Dear all,

    This is my first post on this forum.
    I been using AutoCAD for two yrs and recently was trying to incorporate my calculation with excel to autocad.

    my question here is,
    I have a set of data in excel consists of two column, x column and y column,
    how am i going to do in order my autocad will automatic plot a graph with the x and y value of my excel data sheet.
    my idea was to create a button on my excel spreadsheet, when ever i change my parameter that affect my x and y column value, and press the button, it will link to my autocad and a graph will be plotted there.
    is this sound possible?

    I believe by using autolisp will be much more easier as it will perform the calculation and plotting of graph in autocad itself only, but the reason I create my calculation in an excel spreadsheet is because, some of the autocad users in my company are using autocad LT which not able to perform autolisp program. Therefore, I think to let them have an excel calculation for thier own parameter key in, and pass to some other colleugues who owns autocad which able to run lisp program and generate the graph for them.

    I am new to excel marco and also autolisp language, please suggest me if u have any better idea.
    Appreciate very much in advance for ur reply.

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    Quote Originally Posted by yonlih View Post
    Dear all,

    This is my first post on this forum.
    I been using AutoCAD for two yrs and recently was trying to incorporate my calculation with excel to autocad.

    my question here is,
    I have a set of data in excel consists of two column, x column and y column,
    how am i going to do in order my autocad will automatic plot a graph with the x and y value of my excel data sheet.
    my idea was to create a button on my excel spreadsheet, when ever i change my parameter that affect my x and y column value, and press the button, it will link to my autocad and a graph will be plotted there.
    is this sound possible?

    I believe by using autolisp will be much more easier as it will perform the calculation and plotting of graph in autocad itself only, but the reason I create my calculation in an excel spreadsheet is because, some of the autocad users in my company are using autocad LT which not able to perform autolisp program. Therefore, I think to let them have an excel calculation for thier own parameter key in, and pass to some other colleugues who owns autocad which able to run lisp program and generate the graph for them.

    I am new to excel marco and also autolisp language, please suggest me if u have any better idea.
    Appreciate very much in advance for ur reply.
    Try attached file
    Open Autocad drawing
    Open Excel file (AutoCAD must be opened)
    Select four columns
    Press button

    ~'J'~
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    2010-07
    Posts
    3
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    dear fixo,

    thank you so much for your file.
    I have just tried, but it return me with this error msg box when i press the button,
    please see the attached jpeg.
    i still figure it out why, not sure if it because of the autocad version.
    I'm using the autocad mechanical 2010.
    but some of my colleague are using autocad mechanical 2008 and some are LT.
    but i think LT version are not able to do the line plot. correct me if i am wrong.
    hopefully you can help to solve this. or giving some guildlines.
    Many thanks.
    Attached Images Attached Images

  4. #4
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    Quote Originally Posted by yonlih View Post
    dear fixo,

    thank you so much for your file.
    I have just tried, but it return me with this error msg box when i press the button,
    please see the attached jpeg.
    i still figure it out why, not sure if it because of the autocad version.
    I'm using the autocad mechanical 2010.
    but some of my colleague are using autocad mechanical 2008 and some are LT.
    but i think LT version are not able to do the line plot. correct me if i am wrong.
    hopefully you can help to solve this. or giving some guildlines.
    Many thanks.
    I'm working on A2009 only
    You can try open VBA editor (Alt+F11 in Excel)
    then go to Tools->References and change AutoCAD XXXX Object Library
    on your current version - it would be marked as *MISSING* in there
    Unfortunatelly I know nothing about VBA and LT release, sorry

    ~'J'~

  5. #5
    Member
    Join Date
    2011-10
    Posts
    40
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    This is what i am looking for. i picked all references related AutoCAD. i am using AUtoCAD map 2004. i faced this Error Kindly Check it. give me solution friends. Please !

    Code:
    For i = 1 To UBound(lineData, 1) ;gor Error here as "Run time Error 33, type Mismatch
    
    Dim startPt(0 To 2) As Double
    Dim endPt(0 To 2) As Double
    startPt(0) = CDbl(lineData(i, 1)): startPt(1) = CDbl(lineData(i, 2)): startPt(2) = 0#
    endPt(0) = CDbl(lineData(i, 3)): endPt(1) = CDbl(lineData(i, 4)): endPt(2) = 0#
    Set oLine = aspace.AddLine(startPt, endPt)
    Next i


    Quote Originally Posted by fixo View Post
    I'm working on A2009 only
    You can try open VBA editor (Alt+F11 in Excel)
    then go to Tools->References and change AutoCAD XXXX Object Library
    on your current version - it would be marked as *MISSING* in there
    Unfortunatelly I know nothing about VBA and LT release, sorry

    ~'J'~

  6. #6
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    AutoCad drawing must be open at the first, then,
    before of you click button, you have just select whole Excel data range,
    nothing else
    Try again

    ~'J'~

  7. #7
    Woo! Hoo! my 1st post
    Join Date
    2012-08
    Posts
    1
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    Dear Fixo,

    Thank you very much for this useful information, Based on your advise I wanna draw a spline in cad by attached excel coordinate.

    Could you please help me?

    Thanks

    Arash
    Attached Files Attached Files

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    Quote Originally Posted by arazmjo551023 View Post
    Dear Fixo,

    Thank you very much for this useful information, Based on your advise I wanna draw a spline in cad by attached excel coordinate.

    Could you please help me?

    Thanks

    Arash
    Welcome on board, Arash
    I have not worked with splines, anyway I will try to help

    Here is my attempt:

    Open Excel file, add reference to AutoCAD Type library
    then in the Sheet1 add a button, then add code for this button
    and save Excel file, better yet to save it in .XLSM format:
    Code:
    Option Explicit
    
    Private Sub CommandButton1_Click()
    
    
    Dim selRng As Range
    Set selRng = Selection
    
    Dim lineData As Variant
    lineData = selRng.Value2
    
    
    
    Dim acad As AcadApplication
    Set acad = GetObject(, "Autocad.Application")
    Dim adoc As AcadDocument
    Set adoc = acad.ActiveDocument
    Dim aspace As AcadBlock
    Dim oSpline As AcadSpline
    Set aspace = adoc.ActiveLayout.Block
    
    Dim i
    ReDim ptarr(0 To (UBound(lineData, 1) * 3) - 1) As Double
    Dim n
    For i = 1 To UBound(lineData, 1)
    ptarr(n) = CDbl(lineData(i, 1)): ptarr(n + 1) = CDbl(lineData(i, 2)): ptarr(n + 2) = 0#
    n = n + 3
    Next i
    
    Dim startPt(0 To 2) As Double
    Dim endPt(0 To 2) As Double
    startPt(0) = 0.5: startPt(1) = 0.5: startPt(2) = 0#
    endPt(0) = 0.5: endPt(1) = 0.5: endPt(2) = 0#
    
    Set oSpline = aspace.AddSpline(ptarr, startPt, endPt)
    '' if you need to draw the closed spline then add this line:
    '' oSpline.Closed=True
    ZoomAll
    
    Set aspace = Nothing
    Set adoc = Nothing
    Set acad = Nothing
    
    End Sub
    Open any drawing, the go to Excel and select diapazone of
    coordinate cells 2 columns as in your example, then press button,
    this way it working on my end A2010, MS Office 2007


    ~'J'~
    Last edited by fixo; 2012-08-13 at 08:24 AM. Reason: code added

  9. #9
    Member
    Join Date
    2012-10
    Posts
    4
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    Hi to Everyone,
    I looked through posts and i concluded that it is very useful tool in a autocad usage. I have also a question which concern a connection between Excel and AutoCAD. Is there any possibility to generate lines also with line options as thickness, colour and so on?

    Thank you in advance for reply.

  10. #10
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: excel data to draw line in autocad.

    Hi, strawmoped,
    Welcome on board!
    You have to create an Excel file with these datum row by row:
    x1, y1, z1, x2, y2, z2, Lineweight as double?, Colrindex as integer
    And also what is your Excel version? AutoCAD version?
    Let me know about then I will try to write a sample code for you.
    But easier yet to hold the data in .CSV file instead, then it would be
    retrieved from there more easily, btw
    Last edited by fixo; 2012-10-28 at 06:06 AM.

Page 1 of 4 1234 LastLast

Similar Threads

  1. use excel data to draw
    By santhoshi.civil114776650 in forum AutoCAD General
    Replies: 13
    Last Post: 2017-05-15, 02:36 AM
  2. Replies: 13
    Last Post: 2014-07-01, 02:23 PM
  3. Bring data to Excel from AutoCAD
    By cparvez in forum Dot Net API
    Replies: 1
    Last Post: 2014-05-27, 08:46 PM
  4. Replies: 4
    Last Post: 2014-01-01, 07:58 PM
  5. import text and data from excel into autocad
    By elipman in forum AutoCAD General
    Replies: 4
    Last Post: 2008-12-22, 08:04 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
  •