TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: carmi on April 07, 2020, 11:46:05 AM

Title: Draw polyline and get area value
Post by: carmi 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
Title: Re: Draw polyline and get area value
Post by: Lee Mac 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.
Title: Re: Draw polyline and get area value
Post by: carmi 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
Title: Re: Draw polyline and get area value
Post by: BIGAL 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
Title: Re: Draw polyline and get area value
Post by: carmi 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 ;)
Title: Re: Draw polyline and get area value
Post by: roy_043 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.
Title: Re: Draw polyline and get area value
Post by: carmi 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...
Title: Re: Draw polyline and get area value
Post by: carmi 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?
Title: Re: Draw polyline and get area value
Post by: ahsattarian 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)
)