Jump to content

Recommended Posts

Posted

I have been working with dynamic blocks for a year now. I am new to LISP programming. I found this code from vbcad from tek-tips and i seem to recognize a few things from my experience working in MATLAB.

 

Since ACAD 2010 is still missing support

 

This routine is supposed to replace dynamic blocks with another block. The user select the block, and the predefined replacement block is inserted into it's place.

 

However, when I use the routine and select a block, it will not allow me to select blocks, either regular or dynamic returning "0 blocks selected". The function then proceeds to return "No replaceable blocks selected."

 

It will also set the visibility, but that is neither here nor there if I cannot select the block I want to replace.

 

Any ideas on how to make a dynamic block replaceable or am I missing something here.

 

rec.dwg will be the block that will be inserted. test is the dwg i am trying to replace the block in.

 

-KGB

test.dwg

rec.dwg

dyntemp.lsp

Posted

found here http://forums.autodesk.com/t5/AutoCAD-Express-Tools/Block-Replace-possible-wishlist-item/m-p/361602

 

defun c:TEST (/ ENT1 BL1 NWNM OLD ODNM)
;;LOOKS LIKE robkimross WROTE IT IN 06-09-2005 
 (prompt "Select blocks to replace: ")
 (and
   (setq ENT1 (ssget "_:S" '((0 . "INSERT"))))
   (setq NEWBL "[color=darkred][b]NAME OF BLOCK WHICH TAKES THE PLACE OF OLD BLOCK[/b][/color]")
   (not (command "insert" NEWBL nil))
   (setq N (sslength ENT1))
   (setq I 0)
   (repeat N
     (setq BL1 (entget (ssname ENT1 I)))
     (setq NWNM (cons 2 NEWBL))
     (setq OLD (assoc 2 BL1))
     (setq ODNM (cdr OLD))
     (entmod (subst NWNM OLD BL1))
     (setq I (1+ I))
   ) ;_ repeat
 ) ;_ and
 (prin1)
) ;_ defun]

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