Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get a list (block names) from an external file

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
387 Views, 3 Replies

get a list (block names) from an external file

I'd like to get the list of blocks from a external file (either txt or xls) as apposed to here. Ideally each block name would be in its own row/line. Any example code how to best pull a list like this "x48,y48,v48,x60,y60,v60"? 

 

(setq ss (ssget "x" '((0 . "INSERT") (2 . "x48,y48,v48,x60,y60,v60"))))

 

Thanks

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: Anonymous

Something like this perhaps.

(if (setq fn (getfiled "Select a txt file" (getvar 'DWGPREFIX) "txt" 0))
  (progn
    (setq of (open fn "r"))
    (while (setq b (read-line of))
      (if (/= " " b)
	(if (not a)
	  (setq a b)
	  (setq a (strcat a "," b))
	)
      )
    )
    (close of)
    (setq ss (ssget "x" (list '(0 . "INSERT") (cons 2 a))))
  )
)

 

HTH

Henrique

EESignature

Message 3 of 4
Anonymous
in reply to: hmsilva

Yes, just like that. I like the getfiled, but changed it to findfile with a hard coded path. Performs the task just as I wanted it to. Thanks a bunch for the quick soultion! Smiley Happy

Message 4 of 4
hmsilva
in reply to: Anonymous

You're welcome, cummins600
Glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost