Jump to content

insert similar


Grrr

Recommended Posts

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.

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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) :)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...