Jump to content

Multiple hatches in multiple layers


romrom

Recommended Posts

Hello

When I export polygons from arcgis to autocad, I’m loosing all my hatches, from differents layers, I’ve only get closed polylines !

Question : is it possible to make a lisp to create differents hatch type in differents layers at once with all closed polylines from those layers ?

Thank you for your help

Link to comment
Share on other sites

The "simple" way would be to be to cycle through your selection checking for closed polylines.

if the object's a closed polyline then read off it's layer, and set that to current.

Hatch the object on the current layer.

Probably three quarters of this code would be essentially mimicking what you'd do on the command line.

 

 

A more complicated way to code it, but probably quicker would be to sort through all the objects, filtering them for their layer and filtering into lists to match.

You could then cycle through those lists hatching them onto a specific layer.

 

 

dJE

Link to comment
Share on other sites

Need a sample dwg and some rules what hatch goes on what layer etc. Like danellis its not a very hard task but its better to do once hence a sample required.

Link to comment
Share on other sites

cadtutor.DWG

 

here is a sample dwg it contains only good layers with closed polylines.

So I need to hatch each closed polyline of each layer in the same layer as the polyline...

Thank you very much for answers!

Link to comment
Share on other sites

This is a bit rough but its a start and gives the method. One problem maybe your polylines are by colour not bylayer.

 

(defun c:polhatch ( / obj ss len layname)
(setq oldhatch (getvar "HPNAME")) 
(setq ss (ssget "X" (list (cons 0 "LWPOLYLINE"))))
(setq len (sslength  ss))
(setq x 0)
(repeat len
(setq obj (entget (ssname ss x)))
(setq layname (cdr (assoc 8 obj)))
(setvar "Clayer" layname)
;(setvar "hpname" "newhatchpattern") ;Sets a default hatch pattern name of up to 34 characters without spaces
(command "-hatch" "S" (cdr (assoc -1 obj)) "" "")
(setq x (+ x 1))
)
(setvar "Hpname" oldhatch) ;reset back to original pattern
)

Edited by BIGAL
Link to comment
Share on other sites

[ATTACH]53868[/ATTACH]

...

So I need to hatch each closed polyline of each layer in the same layer as the polyline...

Thank you very much for answers!

 

Not necessarily, although that was what I'd thought you wanted to do from your OP.

 

 

If you needed them to be on different layers then you'd need to include for a "converter" to tell the routine that a polyline on layer 1 would need to be hatched on layer A.

 

 

dJE

Link to comment
Share on other sites

thanks for answering!

the code doesn't work but i'm very bad in lisp so I'm sure I make a mistake when I try to use it!

 

 

I

Link to comment
Share on other sites

Not necessarily, although that was what I'd thought you wanted to do from your OP.

 

 

If you needed them to be on different layers then you'd need to include for a "converter" to tell the routine that a polyline on layer 1 would need to be hatched on layer A.

 

 

dJE

 

danellis the lisp does hatch on same layer as pline as per request ? Same layer as the polyline...

 

 

Bigal, RomRom's post #4 implied to me that he may want the hatching on separate layers, but he'd have to clarify that.

 

 

 

thanks for answering!

the code doesn't work but i'm very bad in lisp so I'm sure I make a mistake when I try to use it!

 

 

I

 

 

Are you getting any error messages?

 

 

dJE

Link to comment
Share on other sites

thank you again, you are very friendly boys!!

I had a error message but now it works, why: in french the command is not "-hatch" but "-hachures" :D

So now I can see the result it's not bad, it's a good beginning!

now if it's possible to select Automatically all boundaries when typing the "polhatch" command it's a magical command :)

and if the hatches take the same color as the closed polyline it's a perfect command (the layer is already a very good thing!)

And when somebody find the solution I can send him a real french camembert for thanking!

for australia it should be a long trip for it !!

Thanks again

Link to comment
Share on other sites

You can fix the lisp for future reference I think its ._Hatch its to do with the period or underscore that makes it language independant. not sure if I had done it as Vl-addhatch wether the french version would be of any effect.

 

Almost forgot ssget "X" is select all rather than just ssget options are like W CP WP check code it has been updated.

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