Jump to content
Holybod

How to add a single boundary outline around multiple hatches.

Recommended Posts

Holybod

Hi Guys,

 

I'm currently working on a large scale map. The map I've purchased contains building areas as hatching but no boundary outline (to my shock). The map is laid out in tiles which has meant on many occasions buildings have been cut into 2 or more sections rather than the 1.

 

I have downloaded a Merge Hatch.Lsp which merges all the building Hatches together but when I go to recreate boundary via 'HATCHEDIT' it just draws a line around each piece of hatching rather than the whole lot.

 

Can anyone help me with this please, Many Thanks.

 

Liam :)

Share this post


Link to post
Share on other sites
ReMark

I think I might be able to help but you will have to change the lisp routine you are currently using to merge your hatch patterns and adopt a second lisp routine that will create a single boundary.

 

CAVEAT: I've only tested this technique once using nearly square hatch patterns. Here is an image of what I did.

 

MergedHatches.JPG

 

Upper left corner. Two boxes created with the Rectangle command which I hatched then moved the two hatch patterns to the right assigning each a different color (yellow and blue).

 

Used a lisp routine by forum member hmsilva that he graciously wrote and shared on the AutoDesk Community website and posted to the Visual Lisp...forum on 04-12-2013 to merge the two patterns. Result is shown below in green.

 

Finally, used a lisp routine called Hatchb.lsp written (03-30-2000) by Jimmy Bergmark that recreates a hatch boundary. If you look at the bottom rectangle on the right you'll see a single magenta boundary that surrounds the two merged hatch patterns. I suppose there is a chance that this lisp routine will solve your problem all by itself. Might want to give it a try first.

 

My test was a simple one. As the saying goes "Your results may vary."

 

I'm only around for another five minutes then I have to go out into the plant. May not be back for a while.

Edited by ReMark
can't spell today & I don't know my left from my right!

Share this post


Link to post
Share on other sites
BIGAL

There was a post about 2 weeks ago and it did exactly what you want taking multiple plines and working out the single boundary of all of them you can create the hatch boundaries pretty easy. I know I replied to the post but another provided the solution will look for it soon.

Edited by BIGAL

Share this post


Link to post
Share on other sites
Holybod

Thanks Guys, I will test these out and let you know how I get on... :)

 

...

 

Struggling to find hmsilva's lisp on the AutoCAD Community website. Do you have a link?

 

When using the HATCHB.lsp along with the MergeHatch.lsp I already have I am encountering the same issues I had before.

Edited by Holybod

Share this post


Link to post
Share on other sites
lrm

Here's another approach that relies only on standard AutoCAD commands. You can use this process on all hatches at the same time.

Use HATCHGENERATEBOUNDARY to generate the boundary for all hatches then convert the boundaries to Regions then use Union to create contiguous regions from which you can use the Hatch S command to hatch the result.

Share this post


Link to post
Share on other sites
ReMark

"When using the HATCHB.lsp along with the MergeHatch.lsp I already have I am encountering the same issues I had before."

 

I kind of figured you would.

 

Wait here, I'll be back.8)

 

I've attached the lisp routine below. Note that he gave it the command name "test" which you will have to change. I named the lisp routine HatchMerge.lsp to differentiate it from the MergeHatch.lsp routine which I too have.

 

HatchMerge.lsp

 

I added two lines to the lisp routine right at the top crediting hmsilva as the author. Please do not remove them.

Share this post


Link to post
Share on other sites
ReMark
Here's another approach that relies only on standard AutoCAD commands. You can use this process on all hatches at the same time.

Use HATCHGENERATEBOUNDARY to generate the boundary for all hatches then convert the boundaries to Regions then use Union to create contiguous regions from which you can use the Hatch S command to hatch the result.

 

A person could die of old age using that method on a very busy drawing. Just saying.:lol:

Share this post


Link to post
Share on other sites
hmsilva

I added two lines to the lisp routine right at the top crediting hmsilva as the author. Please do not remove them.

 

