G.Aquarius Posted March 19 Share Posted March 19 (edited) Hello, New to LISP here. I was writing a program and I need it to: (1) identify old title blocks by name -> (2) Gather some attribute data and temporarily store it -> (3) purge the drawing -> (4) paste in new blocks -> (5) populate new title block attributes. got steps 2, 3, and 5 all good. For step 1, I'm using entsel to ask the user to select the block, but I need to make sure they select the correct one. I can use the name of the block as a check because it's unique. Can someone help me with the code for this? (setq obj1 (car (entsel "\nSelect the title block:"))) -> this is what I use to ask the user to select the block and then use obj1 to get attributes. Thanks. Edited March 19 by G.Aquarius Quote Link to comment Share on other sites More sharing options...
mhupp Posted March 19 Share Posted March 19 just use ssget if your looking for a unique named block. then their isn't a need for the user to select anything. (setq ss (ssget "_X" '((0 . "INSERT") (2 . "block name") (410 . "Model")))) I would also pull the base point of said block to help with step 4. 2 Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 19 Share Posted March 19 5 hours ago, mhupp said: just use ssget if your looking for a unique named block. then their isn't a need for the user to select anything. (setq ss (ssget "_X" '((0 . "INSERT") (2 . "block name") (410 . "Model")))) I would also pull the base point of said block to help with step 4. You've been on your holidays too long....add this so that the the OP can keep using entitiy from a selection set: (setq obj (ssname ss 0)), and modifying the cons 410 to a variable (to be set earlier in the LISP) MyLayout - assuming the OP is working in paperspace for a title block, rather than modelspace0? Though if they are in that screen as they run this can use ctab. Assuming only 1 occurrence of the title block you might not need the cons 410 part. (setq obj (ssname (ssget "_X" (list (0 . "INSERT") (2 . "block name") (cons 410 MyLayout) ))) 0 )) For obvious reasons (it is a Sunday here), this is untested - might be typing errors 2 Quote Link to comment Share on other sites More sharing options...
G.Aquarius Posted March 19 Author Share Posted March 19 Thank You @Steven P and @mhupp here's the code that works (made some changes, syntax errors really nothing major) (setq obj (ssname (ssget "_X" (list '(0 . "INSERT") '(2 . "MARS_Petcare_US Title Block") )) 0) ) Works great!! 2 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 19 Share Posted March 19 If you do want current layout only add. (cons 410 (getvar 'ctab)) 1 Quote Link to comment Share on other sites More sharing options...
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.