Author Topic: Draw polyline and get area value  (Read 2467 times)

0 Members and 1 Guest are viewing this topic.

carmi

  • Newt
  • Posts: 27
Draw polyline and get area value
« on: April 07, 2020, 11:46:05 AM »
Hi all,
I only found lisp code that return the area value of an existing boundary if you click an internal point.

I am looking for a lisp that allows, first to draw the boundary with a polyline and then return the area value of this boundary and, after get area value, automatically delete boundary.

Anyone help me?
Thank you

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Draw polyline and get area value
« Reply #1 on: April 07, 2020, 02:32:32 PM »
Have you tried using the standard AREA command? The process you have described is exactly how this command operates.

carmi

  • Newt
  • Posts: 27
Re: Draw polyline and get area value
« Reply #2 on: April 07, 2020, 02:42:07 PM »
Have you tried using the standard AREA command? The process you have described is exactly how this command operates.
Yes, I know but I not have Autocad but another cad with another area command. I search a lisp similar to area command of Autocad.
Thank you

BIGAL

  • Swamp Rat
  • Posts: 1407
  • 40 + years of using Autocad
Re: Draw polyline and get area value
« Reply #3 on: April 08, 2020, 01:48:45 AM »
My $0.05 draw pline

(setq area (vla-get-area (vlax-ename->vla-object  (entlast))))

erase pline
A man who never made a mistake never made anything

carmi

  • Newt
  • Posts: 27
Re: Draw polyline and get area value
« Reply #4 on: April 08, 2020, 04:27:58 AM »
Hi, this is my code:

Code: [Select]
(defun c:ap (/ area e1 text)
     
      (command "PLINE" )
  (setq area (vla-get-area (vlax-ename->vla-object  (entlast))))
  (setq e1 (entlast))
  (command "-ERASE" e1 "")
      (princ "\nArea: ")
  (princ (rtos area))
  (vl-load-com) (princ)

    )

Thanks ;)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Draw polyline and get area value
« Reply #5 on: April 08, 2020, 05:57:23 AM »
@carmi: Which DwgCAD program do you use?
Your code does not work in BricsCAD, and probably also doesn't work in AutoCAD.

carmi

  • Newt
  • Posts: 27
Re: Draw polyline and get area value
« Reply #6 on: April 08, 2020, 06:01:14 AM »
@carmi: Which DwgCAD program do you use?
Your code does not work in BricsCAD, and probably also doesn't work in AutoCAD.
I don't know, in Nanocad work perfectly...

carmi

  • Newt
  • Posts: 27
Re: Draw polyline and get area value
« Reply #7 on: April 08, 2020, 10:26:47 AM »
Do you think is it simple to make a "dynamic" semi-trasparent hatch similar to Area command in Autocad?

ahsattarian

  • Newt
  • Posts: 112
Re: Draw polyline and get area value
« Reply #8 on: November 20, 2020, 01:56:44 PM »
This Helps U   :





(defun c:a ()
  (setq s nil)
  (setq pli nil)
  (setvar "osmode" 0)
  (initget (+ 1 16))
  (while (setq po (getpoint "\n Point :  "))
    (setq pli (append pli (list po)))
    (setq nn (length pli))
    (cond
      ((> nn 2)
       (cond (s (entdel s)))
       (setvar "cmdecho" 0)
       (command "pline")
       (mapcar 'command pli) ;| #apply |;
       (command "close")
       (setq s (entlast))
       (command "area" "object" s)
       (princ (getvar "area"))
      )
    )
  )
  (princ)
)