Grrr Posted November 5, 2015 Share Posted November 5, 2015 Hello, I am trying to select a specific block and re-insert it. Kinda like copy command, but using block's base point. The problem is that I can't figure out how to get the specific block: (defun c:InsertSimilar (/ en inspt1 ) (setq en(car (entsel "\n Select a block :"))) (setq enlist(entget en)) (setq inspt1 (getpoint "\nPick Insertion point: ")) (command "_insert" en inspt1 "" "" "") (princ) ) I tried to mix it with this part of Lee mac's code: ;;---------------------------------------------;; ;; Example © Lee Mac 2011 - www.lee-mac.com ;; ;;---------------------------------------------;; (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)) acblk (vla-get-Blocks acdoc) ) (if (ssget '((0 . "INSERT"))) (progn (vlax-for block (setq acsel (vla-get-ActiveSelectionSet acdoc)) (if (not (member (setq name (vlax-get-property block (if (vlax-property-available-p block 'effectivename) 'effectivename 'name ) ) ) done ) ) Still, without any success - since I understand little about lisp, and nothing about vlisp. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 5, 2015 Share Posted November 5, 2015 Perhaps something like this? (defun c:cb ( / blk ) (if (setq blk (ssget "_+.:E:S" '((0 . "INSERT")))) (progn (setq blk (ssname blk 0)) (command "_.copy" blk "" "_non" (trans (cdr (assoc 10 (entget blk))) blk 1)) (while (= 1 (logand 1 (getvar 'cmdactive))) (command "\\")) ) ) (princ) ) [untested] Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 5, 2015 Share Posted November 5, 2015 Are you talking about dynamic block ? Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 5, 2015 Author Share Posted November 5, 2015 Lee, it works! But I've got a simple question: How I can change the insertion method (instead of manual input) I got this list of points: (foreach PT PTS ;;Loop through list of points EDIT: Tharwat, just a simple block, but I'm trying to insert it on specific locations. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 5, 2015 Share Posted November 5, 2015 Lee, it works! But I've got a simple question:How I can change the insertion method (instead of manual input) I got this list of points: (foreach PT PTS ;;Loop through list of points Assuming 'pts' is a valid point list, a very simple way would be: (defun c:cb ( / blk ins ) (if (setq blk (ssget "_+.:E:S" '((0 . "INSERT")))) (progn (setq blk (ssname blk 0) ins (trans (cdr (assoc 10 (entget blk))) blk 1) ) (foreach x pts (command "_.copy" blk "" "_non" ins "_non" x)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 5, 2015 Author Share Posted November 5, 2015 Thank you, Lee! Quote Link to comment Share on other sites More sharing options...
iconeo Posted November 5, 2015 Share Posted November 5, 2015 Check this out as well. http://www.cadtutor.net/forum/showthread.php?t=92703 Quote Link to comment Share on other sites More sharing options...
rkent Posted November 5, 2015 Share Posted November 5, 2015 Isn't ADDSELECTED a built in command now? That will work also. Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 5, 2015 Author Share Posted November 5, 2015 Thanks, iconeo - I found already what I was searching. rkent, I just wanted to see how to select a block by name and use it in lisp function - so it can be inserted later in points list. I've found a bunch of different inserting points lisps, which are placing points on selection of line's vertices, endpoints, midpoints, intersections (selection of different entities(lines/plines/xlines/circles...)) but none of them come up with inserting blocks on those reference points (which is time consuming by placing blocks manually) 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.