Results 1 to 3 of 3

Thread: Lost

  1. #1
    Member
    Join Date
    2007-02
    Posts
    6
    Login to Give a bone
    0

    Default Lost

    I have a spreadsheet listing XY coordinates for multiples of the same object, and would like a block with attributes to be inserted using the spreadsheets XY coordinates. I have no clue how to automate this, is it possible? Is this question in the right place? What is the best way to learn this?

  2. #2
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Lost

    Yes it can be done. I think I saw no too long ago.
    http://forums.augi.com/search.php

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Lost

    Firstly, save the spreadsheet to CSV. Then find a routine to read csv into a LISP list. Then step through the list inserting the block at the points defined.

    Your CSV file would look something like this:
    Code:
    456.65,234.56
    234.56,1221.45
    56.45,234.50
    Your lisp function to place the blocks. I've included a quick port from CSV to LISP, this may not work in all instances.
    Code:
    (defun CSVtoLST (fn / file lst lst1 str n)
      (setq file (open fn "r") lst nil);Open the file and start empty list
      (while (setq str (read-line file)) ;Read the next line in the file
        (setq lst1 (read (strcat "(" (vl-string-subst " " "," str) ")")));Convert string to real list
        ;;Check if only 2 items in list, then change to dotted pair
        (if (= 2 (length lst1))
          (setq lst1 (read (strcat "(" (vl-string-subst " . " "," str) ")")));Convert string to real list
        )
        ;; Add line as item of list
        (setq lst (cons lst1 lst))
      )
      (close file)
      lst
    )
    
    ;; Command function to insert blocks according to csv values
    (defun c:InsBlkXY (/ fn xylst blkname n)
      (setq blkname "BLK1") ;Change this to the block you wish to insert
      (if (setq fn (getfiled "Select CSV" "" "csv" (+ 4 8)))
        (progn
          (setq xylst (CSVtoLST fn))
          (setq n 0)
          (while (< n (length xylst))
        (command "-insert" blkname (nth n xylst) "" "" "")
        (setq n (1+ n))
          )
        )
        (princ "Canceled by user")
      )
      (princ)
    )
    Save this to a LSP file, load into AutoCAD using Tools --> Application Load. Then run by typing InsBlkXY at the command prompt.

Similar Threads

  1. lost my add-ons
    By rsloyer in forum Revit Architecture - General
    Replies: 0
    Last Post: 2010-11-29, 06:15 PM
  2. I'm Lost
    By Brian.164262 in forum AutoLISP
    Replies: 2
    Last Post: 2010-05-05, 09:02 PM
  3. getting lost
    By rjjlee in forum Revit - Gallery
    Replies: 2
    Last Post: 2004-11-22, 04:25 AM

Posting Permissions

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