Results 1 to 5 of 5

Thread: LISP to extract single Excel cell and plug into SETQ variable

  1. #1
    Member
    Join Date
    2014-11
    Posts
    2
    Login to Give a bone
    0

    Default LISP to extract single Excel cell and plug into SETQ variable

    Hey everyone,

    I've been working on this thing for months, searching forums and trying to put together code. So far, failing miserably.

    I'm trying to extract real numbers from particular cells in a simple .xls spreadsheet (or could be .csv if need be). The idea is that I could retrieve numbers from my spreadsheet of specs and plug them straight into a SETQ variable.

    All my tries so far end up in error messages or in the SETQ trying to spit out every single number on the sheet.

    So is this possible? Or is LISP the wrong tool to be using for this? I can post the code that I have if it would be helpful...but maybe I'm thinking of it all wrong.

  2. #2
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    917
    Login to Give a bone
    0

    Default Re: LISP to extract single Excel cell and plug into SETQ variable

    Hi and welcome to AUGI,

    I think you did not clarify the problem well when you said that you could have retrieved the numbers and assigned them to a variable and on the other hand you said or mentioned that you ended up with an error message .

    So can you be more specific and straight to the point or even by posting an example ?

    Tharwat.

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

    Default Re: LISP to extract single Excel cell and plug into SETQ variable

    Like Tharwat you have not really said how your doing it, in simple terms you read a colxrowy value from excel C5R3. Search for GETEXCEL.lsp it has examples of how to go both ways to or from Autocad. Read csv is a different method all together.

  4. #4
    Member
    Join Date
    2014-11
    Posts
    2
    Login to Give a bone
    0

    Default Re: LISP to extract single Excel cell and plug into SETQ variable

    Thanks for the advice. I've tried the getexcel.lsp thing before, but this time had more success. Thanks for the suggestion (and thank you, Terry Miller for the code). So I've gotten where I want to go sort of.

    Now I have a 2nd part to my original question. What I really want to accomplish when this is all said and done is to insert a dynamic block and have the values pulled by getexcel from my .xls plugged into my dynamic block. My hope is to have
    A. A tool palette button or ribbon insert the dynamic block
    B. Change the "half-width" (the width x .5)
    C. Change the "depth"
    D. Exit the command

    I've added Lee Mac's "SETDYNPROPVALUE" (thanks, Lee Mac) to my code to accomplish this. It gets me further down the road, but not to my destination.

    So right now the attached code:

    #1: Works (as in, it doesn't break)
    #2: Will change the dynamic block around with number from my excel
    #3: *But* it prompts me twice (w/ "Select dynamic block: ") and I end up picking the same block twice, once for the half-width, then once for the depth.

    I'd love for this to just be a lisp that, when ran/loaded, inserted the block with the values plugged in. All my attempts to strip it down and simplify it have failed me (i.e. using entlast and similar stuff). I have attached--along with the code--a sample .xls and a sample dynamic block. (of course the path to the .xls will have to be changed in the above code to get this to work)

    I hope one of you can help me trim the fat on this thing. Thanks in advance.
    Attached Files Attached Files

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

    Default Re: LISP to extract single Excel cell and plug into SETQ variable

    Many years go Autocad supplied a sample drawing called Shaft it had a corresponding excel you just change the excel value and the dwg changed automatically. Will see if I can find. Code was included.

Similar Threads

  1. Using SETQ to assign a block to a variable
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 8
    Last Post: 2014-02-11, 04:44 PM
  2. error: bad variable name in SETQ?
    By stusic in forum AutoLISP
    Replies: 6
    Last Post: 2013-05-21, 05:46 PM
  3. COND Statement to Setq Variable
    By stusic in forum AutoLISP
    Replies: 9
    Last Post: 2012-04-05, 08:47 PM
  4. Create lisp to extract data from excel file
    By Lions60 in forum AutoLISP
    Replies: 7
    Last Post: 2008-01-30, 04:32 AM
  5. setq Selection Set to a variable
    By gisdude in forum AutoLISP
    Replies: 2
    Last Post: 2006-05-30, 03:05 PM

Tags for this Thread

Posting Permissions

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