Jump to content

Recommended Posts

GP_
Posted (edited)

Frequently, after a topographic survey, I have to prove the obtained area of a Lot of Land.
This lisp creates a table with the analytical method of the Gauss's area formula.
I do not need absolute precision, but logically (owing to rounding) by increasing decimal units you can get a result as close to the real one.


It is still to be completed, but I never have time to finish it.


You can change the nonsense I wrote in English 🙂

632a.gif

AreaG.LSP

Edited by GP_
  • Like 2

Share this post


Link to post
Share on other sites
GP_
Customization 🙂
 

632b.gif

  • Like 3

Share this post


Link to post
Share on other sites
Lee Mac

Wow! Astounding DCL work GP, very well done.

Share this post


Link to post
Share on other sites
Jonathan Handojo

Agree with Lee Mac. That DCL is amazing. Though capable, I've never written one this big. 

Share this post


Link to post
Share on other sites
GP_

@Lee   

@Jonathan

 

Thanks 😊

Share this post


Link to post
Share on other sites
marko_ribar

I've run into this problem while inspired with this topic...

To explain... According to math and lisp that implemented math, area of closed 2d spline should be equal to (vla-get-area) or (vlax-curve-getarea) or data from Properties panel... But routine gives approx. correct, but little less... I know that there is curving involved, but 100000 points is very dense, so there should be no bigger difference and by my testings - difference is seen at very first decimals - how can this be true? Can someone explain or elaborate or retest my research...

 

(defun c:areaclosed2dspline ( / s spl n dx k pl ar )

  (vl-load-com)

  (while
    (or
      (prompt "\nPick closed 2d spline in WCS...")
      (not (setq s (ssget "_+.:E:S" '((0 . "SPLINE")))))
      (if s
        (or
          (not (vlax-curve-isclosed (ssname s 0)))
          (not (vl-every '(lambda ( x ) (equal (cadddr x) 0.0 1e-6)) (vl-remove-if-not '(lambda ( x ) (vl-position (car x) '(10 11))) (entget (ssname s 0)))))
        )
      )
    )
    (prompt "\nMissed or picked spline not closed or picked spline not in WCS...")
  )
  (setq spl (ssname s 0))
  (initget 6)
  (setq n (getreal "\nSpecify precision segmentation <100000> : "))
  (if (null n)
    (setq n 100000)
    (setq n (fix n))
  )
  (setq dx (/ (vlax-curve-getdistatparam spl (vlax-curve-getendparam spl)) n))
  (setq k -1)
  (repeat n
    (setq pl (cons (vlax-curve-getpointatdist spl (* dx (setq k (1+ k)))) pl))
  )
  (setq pl (reverse pl))
  (setq ar (abs (apply '+ (mapcar '(lambda ( a b ) (/ (- (* (car a) (cadr b)) (* (cadr a) (car b))) 2.0)) pl (append (cdr pl) (list (car pl)))))))
  (prompt "\nArea of closed 2d spline : ") (princ (rtos ar 2 20))
  (princ)
)

 

Share this post


Link to post
Share on other sites
marko_ribar

Discard my post...

I retested with another 2d spline and now routine returned little bigger result and difference was at 4th decimal, so it's accurate...

Thanks for reading anyway...

Share this post


Link to post
Share on other sites
BIGAL

As you say there is the little bit of the arc segment area left out,  unless there is a way of working out the approx radius between points on the spline  the area will say always be a bit less. Spline like a "U" shape would be different again with + & - areas

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...