V4Mp Posted August 31, 2020 Posted August 31, 2020 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 Quote
BIGAL Posted August 31, 2020 Posted August 31, 2020 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. Quote
Dadgad Posted September 1, 2020 Posted September 1, 2020 (edited) Welcome to CADTutor V4Mp. When in doubt Check Lee-Mac out! http://www.lee-mac.com/copyblock.html Thanks Lee! Edited September 1, 2020 by Dadgad greeting added 1 Quote
Dadgad Posted September 1, 2020 Posted September 1, 2020 It looks like the BR (Block Rename) option in Lee's lisp would be a pretty painless way to do this. 1 Quote
V4Mp Posted September 1, 2020 Author Posted September 1, 2020 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? Quote
V4Mp Posted September 1, 2020 Author Posted September 1, 2020 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... Quote
V4Mp Posted September 1, 2020 Author Posted September 1, 2020 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 1 Quote
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.