Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Area Calculation problem

5 REPLIES 5
Reply
Message 1 of 6
dooners
191 Views, 5 Replies

Area Calculation problem

G'day all,

I have a LISP that calculates the area of a polyline to calculate the weight for a steel plate of this shape.
However im now trying to get it to subtract seperate areas like cutouts inside this polyline. This is where im getting stuck.

My original file went like this....
defun c:WT2(/ ent AR TH N V M Z ss)
(prompt "\nSelect object to be calculated: ")
(setq ss (ssget ":s"));general selection set
(setq ent (ssname ss 0))
;(setq ent (entlast))
(redraw ent 3)
(command "area" "o" ent)
(setq AR(getvar "area"))
(setq TH (getdist "ENTER THE THICKNESSS OF THE PLATE (mm) : ")) (terpri)
(setq N (getreal "HOW MANY OF THIS ITEM IN THE DRAWING ? (DEFAULT = 1) : ")) (terpri)
.... ( on to calculation part )

However i am unsure of how to get it to subtract areas of other items from this. I tried forming a regions and then subtracting these but i dont think im looking at this the right way...

(defun C:WTP (/ pt1 ss E ent AR TH N V M Z ss)
(setq pt1 (getpoint "\nSelect point inside boundary:"))
(command "-boundary" pt1 "")
(prompt "\nSelect Outside Boundary line: ")
(setq ss (ssget ":s"));general selection set
(prompt "\nSelect objects to be subtracted: ")
(setq E (ssget))
(command "subtract" ss E)
(setq ent (entlast))
(setq entn (ssname ent 0))
(command "area" "o" entn)
(setq AR(getvar "area"))
(setq TH (getdist "ENTER THE THICKNESSS OF THE PLATE (mm) : ")) (terpri)
....

Any comments ideas would be greatly appreciated. Also is there a way to get a general selection set to prompt the user with a different question rather than "select objects:"?

Using ACAD 07, prefer LISP as knowledge of VBA is nil.
Cheers, Dooners.
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: dooners

Here's one way....and no, you cannot change the (ssget) prompt via lisp. (But you can in .NET and ObjectARX)

(defun C:WTP (/ pt1 ss E ent AR TH N V M Z ss)
(setq pt1 (getpoint "\nSelect point inside boundary:"))
(command "-boundary" pt1 "")
(prompt "\nSelect Outside Boundary line: ")
(setq ss (ssget ":s" '((0 . "*POLYLINE")))) ;general selection set
(prompt "\nSelect objects to be subtracted: ")
(setq E (ssget '((0 . "*POLYLINE"))))
(setq entn (ssname ss 0))
(command "area" "o" entn)
(setq AR (getvar "area"))
(setq idx -1)
(while (< (setq idx (1+ idx)) (sslength E))
(setq ent (ssname E idx))
(command "area" "o" ent)
(setq AR (- AR (getvar "area")))
)
(setq TH (getdist "ENTER THE THICKNESSS OF THE PLATE (mm) : "))
;.....remainder of your calcs here
(princ)
)


wrote in message news:5802558@discussion.autodesk.com...
G'day all,

I have a LISP that calculates the area of a polyline to calculate the weight for a steel plate of this shape.
However im now trying to get it to subtract seperate areas like cutouts inside this polyline. This is where im getting
stuck.
Message 3 of 6
dooners
in reply to: dooners

Thanks for the quick response Jeff,

I just had to change the selction sets and it works a treat. Thanks for the help.

D
Message 4 of 6
Anonymous
in reply to: dooners

/*
....and no, you cannot change the (ssget) prompt via lisp. (But you can in
.NET and ObjectARX)
*/

Yes, but there is always a hack 🙂 .... like this old one [just make sure to
have an !error handler!]:


;; usage:
;; (setq ss (ssgetPrompt "Select any entity type" nil))
;; (setq ss (ssgetPrompt "Select some circles" '((0 . "CIRCLE"))))
(defun ssgetPrompt (msg filter / ss)
(prompt (strcat "\n" msg ": "))
(setvar "nomutt" 1)
(setq ss (ssget filter))
(setvar "nomutt" 0)
ss)
Message 5 of 6
dooners
in reply to: dooners

Cheers Luis, I like it!!!
Message 6 of 6
devitg
in reply to: dooners

How about it.
Of course it is not mine , I use any time I want to do a selection set

I comment it acording the idiom I use
;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
;;;Copyright ©2005 - Marc'Antonio Alessi, Italy - All rights reserved
; http://xoomer.virgilio.it/alessi
;

(defun ALE_EntSelFilter (PrmStr FltLst / FlgSlt EntNam)
(setvar "ERRNO" 0)
(princ "\n_ ")
(prompt (setq PrmStr (strcat "\n" PrmStr ": ")))
(if
(while (not FlgSlt)
(if (setq EntNam (ssget "_:E:S" FltLst))
(not (setq FlgSlt T))
(if (= 52 (getvar "ERRNO"))
(setq FlgSlt T)
(alert
(strcat "\nUd no entendió lo que le pedí, pruebe de nuevo!" PrmStr )

;;; (strcat "\nYou did not understood what I ask for , try it again!" PrmStr )
)
) ;_if
) ;_if
) ;_while
(not (princ "\nFunction cancelled. "))
(ssname EntNam 0)
) ;_if
) ;_defun
;;usage

;;(ALE_EntSelFilter "Seleccione la poly del terreno" '((0 . "POLYLINE") (100 . "AcDb3dPolyline")))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost