Author Topic: verify closed polyline  (Read 8924 times)

0 Members and 1 Guest are viewing this topic.

Fabricio28

  • Swamp Rat
  • Posts: 670
verify closed polyline
« on: October 21, 2013, 12:14:01 PM »
Hi guys,

I used the join command to close a polygon. But for me the polygon was closed, in fact didn't, and gave me the wrong area.
I discover it through the properties palette.

Is there any lisp that can find the polygon is not closed?

I have about 50 polygons in my drawing.

Thank in advance

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: verify closed polyline
« Reply #1 on: October 21, 2013, 12:26:19 PM »
This is to check if an object (LWpolyline) is closed or not .

Code: [Select]
(vla-get-closed < vla-object >)
And it should return either of two , :vlax-false / :vlax-true

ronjonp

  • Needs a day job
  • Posts: 7529
Re: verify closed polyline
« Reply #2 on: October 21, 2013, 12:29:40 PM »
You can also check if the start and end point are equal to a fuzz tolerance.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: verify closed polyline
« Reply #3 on: October 21, 2013, 01:13:56 PM »
You can also check if the start and end point are equal to a fuzz tolerance.

The start and end points can be exactly the same and that does not make it a closed polyline.

See also:
http://www.4d-technologies.com/techcenter/pl/pl_open.lsp
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Check-polyline-if-closed/m-p/861882#M87540
http://bit.ly/18D0Vve


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: verify closed polyline
« Reply #4 on: October 21, 2013, 02:20:36 PM »
Try this:
Code: [Select]
;;  get closed polyline
(setq ss (ssget  '((0 . "LWPOLYLINE,POLYLINE")(-4 . "&")(70 . 1))))
;;  gets not closed plines  by CAB,
(ssget "x"  '( (0 . "LWPOLYLINE") (-4 . "<not") (-4 . "&") (70 . 1) (-4 . "NOT>")) )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: verify closed polyline
« Reply #5 on: October 21, 2013, 03:29:42 PM »
Thank for the quick replay, guys,

Someone could explain to me, why is that polygon gave me the wrong area?

Regards

ronjonp

  • Needs a day job
  • Posts: 7529
Re: verify closed polyline
« Reply #6 on: October 21, 2013, 03:55:13 PM »
Thank for the quick replay, guys,

Someone could explain to me, why is that polygon gave me the wrong area?

Regards


How are you calculating the area? I get the same area for both (closed or not).

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: verify closed polyline
« Reply #7 on: October 21, 2013, 04:06:01 PM »
Hi ronjonp,
Yes, I'm calculating the area. But before that I have to join the polylines.
I don't understand why that polygon gave me the wrong area.

Thank you


ronjonp

  • Needs a day job
  • Posts: 7529
Re: verify closed polyline
« Reply #8 on: October 21, 2013, 04:11:08 PM »
Hi ronjonp,
Yes, I'm calculating the area. But before that I have to join the polylines.
I don't understand why that polygon gave me the wrong area.

Thank you


Are you using code to get the areas? If so, post what function you're using.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: verify closed polyline
« Reply #9 on: October 21, 2013, 04:15:23 PM »
Yes. I'm using Areas to Field from Lee Mac.
But even area command from the autocad is give me the wrong area.

Code: [Select]
Command: area

Specify first corner point or [Object/Add area/Subtract area] <Object>: o

Select objects:

Area = 40939.78, Length = 862.45

should be something wrong with the polygon.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: verify closed polyline
« Reply #10 on: October 21, 2013, 04:20:16 PM »
Must be something specific to your setup. I cannot reproduce the differing areas.  :?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: verify closed polyline
« Reply #11 on: October 21, 2013, 04:27:05 PM »
Did you see my attached file?
Is it giving the wrong area? (40939.78)

I don't know what happened, maybe you're right should be something about the setup.


ronjonp

  • Needs a day job
  • Posts: 7529
Re: verify closed polyline
« Reply #12 on: October 21, 2013, 04:28:49 PM »
Did you see my attached file?
Is it giving the wrong area? (40939.78)


Yes and no.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: verify closed polyline
« Reply #13 on: October 21, 2013, 05:08:00 PM »
Is the proper area listed in the properties box if you just high-lite the polyline ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: verify closed polyline
« Reply #14 on: October 21, 2013, 05:28:05 PM »
Both plines show the same area for me ACAD2006

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ymg

  • Guest
Re: verify closed polyline
« Reply #15 on: October 21, 2013, 11:02:33 PM »
Fabricio,

If you zoom the upper left of your polyline, the one on the right is actually self-crossing,
so I doubt that it is correct.

You can also see this if you Pedit then edit xertex and then follow the vertices.

Still the problem with the area remains.  It all has to do with the extra vertex that is created by
simply changing the property to closed.

If you actually remove that extra vertex your area is OK.

ymg
« Last Edit: October 21, 2013, 11:48:26 PM by ymg »

pBe

  • Bull Frog
  • Posts: 402
Re: verify closed polyline
« Reply #16 on: October 22, 2013, 03:55:48 AM »

Command: area
Specify first corner point or [Object/Add area/Subtract area] <Object>: o
Select objects:
Cannot calculate the area of a self intersecting curve.
Select objects:



Explode the object... run overkill...
17 object(s) deleted. <-------

as ymg noted above...
« Last Edit: October 22, 2013, 03:58:58 AM by pBe »

DanW

  • Mosquito
  • Posts: 18
Re: verify closed polyline
« Reply #17 on: October 22, 2013, 04:36:20 AM »
I think the area command taking exception to self intesecting curves was a known issue for AutoCAD 2009 and 2010, but fixed in 2011 onwards.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: verify closed polyline
« Reply #18 on: October 22, 2013, 07:54:25 AM »
 :-D
Thank you all of you guys for interested in my task.
I'm using autocad 2012

Fabricio,

If you zoom the upper left of your polyline, the one on the right is actually self-crossing,
so I doubt that it is correct.

You can also see this if you Pedit then edit xertex and then follow the vertices.

Still the problem with the area remains.  It all has to do with the extra vertex that is created by
simply changing the property to closed.

If you actually remove that extra vertex your area is OK.

ymg

Hi ymg,
My english is very poor and I haven't explained clearly my task.
The area of the polygon on the right is correct, even if I remove that extra vertex still the same area (5484.37).
But I don't know what is wrong with the polygon on the left, is the same polygon as on the right and give other area (40939.78).

pBe

  • Bull Frog
  • Posts: 402
Re: verify closed polyline
« Reply #19 on: October 22, 2013, 09:18:49 AM »
I think the area command taking exception to self intesecting curves was a known issue for AutoCAD 2009 and 2010, but fixed in 2011 onwards.

Nice to know ADESK looked into that issue and had it fix.

Thank you for the info  DanW

pBe

  • Bull Frog
  • Posts: 402
Re: verify closed polyline
« Reply #20 on: October 22, 2013, 09:29:50 AM »

Hi ymg,
My english is very poor and I haven't explained clearly my task.
The area of the polygon on the right is correct, even if I remove that extra vertex still the same area (5484.37).
But I don't know what is wrong with the polygon on the left, is the same polygon as on the right and give other area (40939.78).

Same as CAB and ronjonp, Besides the text entry with 40939.78 value, both pline entities give me the same area using list command, even with LM's A2F lisp

ymg

  • Guest
Re: verify closed polyline
« Reply #21 on: October 22, 2013, 10:43:41 PM »
Fabricio,

Quote
But I don't know what is wrong with the polygon on the left, is the same polygon as on the right and give other area (40939.78)

O que estou dizendo é que o polilines não são os mesmos.

Aquele com a área errada à esquerda tem mais vértices, incluindo um extra no final que desequilibra o cálculo.

O comando "Overkill"  é seu amigo para este

ymg

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: verify closed polyline
« Reply #22 on: October 23, 2013, 09:45:23 AM »
Hi ymg,

Portuguese is better. lol

I understood what you meant, but didn't work.
Maybe the problem should be in my autocad 2012.

I've already used overkill command too, and the area is same.