HELP: LISP that can combine/me
I have many blocks of the same name in 2 different files that i need to combine.Is there a LISP that can combine/merge items in a blocks that has the same names?
example.
Drawing "A" has a drawing of a table in a block called "FURNITURE"
Drawing "B" has a drawing of a chair in a block also called "FURNITURE"
After running the LISP routine:
Drawing "A" block "FURNITURE"will have now both Table & chair, in a single block.
Thanks You could rename the table block "Table" and the chair block "Chair" then combine both of them to a block called "FURNITURE".
You could also insert the chair exploded into drawing "A" next to the table then edit the table block "FURNITURE" in place to add the chair.
The chair would have to be placed in reference to the table.How often does a table have only one chair?I don't see how this could be made any easier with lisp.
Hi tombu. I understand what you mean. However the example I gave is only a simple example to explain the proposed routine of the LISP. My drawings do not contain tables or chairs.
My actual drawing is more complex.
The blocks in each drawing itself is close to a hundred. They are also nested blocks within different blocks/nested blocks at many levels deep. I have at least 30 pairs of such drawings as well. It will be near impossible to do it one at a time.
BTW, most of the blocks/nested blocks are xclip as well.
Due to the xclip of each blocks/nested blocks, I also have to maintain its original block/nested blocks depth & configuration.
Hence I do require a LISP to help me out.
Thanks
p.s.
Each pair of drawing that is to be merged do have the exact block names, depth & configuration You could probably do this with xrefs.It would be tedious to say the least.
open dwg 1, xref dwg 2, entmake a new block using the standard block table data, then entmake the data from the block contained in the xref but strip all of the xref prefix names.
Not an easy task-David
Hi david. What do you mean by
Could you elaborate more on the command required & the steps? The bottom line is drawing standards, by having 2 blocks the same name you are asking for trouble. lee-mac has a steal lisp can get a block from another dwg but again you would have to do its as 2 step process renaming one block. My suggestion take a deep breath and set some naming standards across all your drawings, if you dont have a master library of blocks well maybe its time to do that, it will only get worse the further you go. the nesting will make it even harder.
Hi BIGAL.
To clarify, there are no issues with the drawing naming. The merging of the pair of drawing is intended & not a mistake.
In actuality, the pair of drawings I want to combine is actually the same drawing but at different timing. So I have a current one & another that is 1 year ago.
Before the combining I will be changing the 1 year old drawing to yellow colour with hidden line type.
The old drawing is to merge below the current drawing.So that any lines that appear yellow with hidden line type means that that are changes being made there & also to show how it compare with the current which is of a different colour.
The purpose is to reflect that there are changes there to our local building authorities in our submission for approval
Regarding Lee Mac Steal program, I am using it to mainly steal UCS.But I guess it is not gonna work in my current work situation. If I understand :
DWG1 & DWG2 contain a block named BLOCK1
DWG3 has a BLOCK named BLOCK1 and DWG2 xrefed into it
:
(defun c:merge-b (/ en ss sn sd sb ed in td bn c xn bl l1 t1 fe fd t2 f2 la l2 s) (while (not en) (and (setq ss (ssget (list (cons 0 "INSERT")))) (= (sslength ss) 1) (setq sn (ssname ss 0) sd (entget sn) sb (cdr (assoc 2 sd))) (/= (logand (cdr (assoc 70 (tblsearch "BLOCK" sb))) 4) 4) (setq en sn))) (setq ed (entget en) in (cdr (assoc 2 ed))) (while (setq td (tblnext "BLOCK" (not td))) (setq bn (cdr (assoc 2 td))) (cond ((= (logand (cdr (assoc 70 td)) 16) 16) (setq c 1) (repeat (strlen bn) (if (= "|" (substr bn c 1)) (setq s c)) (setq c (1+ c))) (setq xn (substr bn (1+ s)) bl (cons (list bn xn (substr bn 1 s)) bl))))) (prin1 bl) (foreach b bl (if (not l1) (progn (setq t1 (tblsearch "BLOCK" (nth 1 b)) fe (cdr (assoc -2 t1))) (while fe (setq l1 (cons (cdr (entget fe)) l1) fe (entnext fe))) (setq l1 (reverse l1)))) (setq t2 (tblsearch "BLOCK" (nth 0 b)) f2 (cdr (assoc -2 t2)) l2 nil) (while f2 (setq fd (entget f2) la (cdr (assoc 8 fd)) fd (subst (cons 8 (substr la (1+ (strlen (nth 2 b))))) (assoc 8 fd) fd)) (if (and (assoc 6 fd) (tblsearch "LTYPE" (substr la (1+ (strlen (nth 2 b)))))) (setq fd (subst (cons 6 (substr la (1+ (strlen (nth 2 b))))) (assoc 6 fd) fd)) (setq fd (subst (cons 6 "BYLAYER")(assoc 6 fd) fd))) (setq l2 (cons (cdr fd) l2) f2 (entnext f2))) (setq l1 (append l1 l2))) (and l1 (entmake t1) (foreach e l1 (entmake e)) (entmake (list (cons 0 "ENDBLK")(cons 8 "0")))) (command "_.REGENALL") (prin1))
1 gotcha here is if the xref has a linetype that is not defined in the base drawing.I substituted BYLAYER.
I would not recommend this, as BigAl suggested, better standards.
-David
DWG1.DWG
DWG2.DWG
DWG3.DWG
You don't need multiple blocks to display them differently for different conditions.Just make sure color, linetype, and plot style is set to byblock and on layer 0 for everything in the blocks.When compairing existing -vs- design ore design -vs- as-built conditions we use the same blocks for each condition.You simply use different layers for different conditions with the correct colors, linetypes, and plot styles or have seperate drawings for the different conditions.
Except for blocks & xrefs all objects bylayer and never on layer 0 or defpoints.
Hi David.
Basically the merging of blocks is between the 2 duplicate drawings but at different dates.There are no xref in both drawings.
Meaning :
DWG 1 dated 22 aug 2015
(Contains Block/nested block 1 to 87)
DWG 1 dated 10 Jan 2014
Contains Block/nested block 1 to 87
What the proposed LISP will do is this:
Merge Block/nested block 1 to 87 (of DWG 1 dated 10 Jan 2014) into Block/nested block 1 to 87 (of DWG 1 dated 22 Aug 2015)
There will be 30 pairs of such drawings to be merged.
页:
[1]
2