Jump to content

Block copy with new name and replace existing


V4Mp

Recommended Posts

Hello,

 

I am new to lisp, but I knew a little bit of VBA/VB.net and a tiny bit of C#.

I need a lisp code, that simply copy a block by it's name and replace the existing block (only in aktiv layout) with the new copy. Name of the new copy must be ("object-modell" + layoutname)

 

In example:

I already copy the layout with lisp and a new name. New layoutname is 2. I simply count it up.

I have a block called "object-modell1". "1" is the name of the layout I copied.

And then I want to copy the block and replace it with a the new block named "object-modell2".

 

I would be realy thankfull for any help.

 

Flo

Link to comment
Share on other sites

What is the difference between these blocks sounds like a title block thing so much easier to update attributes than renaming blocks. Please post a dwg or image showing details.

Link to comment
Share on other sites

I want to run a complete code to make all the things I need to change in a layout at once. I knew the attribut method, but for me its no solution, because the blocks have more information, that needed to be copied.

 

I already found some code and edited it.

It copy the layout with a new name, that can be given by the user.
Only thing I need is a "copy block with name MyBlock_OldLayout" as "MyBlock_NewLayoutName". The 


If I try to use the name insted of selecting the block, it doesnt work. Maybe the select method select a list/dict or array with infos?

Link to comment
Share on other sites

Ok... I dont knew whats wrong...

Following code chould change my block in aktiv layout to the new one I copied.

 

(setq num1 (1))
(setq num2 (2))
(setq bnameold (strcat "Gruppe" num1)) ; Name des original Blocks aus Layout
(setq bnamenew (strcat "Gruppe" num2)) ; Name des original Blocks aus Layout

    (if (setq ss (ssget "X" (list '(2 . bnameold) (cons 410 (getvar "ctab")))))

    (repeat (setq n (sslength ss))

      (setq edata (entget (ssname ss (setq n (1- n)))))

      (entmod (subst '(2 . bnamenew) '(2 . bnameold) edata))

    ); repeat

  ); if

 

Error: Fehlerhafter SSGET-Listenwert

 

Don't knew why... 

Link to comment
Share on other sites

Thanks. Code worked now for me.

 

(setq num1 (1))
(setq num2 (2))
(setq bnameold (strcat "Gruppe" num1)) ; Name des original Blocks aus Layout
(setq bnamenew (strcat "Gruppe" num2)) ; Name des original Blocks aus Layout

    (if (setq ss (ssget "X" (list (cons 2 bnameold) (cons 410 (getvar "ctab")))))

    (repeat (setq n (sslength ss))

      (setq edata (entget (ssname ss (setq n (1- n)))))

      (entmod (subst (cons 2 bnamenew) (cons 2 bnameold) edata))

    ); repeat

  ); if

 

  • Thanks 1
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...