TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Fabricio28 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
-
This is to check if an object (LWpolyline) is closed or not .
(vla-get-closed < vla-object >)
And it should return either of two , :vlax-false / :vlax-true
-
You can also check if the start and end point are equal to a fuzz tolerance.
-
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
-
Try this:
;; 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>")) )
-
Thank for the quick replay, guys,
Someone could explain to me, why is that polygon gave me the wrong area?
Regards
-
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).
-
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
-
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.
-
Yes. I'm using Areas to Field from Lee Mac.
But even area command from the autocad is give me the wrong area.
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.
-
Must be something specific to your setup. I cannot reproduce the differing areas. :?
-
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.
-
Did you see my attached file?
Is it giving the wrong area? (40939.78)
Yes and no.
-
Is the proper area listed in the properties box if you just high-lite the polyline ?
-
Both plines show the same area for me ACAD2006
-
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
-
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...
-
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.
-
:-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).
-
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
-
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
-
Fabricio,
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
-
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.