Need Help

Discussion in 'AutoCAD' started by WashCaps37, Nov 4, 2004.

  1. WashCaps37

    WashCaps37 Guest

    Hello Everyone,

    Jeffery P. Sanders of jefferypsanders.com was gracious to post this routine on his website for all to use The routine originally would insert circles at the coordinate locations listed in an Excel Spreadsheet. I would like to modify it to suit my needs. What I need help with is getting the routine to look at column A for the Symbol (Block) name and insert the block at the coordinates (column B and column C). Can someone please help me with this. I've started modifying the routine but can't figure out the rest.

    Thank You Very Much!!!!!


    (defun AXcelPts(a)

    ;;;--- Turn the command echo off
    (setvar "cmdecho" 0)

    ;;;--- See if the text file is available, if so, open it to read
    (if (setq fil(open (strcat a "AXCELPts.txt") "r"))
    (progn


    ;;;--- Ignore the first line by reading in the data and
    ;;; doing nothing with it. Why? The first line in a
    ;;; spreadsheet is usually a label. This is included
    ;;; in the ReadMe.txt file.


    ;;;--- Read the first blank line in the Symbol Name position(A,1)
    (setq lin(read-line fil))

    ;;;--- Read the first blank line in the x position (B,1)
    (setq lin(read-line fil))

    ;;;--- Read the first blank line in the y position (C,1)
    (setq lin(read-line fil))

    ;;;--- Set up a counter to count the points
    (setq cntr 0)


    ;;;--- Loop while there is another x coordinate
    (while(setq lin2(read-line fil))

    ;;;--- Get the y coordinate
    (setq lin3(read-line fil))

    ;;;--- Create a x,y point by converting the x and y
    ;;; coordinates from a string to a real number and
    ;;; making a list out of them.
    (setq pt(list (atof lin)(atof lin2)))

    ;;;--- Increment the counter
    (setq cntr(+ cntr 1))

    ;;;--- Insert Blocks at the x,y coordinates
    (command "-insert" A,1)
    )

    ;;;--- Close the file when you are done
    (close fil)
    )

    ;;;--- Display an error message if the file cannot be found
    (alert "Error - File not opened")
    )

    ;;;--- Let the user know the program has finished
    (alert (strcat (itoa cntr) " block insertions created by AxcelPts!"))

    ;;;--- Turn the command echo back on
    (setvar "cmdecho" 1)

    ;;;--- Suppress the last echo for a clean exit
    (princ)
    )
     
    WashCaps37, Nov 4, 2004
    #1
  2. WashCaps37

    WashCaps37 Guest

    I am a LISP newbie so If anyone out there can help me figure this out, It would be very much appreciated.

    Thanks
     
    WashCaps37, Nov 7, 2004
    #2
  3. WashCaps37

    Jeff Mishler Guest

    You can't do this using the AxcelPts program. He used a compiled VB program
    that you cannot alter to be able to include the data you want.

    However......Autodesk included in the Help documents routines & functions to
    interact with excel. There are also a number of posts on this forum that
    either explain in detail how to do this and some even give you full blown
    routines that will do almost exactly what you want. Do a search for posts by
    Marc'Antonio Alessi in April of 2003 for routines to interact with Excel.
    Once you can read the data, the rest is relatively easy. Give it a shot and
    I/we will give you a hand.

    And for the record, I was a lisp 'newbie' less than 2 years ago.....and some
    may still say that I am ;-)
     
    Jeff Mishler, Nov 7, 2004
    #3
  4. WashCaps37

    ECCAD Guest

    WashCaps..
    If you E-Mail me a sample .xls file, I'll take a peek.
    I have code that can read-in a (.csv) comma seperated value
    format. You 'saveas' in Excel, and select file of type (MS DOS csv).
    I can generate a quick little routine to read from that format.

    Bob Shaw

    (remove the nospam + ".")
     
    ECCAD, Nov 8, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.