to select object with hatch size

to select object with hatch size

anycganycgJ8A6A
Advocate Advocate
2,200 Views
26 Replies
Message 1 of 27

to select object with hatch size

anycganycgJ8A6A
Advocate
Advocate

Good morning
I need some help, so I posted it.

For example
There are hatches.

1. x size = 300 or y size = 300
     I would like to select only hatches and move them to a new layer

2. If the x size is less than 300 and the y size is less than 300
I would like to select only the hatches and move them to a new layer


I'd like to ask you for some code that's available.

0 Likes
Accepted solutions (1)
2,201 Views
26 Replies
Replies (26)
Message 2 of 27

dlanorh
Advisor
Advisor
Can you explain x size and y size in more detail, or provide a publish to web jpg that does.

I am not one of the robots you're looking for

0 Likes
Message 3 of 27

anycganycgJ8A6A
Advocate
Advocate

Yes I uploaded an image
Maybe the shape of the hatch varies.
The problem is that the hatch's bounding box is used to get the x y size and select it

0 Likes
Message 4 of 27

ВeekeeCZ
Consultant
Consultant

Maybe selection by area would be good enough?

 

(defun c:HatchbyArea2Layer (/ ss areap prec ent i lay clay)
 
  (if (and (princ "\nSelect Hatch,")
           (setq ss (ssget "_:L" '((0 . "HATCH"))))
           (setq areap (getreal "\nFilter by area: "))
           (setq prec 0.01)
           )
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (if (or (not (setq area (getpropertyvalue ent "Area")))
              (not (equal area areap prec))
              )
        (ssdel ent ss))))
  (if (and ss
           (> (sslength ss) 0)
           (setq lay (lisped (setq clay (getvar 'clayer)))))
    (progn
      (command "_.-LAYER" "_T" lay "_M" lay ""
               "_.CHPROP" ss "" "_La" (getvar 'clayer) "")
      (print (sslength ss)) (princ (strcat " hatches moved to layer '" (getvar 'clayer) "'"))
      (setvar 'CLAYER clay)))
  (princ)
)
0 Likes
Message 5 of 27

anycganycgJ8A6A
Advocate
Advocate

I really appreciate you for making it.
But it's not a selection on the area.
It's a choice of x and y sizes for hatch.
Is this possible?
Sorry for annoying you.

0 Likes
Message 6 of 27

ВeekeeCZ
Consultant
Consultant

@anycganycgJ8A6A wrote:

I really appreciate you for making it.
But it's not a selection on the area.
It's a choice of x and y sizes for hatch.
Is this possible?
Sorry for annoying you.


Anything is possible, but something might be more complicated then others.

You need to provide move info the just a picture. Now we can just guess how it's done - does it is drawn nicely with just 4 vertices, or not. Is always X horizontal, Y vertical in WCS?

So provide as much information as you can, post as much dwg samples as you can and we'll see.

0 Likes
Message 7 of 27

anycganycgJ8A6A
Advocate
Advocate

Yes the work is done completely in wcs
If you look at the attached CAD file,
There is an object with the same y value
This is just an example.
If there are hundreds of complex objects in this way
I would like to send this to a new layer by separating the objects with the same x value
I also want to separate objects with the same y value

Pick a reference object
And if I give you the option to choose the same x value
It is an automatic sending method

0 Likes
Message 8 of 27

dlanorh
Advisor
Advisor
Most of the objects are irregular and have 2 'x' values and 2 'y' values unless you are talking about maximum 'x' and maximum 'y' as in a bounding box.

I am not one of the robots you're looking for

0 Likes
Message 9 of 27

anycganycgJ8A6A
Advocate
Advocate

Yes it is irregular
But when you look closely, some objects have the same x size
that will be use the bounding box to select only objects of the same x size
I would like to  select hatch  like  that

Another option is to select an object of the same y size

0 Likes
Message 10 of 27

dlanorh
Advisor
Advisor

I've attached a modified drawing showing the "bounding Box" (nodes) of the hatch items. Is this the x and y you need?

I am not one of the robots you're looking for

0 Likes
Message 11 of 27

anycganycgJ8A6A
Advocate
Advocate
##- yes~~ bounding is right
With that , have to check x or y size
And same x size objects -》 other layer ~~
-##
0 Likes
Message 12 of 27

ВeekeeCZ
Consultant
Consultant

Quick mod... A distance can be typed or selected.

 

(vl-load-com)

(defun c:HatchbyXY2Layer (/ ss areap prec ent i lay clay)
 
  (if (and (princ "\nSelect Hatch,")
           (setq ss (ssget "_:L" '((0 . "HATCH"))))
           (or (setq fltx (getdist "\nFilter by X <no filter>: ")
                     flty (getdist "\nFilter by Y <no filter>: "))
               fltx)
           (setq prec 0.01)
           )
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (vla-GetBoundingBox (vlax-ename->vla-object ent) 'Ptmin 'Ptmax)
      (setq box (cons (vlax-safearray->list PtMin)
                      (vlax-safearray->list PtMax)))
      (if (not (and (or (not fltx)
                        (equal (abs (- (cadr box) (caar box))) fltx prec))
                    (or (not flty)
                        (equal (abs (- (caddr box) (cadar box))) flty prec))
                    ))
        (ssdel ent ss))))
  (if (and ss
           (> (sslength ss) 0)
           (setq lay (lisped (setq clay (getvar 'clayer)))))
    (progn
      (command "_.-LAYER" "_T" lay "_M" lay ""
               "_.CHPROP" ss "" "_La" (getvar 'clayer) "")
      (print (sslength ss)) (princ (strcat " hatches moved to layer '" (getvar 'clayer) "'"))
      (setvar 'CLAYER clay)))
  (princ)
)
0 Likes
Message 13 of 27

anycganycgJ8A6A
Advocate
Advocate

I really appreciate it so much.
Can I ask you two more?
I'm really sorry to have to ask you.

first. When you select a reference object
     Selecting x as an option will find the hatch with the same x value in the entire hatch
     It's automatically sent to "xsize-same-1".


Second, if there are three or more objects with the same x size in the entire hatch
     It automatically classifies the layers as xsize-x value layers, respectively.
    Is this possible?


I'm really sorry to have to ask you.

0 Likes
Message 14 of 27

ВeekeeCZ
Consultant
Consultant

Sorry, don't understand you. Would you describe your issues in following structure?

 

1) Now when I set X filter... it does...

I need to do....

 

2) Now it does...

I need to do...

 

What you mean by saying "entire hatch?" You meant all hatches? Or single hatch? There are no "parts" of hatch.

0 Likes
Message 15 of 27

anycganycgJ8A6A
Advocate
Advocate
##- yes entire hatch = all hatch
Sorry my poor english skill -##
0 Likes
Message 16 of 27

dlanorh
Advisor
Advisor

Please see attached dwg with questions.

I am not one of the robots you're looking for

0 Likes
Message 17 of 27

anycganycgJ8A6A
Advocate
Advocate
##- now is outside for work
Can you see attach file above
Now is mobile -##
0 Likes
Message 18 of 27

dlanorh
Advisor
Advisor
OK. Still working here. Reply when your back at work.

I am not one of the robots you're looking for

0 Likes
Message 19 of 27

anycganycgJ8A6A
Advocate
Advocate

Sorry
Now I've come back from work outside.

I saw your htachbd2.dwg file

That's right
It would be complicated to calculate both x and y
So first we calculate x
I will send it to the new layer and turn it off.

I think it is better to calculate the y value with the rest
You do not have to compute both x and y sizes
You only need to consider one condition.

  , Just before the hatch was full
I'm sorry about these conditions, but I would like to add

1. I would appreciate it if you exclude the layer whose layers are off in the screen.
2. You do not need to calculate both x and y
   If I want to compute x, I just need to compute x.
   If you want to calculate only y values, you only need to compute y.

3. On the screen, there are fourth sizes x size = 317
   If there are three or more objects of the same size, you can send them to the new layer
  But the rest do not have more than three same x sizes, so you do not need to send them to another layer

I'm sorry. I demand a lot.

0 Likes
Message 20 of 27

ВeekeeCZ
Consultant
Consultant

This is best I can do. HTH

 

(defun c:HatchbyXY2Layer (/ ss areap ent i lay clay fltx funx flty funy)
 
  (if (and (setq ss (ssget "_X" '((0 . "HATCH"))))
           (or (progn
                 (and (setq fltx (getdist "\nFilter by X <no filter>: "))
                      (not (initget "< > = Less More Equal"))
                      (setq funx (getkword "\nSelect typ of comparison [< Less/> More/= Equal]: "))
                      (setq funx (cond ((wcmatch funx "<,Less") <)
                                       ((wcmatch funx ">,More") >)
                                       ((wcmatch funx "=,Equal") =))))
                 (and (setq flty (getdist "\nFilter by Y <no filter>: "))
                      (not (initget "< > = Less More Equal"))
                      (setq funy (getkword "\nSelect typ of comparison [< Less/> More/= Equal]: "))
                      (setq funy (cond ((wcmatch funy "<,Less") <)
                                       ((wcmatch funy ">,More") >)
                                       ((wcmatch funy "=,Equal") =)))))
               funx)
           )
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (vla-GetBoundingBox (vlax-ename->vla-object ent) 'Ptmin 'Ptmax)
      (setq box (cons (vlax-safearray->list PtMin)
                      (vlax-safearray->list PtMax)))
      (if (not (and (or (not fltx)
                        (funx (abs (- (cadr box) (caar box))) fltx))
                    (or (not flty)
                        (funy (abs (- (caddr box) (cadar box))) flty))
                    ))
        (ssdel ent ss))))
  (if (and ss
           (> (sslength ss) 0)
           (setq lay (lisped (setq clay (getvar 'clayer)))))
    (progn
      (command "_.-LAYER" "_T" lay "_M" lay ""
               "_.CHPROP" ss "" "_La" (getvar 'clayer) "")
      (print (sslength ss)) (princ (strcat " hatches moved to layer '" (getvar 'clayer) "'"))
      (sssetfirst nil ss)
      (setvar 'CLAYER clay)))
  (princ)
)
0 Likes