Jump to content

Recommended Posts

Posted

Dear All,

 

I would like to hatch all closed polyline in different layer and make it in different color. anyone know how to do that ?

 

Thanks !

Posted

Basically, may use:

 

(setq ClosedPlinesSSet (ssget "_X" (LIST '(0 . "LWPOLYLINE") '(70 . 1)))   ;select all closed polylines
     CrIndex 0)

(repeat (sslength ClosedPlinesSSet)                                        ;parse selection set items
(setvar "CECOLOR" (itoa (1+ CrIndex)))                                    ;change current color
(command "_HATCH" "_U" 45 1 "_N" (ssname ClosedPlinesSSet CrIndex) "")    ;apply hatch
(setq CrIndex (1+ CrIndex))                                               ;go to next entity
)

 

 

 

Regards,

Posted
Dear All,

 

I would like to hatch all closed polyline in different layer and make it in different color. anyone know how to do that ?

 

Thanks !

 

Here is another one

(defun C:hat (/ color en ha hp hs lname ltable sset)

(setq hp (getvar "hpname"))
(setvar "hpname" "ANSI37")     ;<-- hatch pattern name
(setq ha (getvar "hpassoc"))
(setvar "hpassoc" 1)      ;<-- set hatch associative
(setq hs (getvar "hpscale"))
(setvar "hpscale" 2.0)      ;<-- set hatch pattern scale
(setq sset
      (ssget "_X"
      (list
 (cons 0 "LWPOLYLINE")    ;<-- lightweight polylines only
 (cons 70 1)     ;<-- closed polylines
 (cons 410 (getvar "CTAB"))   ;<-- current space
 (cons 8 "Layer1,Layer2,Layer3,Layer4,Layer5")))) ;<--desired layer names, separated by comma
(while (setq en (ssname sset 0))
 (setq lname (cdr (assoc 8 (entget en))))
 (setq ltable (tblsearch "layer" lname))
 (setq color (cdr (assoc 62 ltable)))
 (command "._-hatch" "_S" en "" "")
 (command "._change"
   (entlast)
   ""
   "_PR"
   "_Layer"
   lname
   "_Color"
   "BYLAYER"
   "")
 (ssdel en sset))

(setvar "hpname" hp)      ;<-- restore hatch patter name
(setvar "hpassoc" ha)      ;<-- restore hatch asociativity
(setvar "hpscale" hs)      ;<-- restore hatch patter scale
(princ)
 )
(prompt
 "\n\t\t>>>\tType HAT to execute\t<<<")
(prin1)

 

~'J'~

Posted
Did he not like the answers in that thread then? :huh: :unsure:

WTF?!

I didn't even notice it was the same person. I guess the post is pointless. He'll probably never respond to this one either.:glare:

Posted
My thoughts exactly.

ugh. :|.............

  • 2 years later...
Posted

Hi Fixo,

The last line should be changed to (princ) not (prin1).

 

I was wondering if the routine could be modified so that if the area has already been hatched it does not get hatched again.

 

I have tried the routine it work beautifully except the drawings I am working on already have some hatches in them and when I run the routine the same area gets hatched again.

 

I look forward to your response with great anticipation.

Posted
The last line should be changed to (princ) not (prin1).

 

Why? ........

Posted

I'm so sorry later for reply, thank you very much for all of your help ! I like this answers very very much.

 

Did he not like the answers in that thread then? :huh: :unsure:
Posted

Thank you for MSasu, fixo, alanjt and Lee Mac. Forgive me later for reply, I don't why I haven't recieve any email from this post before. That why I haven't reply this post. Both of you is very kindly and helpful. Yours code is very very useful.

Posted
Here is another one

(defun C:hat (/ color en ha hp hs lname ltable sset)

(setq hp (getvar "hpname"))
(setvar "hpname" "ANSI37")     ;<-- hatch pattern name
(setq ha (getvar "hpassoc"))
(setvar "hpassoc" 1)      ;<-- set hatch associative
(setq hs (getvar "hpscale"))
(setvar "hpscale" 2.0)      ;<-- set hatch pattern scale
(setq sset
      (ssget "_X"
      (list
 (cons 0 "LWPOLYLINE")    ;<-- lightweight polylines only
 (cons 70 1)     ;<-- closed polylines
 (cons 410 (getvar "CTAB"))   ;<-- current space
 (cons 8 "Layer1,Layer2,Layer3,Layer4,Layer5")))) ;<--desired layer names, separated by comma
(while (setq en (ssname sset 0))
 (setq lname (cdr (assoc 8 (entget en))))
 (setq ltable (tblsearch "layer" lname))
 (setq color (cdr (assoc 62 ltable)))
 (command "._-hatch" "_S" en "" "")
 (command "._change"
   (entlast)
   ""
   "_PR"
   "_Layer"
   lname
   "_Color"
   "BYLAYER"
   "")
 (ssdel en sset))

(setvar "hpname" hp)      ;<-- restore hatch patter name
(setvar "hpassoc" ha)      ;<-- restore hatch asociativity
(setvar "hpscale" hs)      ;<-- restore hatch patter scale
(princ)
 )
(prompt
 "\n\t\t>>>\tType HAT to execute\t<<<")
(prin1)

 

~'J'~

 

Fixo Hello!

 

Your Lisp works great!

How could I change it if I just hatching (not two superimposed) would make per Polylinienumgrenzung in a selectable color?

 

Thanks for your help!

 

Best regards Martin

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