Author Topic: Calculating Area  (Read 1992 times)

0 Members and 1 Guest are viewing this topic.

Big G

  • Bull Frog
  • Posts: 415
Calculating Area
« on: January 14, 2005, 05:19:08 AM »
Hi Guys,
I have been searching for a lisp file to calculate an area based on a user click, almost like a bhatch where you click the internal point and it returns the area.?

As it is I cant find it and am thinking about trying to write it myself, can anyone give me a pointer on where to start (Not written lisp before, but willing to have a bash)

Cheers,
Big G
I thought i seen the light at the end of the tunnel. But it was just someone with a torch bringing me more work.
"You have to accept that somedays youre the pigeon and  somedays youre the statue"

SMadsen

  • Guest
Calculating Area
« Reply #1 on: January 14, 2005, 07:52:14 AM »
It could be as simple as using the BOUNDARY command. For example, a quick an dirty one to build on:

Code: [Select]
(defun getArea (/ area ent lastent pt)
  (setq ent (entlast))
  (setq pt (getpoint "\nSpecify internal point: "))
  (vl-cmdf "-BOUNDARY" pt "")
  (cond ((not (eq (setq lastent (entlast)) ent))
         ;; assuming last ent is a pline, you could
         ;; retrieve the area by a variety of methods
         ;; .. this is just a purely command driven one
         (and (vl-cmdf "AREA" "Object" lastent)
              (setq area (getvar "AREA"))
         )
         (entdel lastent)
        )
        ((princ "\nNo enclosing boundary found")(princ))
  )
  area
)