Insert blocks from a txt file lisp PROBLEM

Discussion in 'AutoCAD' started by gardensouras, Dec 9, 2004.

  1. gardensouras

    gardensouras Guest

    Hi if anyone could help I would appreciate it.
    I work in a Staduim that has a lot of touring rock shows. When we get
    their lighting rig info we have to check wether it will pull the roof
    down or not. Lighting pionts for shows are supplied as list of x y
    coords, names and weights. I have wriiten a LISP routine to insert
    atrributed blocks from the list on a .txt file. The txt file is list is
    formated:

    L1 1800 -22.5 41
    L2 1800 -8.5 41
    L6 700 0 21

    I use this routine to insert the blocks (I wrote it myself and am no
    expert)but it sometimes has some random results and I cant figure out
    why. The routine works but some of the pionts xy insert coordinates are
    wrong. Please look at it and help. Also feel free to use it if you
    like, remember to take all spaces out of the txt file before you go
    though and it is slightly faulty.

    (defun inpt ()
    (command "insert" "Point" ptt "" "" "" ptname ptw )
    );I think this bit is a bit dodgy again no expert

    (Defun C:IMPRT4 (/ nme txt dt ptt ptname ptw)
    (setq nme (getstring "\nName of text file to import: "))
    (setq nme (strcat "T://1.Rod Laver Arena//Data//" nme ".txt"))
    (setq txt (open nme "r"))
    (setq dt (read-line txt))
    (split_tab_delimited_str dt); this function splits the tab delimited
    string into a list of strings post me if you want it

    (setq ptname (car dt))
    (setq ptw (cadr dt)
    );setq as long as the weight is in kg otherwise I do like below to
    convert it

    (setq ptt
    (list
    (cvunit (distof (nth 2 dt) 2) "feet" "Millimeters")
    (cvunit (distof (nth 3 dt) 2) "feet" "Millimeters")
    ); list converts xy coordinates from decimal feet to mm
    ); setq

    (inpt)

    (while (/= dt nil)
    (setq dt (read-line txt)) (split_tab_delimited_str dt)

    (setq ptname (car dt))

    (setq ptw (cadr dt)
    );setq

    (setq ptt
    (list
    (cvunit (distof (nth 2 dt) 2) "feet" "Millimeters")
    (cvunit (distof (nth 3 dt) 2) "feet" "Millimeters")
    ); list
    ); setq

    (inpt)

    ); close while

    (close txt)
    (command "redraw")

    ); Inserts pionts from text file


    Thanks
    Justin
     
    gardensouras, Dec 9, 2004
    #1
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.