PLEASE CHANGE THIS LISP TO AREA IN SQUARE FEET INSTEAD OF SQUARE INCH

PLEASE CHANGE THIS LISP TO AREA IN SQUARE FEET INSTEAD OF SQUARE INCH

aiwa1waheed
Explorer Explorer
667 Views
5 Replies
Message 1 of 6

PLEASE CHANGE THIS LISP TO AREA IN SQUARE FEET INSTEAD OF SQUARE INCH

aiwa1waheed
Explorer
Explorer

PLEASE CHANGE THIS LISP TO AREA IN SQUARE FEET INSTEAD OF SQUARE INCH

please email me when solved

aiwa1waheed@gmail.com

Warm Regards

 

0 Likes
Accepted solutions (1)
668 Views
5 Replies
Replies (5)
Message 2 of 6

_gile
Consultant
Consultant

Hi,

You should post in the LISP forum.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 6

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

you should ask the vendor of this file (shown in the top lines inside the file)

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 4 of 6

ec-cad
Collaborator
Collaborator

I agree with you on contacting the author.

But if OP insists on editing that Lisp, they could retrofit in this little function somewhere.

 

ECCAD

 

;; Function to change sq inches to sq feet and sq inches
(defun sqin2ftin ( sqin ); input total Square Inches
 (if sqin
  (progn
   (setq ft (/ sqin 144.0))
   (setq fullft (fix ft)); full sq ft
   (setq in (fix (- sqin (* fullft 144.0))))
   (setq feet fullft inches in)
  ); progn
 ); if
); function

;; Testing:

 (setq sqinch 700.324)
 (setq feet nil inches nil)
 (sqin2ftin sqinch)
 (if feet
  (princ (strcat "\nSquare Feet = " (rtos feet)))
 ); if
 (if inches
  (princ (strcat "\nSquare Inches = " (rtos inches)))
 ); if
 (princ)

 

0 Likes
Message 5 of 6

LDShaw
Collaborator
Collaborator
Accepted solution

I've used this lisp in the past. One of Mr Mac many great routines. I believe he set this up to be changed on the fly. 

Not tested but line 
34 needs to be 

 

 fo "%lu2%pr2%ps[, SQ. FT.]%ct8[0.0069444444444444]" ;; Area field formatting

The pr2 is the how many decimals. I think you can go up to 16

 adesk.png

0 Likes
Message 6 of 6

aiwa1waheed
Explorer
Explorer

Thanks Sir Got it////////////////////////////////////// its Work have another need to result in Square feet and Sides on liner Feet 

 

; rlx 10-mrt-2019 - https://www.cadtutor.net/forum/topic/66987-auto-area-calculation-table/
(defun c:t1 ( / doc spc text-height polly polly-points polly-center polly-area)
(setq doc (vla-get-activedocument (vlax-get-acad-object)) spc (vla-get-block (vla-get-activelayout doc)))
(setq text-height 5) ; adjust to fit your situation
(if (and (setq polly (car (entsel))) (wcmatch (cdr (assoc 0 (entget polly))) "*POLYLINE"))
(progn
(setq polly-points (Get_Polly_Points polly) polly-center (Get_Polly_Center spc polly))
(Put_Polly_Sizes (Get_Polly_Sizes polly-points) polly-center spc text-height)
(Put_Polly_Area spc (Get_Polly_Area polly) (vlax-3d-point polly-center) text-height)
)
)
(vla-Regen doc acActiveViewport)
)

;;; Gile
(defun Get_Polly_Points (pl / pa pt lst)(vl-load-com)
(setq pa (if (vlax-curve-IsClosed pl)(vlax-curve-getEndParam pl)(+ (vlax-curve-getEndParam pl) 1)))
(while (setq pt (vlax-curve-getPointAtParam pl (setq pa (- pa 1))))(setq lst (cons pt lst))))

; s = space , e = polly (ent or obj)
(defun Get_Polly_Center ( s e / o r c )
(or (= (type e) 'VLA-OBJECT) (setq o (vlax-ename->vla-object e)))
(setq r (vlax-invoke s 'addRegion (list o)) c (vlax-get (car r) 'Centroid))
(vla-delete (car r))(trans c 1 (vlax-get o 'Normal)))

; l is point list , return list with angle , midpoint & length for each vertice
(defun Get_Polly_Sizes (l)
(mapcar '(lambda (a b) (list (angle a b) (mapcar '(lambda (x y) (/ (+ x y) 2)) a b)(distance a b)))
l (append (cdr l) (list (car l)))))

; l = vertice list ((ang midp length)...) c = center of gravity , s = space , th = text height
(defun Put_Polly_Sizes (l c s th / x o p)
(foreach x l
(setq p (vlax-3d-point (polar (cadr x) (angle (cadr x) c) th)) o (vla-addtext s (rtos (last x) 2 2) p th))
(mapcar
'(lambda (p v)(vl-catch-all-apply 'vlax-put-property (list o p v)))
(list 'alignment 'textalignmentpoint 'alignment 'rotation 'color)
(list acAlignmentRight p acAlignmentMiddle (car x) acMagenta)
)
)
)

(defun Get_Polly_Area (e) (rtos (vla-get-area (vlax-ename->vla-object e)) 2 5))

; used for single polyline (c:t1) : s = string (area) , cpt = center point of gravity , th = text height
(defun Put_Polly_Area (spc s cpt th / to)
(setq to (vla-addtext spc s cpt th))
(mapcar
'(lambda (p v)(vl-catch-all-apply 'vlax-put-property (list to p v)))
(list 'alignment 'textalignmentpoint 'alignment 'rotation 'color) (list acAlignmentRight cpt acAlignmentMiddle 0 acRed)
)
)

; used for multiple polylines (c:t2) : s = string (area) , cpt = centerpoint of gravity , th = text height , i = index
(defun Put_Polly_Area2 (spc s cpt th i / mto)
(setq mto (vla-AddMText spc cpt (* 5 th) (strcat (itoa i) "\n" s)))
(setq ip (vla-get-insertionpoint mto)) (vla-put-AttachmentPoint mto 5) (vla-put-insertionpoint mto ip)
(vl-catch-all-apply 'vlax-put-property (list mto 'color acRed))
)

; for multiple pollys
(defun c:t2 ( / doc spc i text-height ss to p)
(setq doc (vla-get-activedocument (vlax-get-acad-object)) spc (vla-get-block (vla-get-activelayout doc))
i 0 text-height 5)(setvar 'textsize text-height)
(prompt "\nSelect polylines :")
(if (and (setq ss (ssget ":L" '((0 . "LWPOLYLINE")))) (setq ss (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
(foreach polly ss
(setq polly-points (Get_Polly_Points polly) polly-center (Get_Polly_Center spc polly))
(Put_Polly_Sizes (Get_Polly_Sizes polly-points) polly-center spc text-height)
(Put_Polly_Area2 spc (Get_Polly_Area polly) (vlax-3d-point polly-center) text-height (setq i (1+ i)))
)
)
(vla-Regen doc acActiveViewport)
(princ)
)

0 Likes