Exploded Hatch Delete

Exploded Hatch Delete

k005
Advisor Advisor
2,257 Views
17 Replies
Message 1 of 18

Exploded Hatch Delete

k005
Advisor
Advisor

Hello guys

 

How can I delete Exploded Hatch objects that are within a boundary?

 

sample file is attached.

 

Thanks.

0 Likes
Accepted solutions (3)
2,258 Views
17 Replies
Replies (17)
Message 2 of 18

hak_vz
Advisor
Advisor

Since boundary is also exploded it will take same amount of time to run a lisp or erase hatch remains. Automatic entity erase may result with removing boundary polylines.

If you don't have hatch remains with horizontal or vertical polylines one can create a list that will take all polylines whose angle between start point and endpoint is not 0 90 or variations.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 18

k005
Advisor
Advisor

Generally, as in the example I gave...

borders are not polylines.

0 and 90 degrees are correct. It may be different, but that's how it usually is.

We do not process those with different angles.

0 Likes
Message 4 of 18

hak_vz
Advisor
Advisor
Accepted solution

@k005   Try this, It may work for you. Not fully tested.

 

 

(defun c:dhr ( / rad_to_deg ss i eo ang)
(defun rad_to_deg (rad)(* 180.0 (/ rad pi)))
(setq ss (ssget '((0 . "LWPOLYLINE")(90 . 2))))
(setq i -1)
(while (< (setq i (1+ i)) (sslength ss))
(setq eo (vlax-ename->vla-object (ssname ss i)))
(setq ang (rtos(rad_to_deg(angle (vlax-curve-getStartpoint eo)(vlax-curve-getEndpoint eo))) 2 0))
(if(not(member ang '("0" "90" "180" "270"))) (entdel (ssname ss i)))
)
(princ)
)

 

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 18

k005
Advisor
Advisor

@hak_vz 

I think it will... but I got an error load lisp.

 

; error: misplaced dot on input

0 Likes
Message 6 of 18

hak_vz
Advisor
Advisor

Edited under #4.  A space was missing between  ."LWPOLYLINE". That is the reason you should learn at least basics of autolisp, so you can check for basic errors. 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 18

k005
Advisor
Advisor

I already know the basics. I didn't even have to do a few tries. I am also encountering an error for the first time.

Message 8 of 18

k005
Advisor
Advisor

@hak_vz 

In one word, Super! thank you very much.

0 Likes
Message 9 of 18

Kent1Cooper
Consultant
Consultant

I don't understand.  Exploding a Hatch pattern results in Lines, not Polylines.  What's really happening to get you to your "before" condition?  It would be easy to delete all Hatch patterns on a particular Layer, or with a particular color override, or of a particular pattern, if you eliminate the Exploding.

Kent Cooper, AIA
0 Likes
Message 10 of 18

k005
Advisor
Advisor

@Kent1Cooper 

 

 

Yes of course. it is much easier as you say without blasting. I agree here.

 

But;

 

now border lines and hatching are done on the same layer. This is trouble. Layered not worked....

and sometimes it may be necessary to explode it...

 

this is how it is... Thank you.

0 Likes
Message 11 of 18

Kent1Cooper
Consultant
Consultant

@k005 wrote:

.... border lines and hatching are done on the same layer. This is trouble. Layered not worked....


So whom do you need to tell to not put the border lines and Hatching on the same Layer, to eliminate that trouble?

 

What does "Layered not worked" mean?  Explain in more detail.

 

And nothing there explains how you ended up with a lot of little Polylines where presumably there were Hatch patterns -- that is not what you get from from Exploding Hatch patterns, which means something else is happening.

Kent Cooper, AIA
0 Likes
Message 12 of 18

k005
Advisor
Advisor

@Kent1Cooper 

 

Unfortunately, you can't tell this to anyone.

"What does "Layered not worked" mean? Explain in more detail. "

that is, these projects are sent to us. we cannot criticize it as "you didn't work here with layers". There are many different situations. some projects may seem layered...

In short, there is no standard like what you say, unfortunately. The working logics within the project are variable.

0 Likes
Message 13 of 18

k005
Advisor
Advisor

@hak_vz 

 

Friend;

The example I sent had LWPOLYLINE.

Can we add LINE to this part? Sometimes when Scan is Exploded, LINE can also happen...

 

 

(setq ss (ssget '((0 . "LWPOLYLINE")(90 . 2))))

 

 

 

0 Likes
Message 14 of 18

hak_vz
Advisor
Advisor
Accepted solution

@k005  Try this

(defun c:dhr ( / rad_to_deg ss i eo ang)
	(defun rad_to_deg (rad)(* 180.0 (/ rad pi)))
	(setq ss (ssget '((0 . "LWPOLYLINE,LINE"))))
	(setq i -1)
	(while (< (setq i (1+ i)) (sslength ss))
		(setq eo (vlax-ename->vla-object (ssname ss i)))
		(cond
			((= (vlax-get eo 'ObjectName) "AcDbPolyline")	
				(cond 
					((= (length (vlax-get eo 'Coordinates)) 4)
						(setq ang (rtos(rad_to_deg(angle (vlax-curve-getStartpoint eo)(vlax-curve-getEndpoint eo))) 2 0))
						(if(not(member ang '("0" "90" "180" "270"))) (entdel (ssname ss i)))
					)
				)
			)	
			((= (vlax-get eo 'ObjectName) "AcDbLine")	
				(setq ang (rtos(rad_to_deg(angle (vlax-curve-getStartpoint eo)(vlax-curve-getEndpoint eo))) 2 0))
				(if(not(member ang '("0" "90" "180" "270"))) (entdel (ssname ss i)))
			)
		)
	)
	(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 15 of 18

k005
Advisor
Advisor

@hak_vz 

 

In one word, Super. It was very nice.

Thank you my friend.

0 Likes
Message 16 of 18

hak_vz
Advisor
Advisor

@k005  You're welcome!

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 17 of 18

Kent1Cooper
Consultant
Consultant
Accepted solution

@k005 wrote:

....

The example I sent had LWPOLYLINE.

.... Sometimes when Scan is Exploded, LINE can also happen...


Here's another approach.  It filters the selection to allow only Lines or single-line-segment open LWPolylines, so when it's stepping through the selection [if any such things were selected], there's no need to check for those characteristics depending on which object type each one is -- it needs to look only at the angle.  And for that, it just checks whether there's any non-zero remainder when the angle is divided by 90°, working directly with the radian values without the need to convert to degrees.

(defun C:RAL ; = Remove Angled [poly]Lines
  (/ ss n ent)
  (if
    (setq ss
      (ssget '(
        (-4 . "<OR")
          (0 . "LINE")
          (-4 . "<AND")
            (0 . "LWPOLYLINE")
            (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"); open only
            (90 . 2); 2 vertices only
            (42 . 0); line segment only
          (-4 . "AND>")
        (-4 . "OR>")
      )) ; filter list & ssget
    ); setq
    (repeat (setq n (sslength ss)); then
      (setq ent (ssname ss (setq n (1- n))))
      (if
        (not ; not orthogonal?
          (equal
            (rem
              (angle (vlax-curve-getStartPoint ent) (vlax-curve-getEndPoint ent))
              (/ pi 2); 90° divisor
            ); rem
            0 1e-4
          ); equal
        ); not
        (entdel ent); then -- remove it
      ); if
    ); repeat
  ); if
  (princ)
); defun

[You can collapse a lot of the lines and remove commentary, to shorten it -- I left it expanded for clarity of what's going on.]

Kent Cooper, AIA
Message 18 of 18

k005
Advisor
Advisor

@Kent1Cooper 

 

Thank you very much, it's ok. 🤗

0 Likes