Author Topic: How to know area  (Read 5603 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to know area
« on: January 15, 2008, 03:59:51 AM »
Hi,
my friend ask to me to know area of object with have elevation, look at attach file.

Joe Burke

  • Guest
Re: How to know area
« Reply #1 on: January 15, 2008, 07:46:21 AM »
Hi Ade,

Given a 3D pline, the area command will only work when all the Z values of the vertex points are the same. So to get the "apparent" area of the 3D pline in your example you would flatten a copy and get the area of the copy. Then delete the copy.

If this does not have to be done within LISP I think the ExpressTools flatten command could be used.

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: How to know area
« Reply #2 on: January 15, 2008, 11:48:42 AM »
or you can retrieve the coordinates, strip off the z's, and calculate the area analytically

Guest

  • Guest
Re: How to know area
« Reply #3 on: January 15, 2008, 11:54:18 AM »
Can you use the BOUNDARY command on a 3D pline?  If so, you could do that using lsp, then retrieve the area of the newly created pline "boundary", then delete it afterwards.

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: How to know area
« Reply #4 on: January 15, 2008, 01:52:32 PM »
Code: [Select]
(defun Get3dVx (EntName)
  ((lambda (e)
     (if (= (cdr (assoc 0 e)) "VERTEX")
       (cons (cdr (assoc 10 e)) (Get3dVx (entnext EntName)))
     )
   )
    (entget (entnext EntName))
  )
)
(defun GetArea (CoordsList)
  (abs
    (/ (apply '+
      (mapcar (function
(lambda (p1 p2) (* (+ (car p1) (car p2)) (- (cadr p1) (cadr p2))))
      )
      CoordsList
      (cons (last CoordsList) CoordsList)
      )
       )
       2.0
    )
  )
)
;(GetArea (Get3dVx (car (entsel "Select 3D polyline:"))))

Fatty

  • Guest
Re: How to know area
« Reply #5 on: January 15, 2008, 03:13:38 PM »
Hi VovKa
How about to check IsPlanar property before?
Regards,
 :-)

~'J'~

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: How to know area
« Reply #6 on: January 15, 2008, 03:24:28 PM »
Hi VovKa
How about to check IsPlanar property before?
Regards,
 :-)

~'J'~

feel free to modify, Fatty ;)

Adesu

  • Guest
Re: How to know area
« Reply #7 on: January 15, 2008, 06:39:51 PM »
Woooow.........it's great,thanks.

Code: [Select]
(defun Get3dVx (EntName)
  ((lambda (e)
     (if (= (cdr (assoc 0 e)) "VERTEX")
       (cons (cdr (assoc 10 e)) (Get3dVx (entnext EntName)))
     )
   )
    (entget (entnext EntName))
  )
)
(defun GetArea (CoordsList)
  (abs
    (/ (apply '+
      (mapcar (function
(lambda (p1 p2) (* (+ (car p1) (car p2)) (- (cadr p1) (cadr p2))))
      )
      CoordsList
      (cons (last CoordsList) CoordsList)
      )
       )
       2.0
    )
  )
)
;(GetArea (Get3dVx (car (entsel "Select 3D polyline:"))))

Adesu

  • Guest
Re: How to know area
« Reply #8 on: January 16, 2008, 03:40:10 AM »
Hi VovKa,
Your code is solution for 2d area not 3D

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to know area
« Reply #9 on: January 16, 2008, 09:35:59 AM »
How would you define the 3D area?
If you were to put faces on the pline using vertex you would need interior points and they are not defined.
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to know area
« Reply #10 on: January 16, 2008, 09:43:15 AM »
Well maybe I spoke too soon. :?
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.

SomeCallMeDave

  • Guest
Re: How to know area
« Reply #11 on: January 16, 2008, 09:53:51 AM »
But that area (refer to by some as the surface area as opposed to the  planimetric , or projected, planar area) will differ depending on how the 3dfaces area created. 

Creating/connecting the 3dfaces gets back to some of the previous discussions on triangulation and TIN creation.

I'm thinking that 10 people asked to calc the 3D area would come up the 10 different answers.   It isn't too difficult to calculate A 3d area.  Calculating THE 3d area, IMO,  a different task all together

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: How to know area
« Reply #12 on: January 16, 2008, 01:20:36 PM »
Hi VovKa,
Your code is solution for 2d area not 3D

sorry to disappoint you, Adesu, and SomeCallMeDave is telling the thruth :)

Joe Burke

  • Guest
Re: How to know area
« Reply #13 on: January 17, 2008, 10:07:39 AM »
The term "area" is not arbitrary. Within ACAD or Webstrer's dictionary it always refers to a calculation based on a flat plane. So there's no such thing as the "area" of a 3D pline which has points at various Z values.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: How to know area
« Reply #14 on: January 18, 2008, 02:07:58 AM »
Hi! :)
Code: [Select]
(defun area_triangle_geron (d1 d2 d3 / d)
                           ;|
by ElpanovEvgeniy
18.10.2006

   Calculation area of a triangle under formula Geron
   
   Arguments:
   d1, d2, d3 - Lengths parties of a triangle
   
  (setq p1 (getpoint)
        p2 (getpoint)
        p3 (getpoint)
        d1 (distance p1 p2)
        d2 (distance p3 p2)
        d3 (distance p1 p3)
  ) ;_  setq

 
   Returne:
   (area_triangle_geron 3. 4. 5.) => 6.
  |;
 (setq d (* (+ d1 d2 d3) 0.5))
 (sqrt (abs (* d (- d d1) (- d d2) (- d d3))))
)