VHMN Posted June 10, 2010 Posted June 10, 2010 Hello, my name is Victor, and this is my first post here, I'm currently learning Autolisp (this site has been very useful) i'm trying to create a LISP routine that allows me to pick a block, extract it's block name, asign it to a variable, and then select all the blocks with the same name, I got it right untill the extraction of the block name, but I can't assign that name to a variable, any help would be appreciated, thanks. (DEFUN C:SBN () (SETQ BNAME(cdr (assoc 2 (entget (car (entsel))))))) (SSGET "X" BNAME)) Quote
alanjt Posted June 10, 2010 Posted June 10, 2010 try this... (sssetfirst nil (ssget "_X" (list '(0 . "INSERT") (cons 2 BNAME)))) Quote
VHMN Posted June 10, 2010 Author Posted June 10, 2010 Thanks a lot, it worked really well, I've never heard about the "sssetfirst" function, I guess it's for keeping my selection active, I'll use it for selecting objects specifying colors too. Thanks Quote
alanjt Posted June 10, 2010 Posted June 10, 2010 Food for thought... (defun c:SBN (/ ent eLst) (if (setq ent (car (entsel "\nSelect block: "))) (if (eq "INSERT" (cdr (assoc 0 (setq eLst (entget ent))))) (sssetfirst nil (ssget "_X" (list '(0 . "INSERT") (assoc 2 eLst)))) (princ "\nInvalid object.") ) ) (princ) ) Quote
VHMN Posted June 11, 2010 Author Posted June 11, 2010 Hey, thanks for that, I'll try to add that "if-then-else" routine, I mostly use Autolisp for macross to help me draw stuff, but it would be mor proffessional to have more user-friendly routines. Thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.