TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: miquan on March 06, 2014, 11:07:12 AM

Title: Check number side of polygon
Post by: miquan on March 06, 2014, 11:07:12 AM
Dear,

I have many grid line, I just want to triangle or rectangular shape (number of sides of each cell is smaller than or equal to 4 sides).
Are there any lisp to check that?

Thanks,
Miiquan
Title: Re: Check number side of polygon
Post by: CAB on March 06, 2014, 11:26:08 AM
Not enough information for me.
I have never seen your drawing nor do I know what ACAD objects the grid lines are made of.
Perhaps you can explain it so your receptionist could understand the question & then I would too.  8)
Title: Re: Check number side of polygon
Post by: ronjonp on March 06, 2014, 12:35:28 PM
If these polygons are drawn with the command 'polygon' this would give you the number of sides.
Code: [Select]
(vlax-curve-getEndParam (car (entsel)))
Title: Re: Check number side of polygon
Post by: Lee Mac on March 06, 2014, 01:34:14 PM
Or
Code: [Select]
(if (setq s (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
    (cdr (assoc 90 (entget (ssname s 0))))
)
Title: Re: Check number side of polygon
Post by: Kerry on March 06, 2014, 05:06:08 PM

Lee, I think that will fail if the polyline has Plinegen on. The dxf 70 is bit-coded .. so it's value could be 1 or 129 depending on Plinegen setting.

Title: Re: Check number side of polygon
Post by: Lee Mac on March 06, 2014, 05:39:26 PM
Lee, I think that will fail if the polyline has Plinegen on. The dxf 70 is bit-coded .. so it's value could be 1 or 129 depending on Plinegen setting.

Hence the bitwise equals mask (-4 . &=)  :wink:
Title: Re: Check number side of polygon
Post by: Kerry on March 06, 2014, 06:39:22 PM
Lee, I think that will fail if the polyline has Plinegen on. The dxf 70 is bit-coded .. so it's value could be 1 or 129 depending on Plinegen setting.

Hence the bitwise equals mask (-4 . &=)  :wink:

missed that ; I should look more closely, shouldn't I.
Title: Re: Check number side of polygon
Post by: miquan on March 07, 2014, 12:32:42 AM
Dear CAB,

Sorry for not clear information.

I attached here with my grid lines, I broke them at their intersections.

I need a lisp to select all grids, after that check number of polygon cell.

If number of sides is larger than 4, these sides will be selected, and change layer (Ex: Grid_1).

Thanks,
Miquan
Title: Re: Check number side of polygon
Post by: Lee Mac on March 08, 2014, 09:49:58 AM
Hi Miquan,

You could use the programs shared in this thread (http://www.theswamp.org/index.php?topic=10371.0) to generate polylines for each grid cell, and then process the resulting polylines to check for those with more than 4 sides.

I hope this helps.