Jump to content

HELP: LISP that can combine/merge items in a blocks that has the same name?


vernonlee

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Edited by vernonlee
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.

 

Could you elaborate more on the command required & the steps?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

If I understand :

 

DWG1 & DWG2 contain a block named BLOCK1

 

DWG3 has a BLOCK named BLOCK1 and DWG2 xrefed into it

 

:

 

[b][color=BLACK]([/color][/b]defun c:merge-b [b][color=FUCHSIA]([/color][/b]/ en ss sn sd sb ed in td bn c xn bl
                   l1 t1 fe fd t2 f2 la l2 s[b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not en[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]and [b][color=MAROON]([/color][/b]setq ss [b][color=GREEN]([/color][/b]ssget [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]cons 0 [color=#2f4f4f]"INSERT"[/color][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]= [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]setq sn [b][color=GREEN]([/color][/b]ssname ss 0[b][color=GREEN])[/color][/b]
                   sd [b][color=GREEN]([/color][/b]entget sn[b][color=GREEN])[/color][/b]
                   sb [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 2 sd[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]/= [b][color=GREEN]([/color][/b]logand [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 70 [b][color=PURPLE]([/color][/b]tblsearch [color=#2f4f4f]"BLOCK"[/color] sb[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] 4[b][color=GREEN])[/color][/b] 4[b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]setq en sn[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]setq ed [b][color=NAVY]([/color][/b]entget en[b][color=NAVY])[/color][/b]
       in [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 2 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq td [b][color=MAROON]([/color][/b]tblnext [color=#2f4f4f]"BLOCK"[/color] [b][color=GREEN]([/color][/b]not td[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq bn [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 2 td[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= [b][color=BLUE]([/color][/b]logand [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 70 td[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] 16[b][color=BLUE])[/color][/b] 16[b][color=GREEN])[/color][/b]
               [b][color=GREEN]([/color][/b]setq c 1[b][color=GREEN])[/color][/b]
               [b][color=GREEN]([/color][/b]repeat [b][color=BLUE]([/color][/b]strlen bn[b][color=BLUE])[/color][/b]
                       [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]= [color=#2f4f4f]"|"[/color] [b][color=PURPLE]([/color][/b]substr bn c 1[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                           [b][color=RED]([/color][/b]setq s c[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                       [b][color=BLUE]([/color][/b]setq c [b][color=RED]([/color][/b]1+ c[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
                [b][color=GREEN]([/color][/b]setq xn [b][color=BLUE]([/color][/b]substr bn [b][color=RED]([/color][/b]1+ s[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                      bl [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]list bn xn [b][color=PURPLE]([/color][/b]substr bn 1 s[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] bl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]prin1 bl[b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]foreach b bl

     [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]not l1[b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]progn
           [b][color=GREEN]([/color][/b]setq t1 [b][color=BLUE]([/color][/b]tblsearch [color=#2f4f4f]"BLOCK"[/color] [b][color=RED]([/color][/b]nth 1 b[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                 fe [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc -2 t1[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
           [b][color=GREEN]([/color][/b]while fe
               [b][color=BLUE]([/color][/b]setq l1 [b][color=RED]([/color][/b]cons [b][color=PURPLE]([/color][/b]cdr [b][color=TEAL]([/color][/b]entget fe[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] l1[b][color=RED])[/color][/b]
                     fe [b][color=RED]([/color][/b]entnext fe[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
           [b][color=GREEN]([/color][/b]setq l1 [b][color=BLUE]([/color][/b]reverse l1[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

     [b][color=NAVY]([/color][/b]setq t2 [b][color=MAROON]([/color][/b]tblsearch [color=#2f4f4f]"BLOCK"[/color] [b][color=GREEN]([/color][/b]nth 0 b[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
           f2 [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc -2 t2[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
           l2 nil[b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]while f2
         [b][color=MAROON]([/color][/b]setq fd [b][color=GREEN]([/color][/b]entget f2[b][color=GREEN])[/color][/b]
               la [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 8 fd[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
               fd [b][color=GREEN]([/color][/b]subst [b][color=BLUE]([/color][/b]cons 8 [b][color=RED]([/color][/b]substr la [b][color=PURPLE]([/color][/b]1+ [b][color=TEAL]([/color][/b]strlen [b][color=OLIVE]([/color][/b]nth 2 b[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b]
                         [b][color=BLUE]([/color][/b]assoc 8 fd[b][color=BLUE])[/color][/b] fd[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]assoc 6 fd[b][color=BLUE])[/color][/b]
                  [b][color=BLUE]([/color][/b]tblsearch [color=#2f4f4f]"LTYPE"[/color] [b][color=RED]([/color][/b]substr la [b][color=PURPLE]([/color][/b]1+ [b][color=TEAL]([/color][/b]strlen [b][color=OLIVE]([/color][/b]nth 2 b[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
             [b][color=GREEN]([/color][/b]setq fd [b][color=BLUE]([/color][/b]subst [b][color=RED]([/color][/b]cons 6 [b][color=PURPLE]([/color][/b]substr la [b][color=TEAL]([/color][/b]1+ [b][color=OLIVE]([/color][/b]strlen [b][color=GRAY]([/color][/b]nth 2 b[b][color=GRAY])[/color][/b][b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                             [b][color=RED]([/color][/b]assoc 6 fd[b][color=RED])[/color][/b] fd[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
             [b][color=GREEN]([/color][/b]setq fd [b][color=BLUE]([/color][/b]subst [b][color=RED]([/color][/b]cons 6 [color=#2f4f4f]"BYLAYER"[/color][b][color=RED])[/color][/b][b][color=RED]([/color][/b]assoc 6 fd[b][color=RED])[/color][/b] fd[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]

         [b][color=MAROON]([/color][/b]setq l2 [b][color=GREEN]([/color][/b]cons [b][color=BLUE]([/color][/b]cdr fd[b][color=BLUE])[/color][/b] l2[b][color=GREEN])[/color][/b]
               f2 [b][color=GREEN]([/color][/b]entnext f2[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

     [b][color=NAVY]([/color][/b]setq l1 [b][color=MAROON]([/color][/b]append l1 l2[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]


 [b][color=FUCHSIA]([/color][/b]and l1
   [b][color=NAVY]([/color][/b]entmake t1[b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]foreach e l1
     [b][color=MAROON]([/color][/b]entmake e[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
   [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"ENDBLK"[/color][b][color=GREEN])[/color][/b][b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"0"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.REGENALL"[/color][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

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

Link to comment
Share on other sites

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.

 

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.

Link to comment
Share on other sites

If I understand :

 

DWG1 & DWG2 contain a block named BLOCK1

 

DWG3 has a BLOCK named BLOCK1 and DWG2 xrefed into it

 

-David

 

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.

Edited by vernonlee
Link to comment
Share on other sites

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 tombu. Took me a while to digest what you wrote

 

I may misinterpret you but here goes:

 

This blocks originate from xref. Because of similar or part of the similar unit profile at various floors xref is used to reduce amending the same thing at multiple floors. Nobody wants to amend the same unit 120 times (& that is just 1 unit profile)

 

Each floor will have a mix of unit profile, meaning having multiple xref units.

BUT because not a full profile of the each unit (each xref) is required, xclip is used to clip them out.

Due to xclip being use, there various xref need to be stacked in a particular order.

 

Also these are existing drawing.

 

When preparing for submission , the drawings are binded. Thereby it comes blocks.

 

Next. Ordinarily, we just have to insert the older drawing (after change to yellow hidden linetype ) as a whole. BUT because of the multiple xclip blocks STACKED IN A SPECIFIC ORDER, I cannot insert the older drawing as a whole. If I do that then the blocks with xlips will coverup the older drawing & they cannot be seen.

 

Therefore I need a LISP to insert/merge the items of the old drawing to the new base on "inserting" into its own individual blocks, based on their block names

 

I hope this explains it.

Link to comment
Share on other sites

Just trying to come up with a procedure to do what you're asking for.

By renaming and modifying the layer "FURNITURE" is on in each drawing you can have "FURNITURE" display however you want. The only modification that may be needed would be to set all object properties in each "FURNITURE" block to bylayer on layer 0.

 

Does that sound like what you're looking for? If not could you describe the procedure a little more? Could you attach as small as possible "A" & "B" drawings so we can see what you are trying to do? Hard to imagine combining a chair block & a table block working without seeing the drawings. The chair would have to be placed in reference to the table. Does the table really have only one chair?

Link to comment
Share on other sites

Just trying to come up with a procedure to do what you're asking for.

By renaming and modifying the layer "FURNITURE" is on in each drawing you can have "FURNITURE" display however you want. The only modification that may be needed would be to set all object properties in each "FURNITURE" block to bylayer on layer 0.

 

Does that sound like what you're looking for? If not could you describe the procedure a little more? Could you attach as small as possible "A" & "B" drawings so we can see what you are trying to do? Hard to imagine combining a chair block & a table block working without seeing the drawings. The chair would have to be placed in reference to the table. Does the table really have only one chair?

 

Did my previous post above explain the rational & purpose?

 

Anyway to summaries:-

 

- there is no furniture. There are no tables or chairs in my drawing. The example I gave is only an example

- merging of blocks is between the 2 same drawings but at different dates. (This is to To reflect the changes)

- both drawings share the same layering names & there are over 100 layers names depending on the element.

NOT on the blocks.

 

Hope that is a better description. Unfortunately I am not able to attached a dwg as it would reveal my work.

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