TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Adesu 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.
-
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.
-
or you can retrieve the coordinates, strip off the z's, and calculate the area analytically
-
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.
-
(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:"))))
-
Hi VovKa
How about to check IsPlanar property before?
Regards,
:-)
~'J'~
-
Hi VovKa
How about to check IsPlanar property before?
Regards,
:-)
~'J'~
feel free to modify, Fatty ;)
-
Woooow.........it's great,thanks.
(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:"))))
-
Hi VovKa,
Your code is solution for 2d area not 3D
-
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.
-
Well maybe I spoke too soon. :?
-
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
-
Hi VovKa,
Your code is solution for 2d area not 3D
sorry to disappoint you, Adesu, and SomeCallMeDave is telling the thruth :)
-
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.
-
Hi! :)
(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))))
)
-
Happy New Year Evgeniy.
So this would calculate area for the surfaces just like my picture?
Assuming a 3D point was used.
-
Geron's formula works excellent on 3d triangles.
the only problem left is the way we define these triangles.
see my attached drawing.
3d_area_of_ABC + 3d_area_of_CDA = 10488.1
3d_area_of_ABD + 3d_area_of_DBC = 10481.1
-
Here we are back to the ten ways to calculate the area. :-o