Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remove a boundary from a hatch.. select objects problem

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
danglar
1182 Views, 11 Replies

Remove a boundary from a hatch.. select objects problem

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

11 REPLIES 11
Message 2 of 12
hmsilva
in reply to: danglar


@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

Message 3 of 12
danglar
in reply to: hmsilva

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

Message 4 of 12
hmsilva
in reply to: danglar


@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

Message 5 of 12
danglar
in reply to: hmsilva

this is sample dwg. i work on acad 2013 sp3

Message 6 of 12
marko_ribar
in reply to: danglar

Remarks removed after reinspecting...
Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 7 of 12
hmsilva
in reply to: danglar


@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

Message 8 of 12
danglar
in reply to: hmsilva

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...
Message 9 of 12
hmsilva
in reply to: danglar


@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
in reply to: hmsilva

Now it's works like a charm!

Thank you Henrique!

Message 11 of 12
hmsilva
in reply to: danglar


@apelbaum2014 wrote:

Now it's works like a charm!

Thank you Henrique!


You're welcome, apelbaum2014
Glad I could help

Henrique

EESignature

Message 12 of 12
danglar
in reply to: danglar

...a little improvment

 

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

 

 

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost