Message 1 of 18
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys
How can I delete Exploded Hatch objects that are within a boundary?
sample file is attached.
Thanks.
Solved! Go to Solution.
Hello guys
How can I delete Exploded Hatch objects that are within a boundary?
sample file is attached.
Thanks.
Solved! Go to Solution.
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
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.
@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
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
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.
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.
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.
@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.
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.
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))))
@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
@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.]