Thank you! ReMark

 

Henrique

Share this post


Link to post
Share on other sites
Holybod

Hi ReMark, Thanks again for putting your time into this.

 

I've tested the HATCHMERGE.lsp which works brilliantly on basic rectangles like your example.

However, when using this routine on more complex shapes with numerous vertex points it purely deletes/removes them rather then merging.

Share this post


Link to post
Share on other sites
hmsilva

...when using this routine on more complex shapes with numerous vertex points it purely deletes/removes them rather then merging.

 

 

Hi Holybod,

could you attach a sample dwg with some hatches that gives you error.

 

 

Henrique

Share this post


Link to post
Share on other sites
lrm
A person could die of old age using that method on a very busy drawing. Just saying.:lol:

Not really. You can select all the hatched areas at the same time which would take less than a minute if layers were intelligently used. The other commands I listed can also be used with all the hatched areas at the same time as well. Total time could be less than a few minutes. Try it.

Share this post


Link to post
Share on other sites
ReMark

I'd sooner gouge my one good eye out with a spoon. A spoon? Why? Because it would hurt more!:ouch::lol:

Share this post


Link to post
Share on other sites
lrm
I'd sooner gouge my one good eye out with a spoon. A spoon? Why? Because it would hurt more!:ouch::lol:

 

Funny. I guess you like debugging lisp code. Have fun with that. I thought I'd offer the OP a working, efficient solution that doesn't require debugging. ;)

Share this post


Link to post
Share on other sites
ReMark

No I don't like debugging lisp code. I leave tasks like that to people who know what they are doing.

 

I guess we would know better how well the method works if the OP were to provide an actual drawing that he is working on. Then the two of you can apply the method you have described and compare notes afterwards.

Share this post


Link to post
Share on other sites
ReMark

Did you try Irm's suggested method?

 

How representative is your example drawing? It has about 5000 hatch objects. Is this about average or could a drawing have two, even three (or more) times that many hatch objects?

Share this post


Link to post
Share on other sites
hmsilva

Hi Holybod,

 

 

I did reproduce that error.

The error is because the code uses the command '-hatchedit' and AutoCAD can't resolve the boundaries in almost all existing hatches in your dwg...Why? I do not know...

I did also noticed, using the HATCHGENERATEBOUNDARY command, AutoCAD can resolve the boundaries...

 

 

I am out of the office, but later, I see what I can do to rewrite the code using the HATCHGENERATEBOUNDARY command...

 

EDIT:

Sorry Holybod,

 

but, after some thought I believe it will not be viable using the HATCHGENERATEBOUNDARY command in the code, because it will be practically impossible to ensure the relationship between the outer boundary and existing Islands...

 

Your dwg hatches were generated using some weird UCS, as a result AutoCAD can't resolve the boundaries with '-hatchedit' command.

 

Open your dwg, ucs World, command flatten, select all hatches, try now the MergeHatch.lsp

 

Henrique

Edited by hmsilva

Share this post


Link to post
Share on other sites
Holybod

The 'Map Hatching Example.dwg' is the building Areas of the map in question, copied to another file.

 

I was given the map to work from by another company who had produced the map themselves.

 

I will give that a go, I don't have AutoCAD at my office but will let you know how I get on with both or your methods.

 

Again thanks for your time taken on this.

Share this post


Link to post
Share on other sites
lrm

I tried my method on the OP's posted drawing. The good news... HATCHGENERATEBOUNDARY followed by REGION then UNION then EXPLODE will create 2076 individual appropriately merged boundaries from the 4790 hatched areas. The bad news... hatching the 2076 regions in one step yields one hatched area which I cannot separate into individual hatched areas (if that is what the OP wants). Perhaps this is the point where VLISP is needed.

Note, the default file yields a very dense pattern. I changed it to solid fill.

https://dl.dropboxusercontent.com/u/18135203/Merged-Boundaries-ManyRegions.dwg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×