Extract polyline properties ignoring nested polylines

Extract polyline properties ignoring nested polylines

NSL26
Contributor Contributor
664 Views
11 Replies
Message 1 of 12

Extract polyline properties ignoring nested polylines

NSL26
Contributor
Contributor

Hello.

 

I have a LISP code to extract closed polyligne properties on Autocad MAP 3D.

It works well.

But I have some closed polylines that have polylines nested in them.

So when I want to extract the area value for example, I have the total area contained in the big exterior polyline.

But what I want to have is the area contained in the the big exterior polyline MINUS the area contained in the small polyline inside the big one. 

Because I want to have precisely the area of a room, that is to say the area minus the pillars.

To be the as general as possible, I would prefer to have the area of each room minus the area of every closed geometrical figure that is inside, whether it is a closed polyline or a circle for example.

 

Do you know what I have to change in the LISP code in order to do that ?

 

Thank you.

 

0 Likes
665 Views
11 Replies
Replies (11)
Message 2 of 12

ВeekeeCZ
Consultant
Consultant

You should either translate your code to English or post it to the French forum right away.

 

Either way you should post some sample dwg.

0 Likes
Message 3 of 12

Kent1Cooper
Consultant
Consultant

I haven't studied the routine, but from your description, I think doing a Hatch pattern in pick-in-an-area mode with island detection [and with any Layers of other stuff inside turned off] would get you something from which you can read the area you're looking for, directly.

Kent Cooper, AIA
0 Likes
Message 4 of 12

_Tharwat
Advisor
Advisor

As long as you have the outer polyline object, then make a selection set of the coordinates of the polyline then iterate through the selected inner closed polylines then minus their areas from the outer one.

(setq ss (ssget "_WP" <list_of _outer_polyline_coordinates> '((0 . "LWPOLYLINE"))))

 

0 Likes
Message 5 of 12

Kent1Cooper
Consultant
Consultant

@_Tharwat wrote:

.... make a selection set of the coordinates of the polyline ....


... as long as you're aware that if there are any arc segments in the Polyline, a window-polygon selection using its vertex locations can omit things it should find, and/or find things it should omit.

Kent Cooper, AIA
0 Likes
Message 6 of 12

_Tharwat
Advisor
Advisor

That was an initial suggestion then if arcs are involved then they can create a list of coordinates along the polyline then create a selection as I suggest earlier. 

 

0 Likes
Message 7 of 12

Kent1Cooper
Consultant
Consultant

@_Tharwat wrote:

....

... (ssget ... '((0 . "LWPOLYLINE"))))

[Message 1 says the inside things to be subtracted can also include Circles.]

Kent Cooper, AIA
0 Likes
Message 8 of 12

_Tharwat
Advisor
Advisor

Your comments should be more professional than this, if you don't know how to add a circle to the selection then just let me know unless you are kidding.

0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant

I am pointing things out for the OP's information, lest they try something and it doesn't do what they want.  I don't intend to fix anything myself.  There are many topics in this Forum about finding things inside a Polyline, including consideration of the arc-segment complication, available for the searching.

Kent Cooper, AIA
0 Likes
Message 10 of 12

Sea-Haven
Mentor
Mentor

Agree with you using hatch, pick point, get area, undo, would be reasonable speed. The hatch pick point could be like 0.00001 inside the pline, using "GC" geometric centre and polar should work ok for calculating the internal point from a vertice, even a pline with arcs.

0 Likes
Message 11 of 12

NSL26
Contributor
Contributor

Thank you very much for your answers.

@Sea-Haven I'm quite new with LISP, but by using what you said, how can the code automatically find all the polylines who have interior polylines before applying hatches to them ?

0 Likes
Message 12 of 12

Sea-Haven
Mentor
Mentor
(defun c:wow ( / oldsnap ent pt cpt obj area)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 512)
(setq ent (entsel "\nPick exterior pline "))
(setq pt (cadr ent))
(setvar 'osmode 0)
(setq obj (vlax-ename->vla-object (car ent )))
(setq cpt (osnap (vlax-curve-getStartPoint obj) "gcen"))
(setq pt (polar pt (angle pt cpt) 1.0))
(command "-hatch" pt "")
(setq obj (vlax-ename->vla-object (entlast)))
(setq area (vla-get-area obj))
(vla-delete obj)
(alert (strcat "Area is " (rtos area 2 2)))
(setvar 'osmode oldsnap)
(princ)
)

Try this may need to change the offset value line 9.

0 Likes