Author Topic: find holed hatched ~  (Read 1493 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
find holed hatched ~
« on: May 27, 2018, 09:08:42 AM »
Good morning
I have a really good Lisp here, and for me,
I thought i did not need a new Lisp.
Curiosity continues to play.
I really want to say sorry.
Could I ask you a question though
I just want to find hatches with holes.
Is this possible?
I think that if you find a hatch in the hatch area and only 0.5-0.8% of the hatch's bounding box area
I think it's a limitation of my head to implement it.
Poor beginner please save me ~
i attached file ~

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: find holed hatched ~
« Reply #1 on: May 27, 2018, 11:57:45 AM »
You could test for hatch objects for which at least one of the boundary paths is a non-external path (DXF 92&1 = 0), for example:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( )
  2.     (sssetfirst nil
  3.         (ssget "_X"
  4.             (append
  5.                '((0 . "HATCH") (-4 . "<OR"))
  6.                 (mapcar '(lambda ( x ) (cons 92 x)) (LM:bitcombinations '(2 4 8 16)))
  7.                '((-4 . "OR>"))
  8.             )
  9.         )
  10.     )
  11.     (princ)
  12. )
  13.  
  14. ;; Bit Combinations  -  Lee Mac
  15. ;; Returns all combinations for a given set of bit-codes
  16.  
  17. (defun LM:bitcombinations ( l / foo bar )
  18.     (defun foo ( l r )
  19.         (if (and l (< 1 r))
  20.             (append (mapcar '(lambda ( x ) (+ (car l) x)) (foo (cdr l) (1- r))) (foo (cdr l) r))
  21.             l
  22.         )
  23.     )
  24.     (defun bar ( l r )
  25.         (if (< 0 r) (append (bar l (1- r)) (foo l r)))
  26.     )
  27.     (cons 0 (bar l (length l)))
  28. )

Rather than simply testing for the presence of more than one boundary loop, the above approach would also account for cases in which multiple solid regions have been hatched as a single hatch:



Contrary to the visual appearance, note that the left-hand green hatch in your sample drawing has a single continuous boundary:


dussla

  • Bull Frog
  • Posts: 297
Re: find holed hatched ~
« Reply #2 on: May 27, 2018, 02:03:27 PM »
lee Thank you so much
It's perfect.
You always have to solve difficult homework so easily.
You have outstanding ability.

I really feel numb when I come to the board here
I do not know why there are so many geniuses in the world.

Now this is 3 o'clock in the morning.
I think I can sleep well.

ps : I'm really sorry.
Is this style also possible?
« Last Edit: May 27, 2018, 02:19:02 PM by dussla »

dussla

  • Bull Frog
  • Posts: 297
Re: find holed hatched ~
« Reply #3 on: May 28, 2018, 04:35:30 AM »
i made this code
but that is error   what problem ?~~~
(defun c:ezxx (/ ss)
        (vl-load-com)
        (setq app (vlax-get-acad-object)
 doc (vlax-get-property app 'activedocument)
 layout (vlax-get-property doc 'Layouts)
 )
        (setvar "osmode" 0 )    
      (setq ss (ssget "_X" '((0 . "HATCH"))))
      (setq i 0 )
      (setq copydex 0 )
               (repeat  (sslength ss)
               
                     
                       (setq ent (ssname ss copydex))
                     (vla-GetBoundingBox (vlax-ename->vla-object ent) 'Ptmin 'Ptmax)
                        (vl-cmdf "._rectang" (vlax-safearray->list Ptmin) (vlax-safearray->list Ptmax))
                     (setq boundbox (entlast))
                             (setq  areaent  (vla-get-area  (vlax-ename->vla-object ent)))
                              (setq  boundarea  (vla-get-area  (vlax-ename->vla-object boundbox)))
                     
                   
                        (if   ( =   (* 0.7 boundarea) areaent )
                              
                              

                                   (ssdel ent ss)
                              
                        )
                        
                  
                        (setq  copydex (1+  copydex))
                  )

               
                               (sssetfirst nil ss)

                                                
                                                
)
« Last Edit: May 28, 2018, 05:09:26 AM by dussla »