Remove a boundary from a hatch.. select objects problem

Remove a boundary from a hatch.. select objects problem

danglar
Advocate Advocate
1,684 Views
11 Replies
Message 1 of 12

Remove a boundary from a hatch.. select objects problem

danglar
Advocate
Advocate

I have a drawing with many "holes"(circles) in hatch and now I need to move all circles in a different places. After moving i have a boundaries remains in a hatch..

to remove it i use this little lisp:

 

(defun C:HR(/ gp) (setq gp (ssget))(command "-hatchedit" gp "r" ));remove boundary from hatch

 

but I have a problem when I need to select boundaries one by one..

Is it possible to select ALL boundaries in a one click in order to remove it?

Any help will be very appretiated

0 Likes
Accepted solutions (2)
1,685 Views
11 Replies
Replies (11)
Message 2 of 12

hmsilva
Mentor
Mentor
Accepted solution

@apelbaum2014 wrote:

I have a drawing with many "holes"(circles) in hatch and now I need to move all circles in a different places. After moving i have a boundaries remains in a hatch..

to remove it i use this little lisp:

 

(defun C:HR(/ gp) (setq gp (ssget))(command "-hatchedit" gp "r" ));remove boundary from hatch

 

but I have a problem when I need to select boundaries one by one..

Is it possible to select ALL boundaries in a one click in order to remove it?

Any help will be very appretiated


Hi apelbaum2014!

 

This is quick and dirty, and minimally tested, but it may get you started, and it will fail if outer boundary is also a CIRCLE.

I have a deadline to meet, so at the moment, I don't have much free time...

 

(vl-load-com)
(defun c:MHR (/ cen circle circles ent hnd i rad ss)
    (cond ((setq ss (ssget "_X" (list '(0 . "HATCH") (cons 410 (getvar 'ctab)))))
           (command "_.undo" "_G" "_.zoom" "_O" ss "")
           (repeat (setq i (sslength ss))
               (setq hnd     (ssname ss (setq i (1- i)))
                     ent     (entget hnd)
                     circles (vl-remove-if-not
                                 '(lambda (a)
                                      (and (= (car a) 330)
                                           (= (cdr (assoc 0 (entget (cdr a)))) "CIRCLE")
                                      )
                                  )
                                 ent
                             )
               )
               (cond (circles
                      (command "-hatchedit" hnd "r")
                      (foreach x circles
                          (setq circle (entget (cdr x))
                                cen    (cdr (assoc 10 circle))
                                rad    (cdr (assoc 40 circle))
                          )
                          (command (list (+ rad (car cen)) (cadr cen)))
                      )
                      (command "")
                     )
               )
           )
           (command "_.zoom" "_P" "_.undo" "_E")
          )
          (T
           (prompt "\Could not find any hatches... ")
          )
    )
    (princ)
) ;remove circle boundaries from hatch

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 12

danglar
Advocate
Advocate

Hi Henrique!

Thank you for the quick answer.

Unfortunaly, I don't now why, but I don't see any changes in my drawing after invoking MHR function. I mean hatch boundaries in circle form remanins in the drawing..

0 Likes
Message 4 of 12

hmsilva
Mentor
Mentor

@apelbaum2014 wrote:

Hi Henrique!

Thank you for the quick answer.

Unfortunaly, I don't now why, but I don't see any changes in my drawing after invoking MHR function. I mean hatch boundaries in circle form remanins in the drawing..


Hi apelbaum2014

Could you please post a sample dwg, with a before & after?

 

Henrique

EESignature

0 Likes
Message 5 of 12

danglar
Advocate
Advocate

this is sample dwg. i work on acad 2013 sp3

0 Likes
Message 6 of 12

marko_ribar
Advisor
Advisor
Remarks removed after reinspecting...
Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 7 of 12

hmsilva
Mentor
Mentor

@apelbaum2014 wrote:

this is sample dwg. i work on acad 2013 sp3


Sorry apelbaum2014,

but as I had already said, I have a deadline to meet, so at the moment, I don't have much free time....

 

Attached is a dwg where I tested the code with no problem...

When I have some spare time, I'll see what I can do.

 

Henrique

EESignature

0 Likes
Message 8 of 12

danglar
Advocate
Advocate
Thank you anyway Henrique.
It's intresting, but on your file MHR function works perfect and in a same time on my dwg not working at all...
0 Likes
Message 9 of 12

hmsilva
Mentor
Mentor
Accepted solution

@apelbaum2014 wrote:
Thank you anyway Henrique.
It's intresting, but on your file MHR function works perfect and in a same time on my dwg not working at all...

You're welcome, apelbaum2014
Another approach...Quick and dirty...

 

(defun c:MHR (/ cen cir i rad ss ss1)
    (cond ((and (princ "\nSelect hatch: ")
                (setq ss (ssget "_+.:E:S:L" '((0 . "HATCH") (-4 . ">") (91 . 1))))
                (princ "\nSelect CIRCLE boundaries to remove: ")
                (setq ss1 (ssget '((0 . "CIRCLE"))))
           )
           (command "_.undo" "_G" "_.zoom" "_O" ss "" "_.ucs" "_W")
           (command "-hatchedit" (ssname ss 0) "r")
           (repeat (setq i (sslength ss1))
               (setq cir (entget (ssname ss1 (setq i (1- i))))
                     cen (cdr (assoc 10 cir))
                     rad (cdr (assoc 40 cir))
               )
               (command (list (+ rad (car cen)) (cadr cen)))
           )
           (command "")
           (command "_.zoom" "_P" "_.ucs" "_P" "_.undo" "_E")
          )
    )
    (princ)
) ;remove boundary from hatch



Henrique

 

EESignature

Message 10 of 12

danglar
Advocate
Advocate

Now it's works like a charm!

Thank you Henrique!

0 Likes
Message 11 of 12

hmsilva
Mentor
Mentor

@apelbaum2014 wrote:

Now it's works like a charm!

Thank you Henrique!


You're welcome, apelbaum2014
Glad I could help

Henrique

EESignature

0 Likes
Message 12 of 12

danglar
Advocate
Advocate

...a little improvment

 

(setq ss1 (ssget '((0 . "CIRCLE,LWPOLYLINE,SPLINE"))))

 

 

and Henrique's program now can works with almost all entities as hatch boundaries

0 Likes