Jump to content

Recommended Posts

Posted

I believe I found this LISP on this site a while back, and it actually works great. Its for duplicating and inserting a block, which also asks for for new attribute definitions.

 

What i need help with, is every time the block is duplicated it asks for scale and rotation once inserted. I would like to get rid of those 2 steps if possible.

 

Any help always appreciated! :)

 

;;; Create a duplicate block definition
(defun c:DD (/ en ed bname nname fname fdia)
 (if (and (setq en (entsel "\nPick block: "))
          (setq ed (entget (car en)))
          (= (cdr (assoc 0 ed)) "INSERT")
          (setq nname (getstring nil "\nNew name: "))
     ) ;_ end of and
   (progn
     (setq bname (cdr (assoc 2 ed))
           fname (strcat (getvar "TEMPPREFIX") nname ".DWG")
     ) ;_ end of setq
     (if (findfile fname)
       (vl-file-delete fname)
     ) ;_ end of if
     (setq fdia (getvar "FILEDIA"))
     (setvar "FILEDIA" 0)
     (command ".-WBLOCK" fname bname)
     (command ".-INSERT" fname)
     (setvar "FILEDIA" fdia)
   ) ;_ end of progn
 ) ;_ end of if
 (princ)
) ;_ end of defun

Posted

Ugly. but will work....

 

;;; Create a duplicate block definition
(defun c:DD (/ en ed bname nname fname fdia)
 (if (and (setq en (entsel "\nPick block: "))
          (setq ed (entget (car en)))
          (= (cdr (assoc 0 ed)) "INSERT")
          (setq nname (getstring nil "\nNew name: "))
     ) ;_ end of and
   (progn
     (setq bname (cdr (assoc 2 ed))
           fname (strcat (getvar "TEMPPREFIX") nname ".DWG")
     ) ;_ end of setq
     (if (findfile fname)
       (vl-file-delete fname)
     ) ;_ end of if
     (setq fdia (getvar "FILEDIA"))
     (setvar "FILEDIA" 0)
     (command ".-WBLOCK" fname bname)
     (command ".-INSERT" fname (getpoint) 1 1 0)
     (setvar "FILEDIA" fdia)
   ) ;_ end of progn
 ) ;_ end of if
 (princ)
) ;_ end of defun

 

so all you want is a block thats the same as another block just with a different name?

Posted

I have a block with 3 attributes, which i need to repeatedly copy/paste for different info on different parts of the drawing.

 

The only input i actually need when inserting the block, is for the block name and for another attribute, which i setup when i make the block.

 

This lisp does just that, except it asks for scale/rot when i go to insert the block, and its just a couple of unneccesary steps for me

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