Author Topic: calculating the area of polylines nested polyline  (Read 1787 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1423
calculating the area of polylines nested polyline
« on: September 10, 2023, 04:51:34 AM »
I have a question regarding calculating the area of polylines.
I am writing a LISP routine to calculate the area of a polyline. I have successfully implemented it; however, in some cases, there are nested polylines within the main polyline.
My question is, is there a possibility to obtain the area of each individual polyline (No. 1, 2, & 3) within the main polyline?

Thanks in advance.

ribarm

  • Gator
  • Posts: 3313
  • Marko Ribar, architect
Re: calculating the area of polylines nested polyline
« Reply #1 on: September 10, 2023, 06:41:58 AM »
Of course it's possible...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

HasanCAD

  • Swamp Rat
  • Posts: 1423
Re: calculating the area of polylines nested polyline
« Reply #2 on: September 10, 2023, 07:11:24 AM »
Of course it's possible...

Thats very good.
But, How is this?
« Last Edit: September 10, 2023, 07:20:08 AM by HasanCAD »

hmspe

  • Bull Frog
  • Posts: 367
Re: calculating the area of polylines nested polyline
« Reply #3 on: September 10, 2023, 09:12:04 AM »
I would do this:

- get the vertices of the outer polyline
- use ssget with "_WP" and '((0 . "LWPOLYLINE")) to get the interior polylines
- apply your area function to each polyline
"Science is the belief in the ignorance of experts." - Richard Feynman

BIGAL

  • Swamp Rat
  • Posts: 1445
  • 40 + years of using Autocad
Re: calculating the area of polylines nested polyline
« Reply #4 on: September 10, 2023, 08:19:14 PM »
Like this for WP
Code: [Select]
(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
(princ co-ord)
A man who never made a mistake never made anything

HasanCAD

  • Swamp Rat
  • Posts: 1423
Re: calculating the area of polylines nested polyline
« Reply #5 on: September 11, 2023, 04:26:33 AM »
I would do this:

- get the vertices of the outer polyline
- use ssget with "_WP" and '((0 . "LWPOLYLINE")) to get the interior polylines
- apply your area function to each polyline
Thanks hmspe
Working perfect

HasanCAD

  • Swamp Rat
  • Posts: 1423
Re: calculating the area of polylines nested polyline
« Reply #6 on: September 11, 2023, 04:27:21 AM »
Like this for WP
Code: [Select]
(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
(princ co-ord)

Thanks BIGAL for the start point.