PDA

View Full Version : Help modifying lisp for sqft



vladthedog
26th Oct 2009, 09:08 pm
We use the following code to figure square footage for our jobs individual pieces, as well as total it at the end. Currently it draws a polyline of the selected part (using a layer called "temp" with color 50.) I need for it to delete each temporary polyline as we select each area (meaning, we select area 1, we see a bright yellow line showing what we are getting the sqft of, and then when its time to select the 2nd area, the first yellow line dissapears and draws another). Does that make sense? Thanks.



;;;;;;;;;;;;;;;;;;;;;;;;;;;Total Square Footage for Job
;
(defun c:totalft()
(command "undo" "BE")
(setq dim (ssget "x" '((0 . "dimension"))))
(command "chprop" dim "" "la" "sqft" "")
(command "layer" "off" "sqft" "off" "cab lines" "off" "cabnets" "")

(setq area 0)
(command "layer" "m" "sqft" "c" "7" "sqft" "")
(if not
(command "layer" "m" "temp" "c" "50" "temp" ""))
(while
(setq pt (getpoint "Please pick inside the area:"))
(command "-boundary" "a" "i" "n" "+x" "" PT "")
(setq temp (entlast))
(command "area" "o" "l")
(setq areatop (getvar "area"))
(setq top (rtos (/ AREAtop 92903.04) 2 1))
(setq top (strcat top " sqft"))
(setq PT (getpoint "\n pick location for text"))
(command "text" "m" PT 0 top)
(command "chprop" "l" "" "la" "sqft" "")
(command "area" "o" temp
"pedit" temp "w" "5" "")

(setq area (+ area (getvar "area")))
)
(command "layer" "set" "0" "")
(setq FEET (rtos (/ AREA 92903.04) 2 1))
(setq FEET (strcat FEET " sqft"))
(princ "\n")
(setq TXTPT (getpoint "\n Select Location for sqft total"))
(command "text" txtPT 0 FEET)
(command "chprop" "l" "" "la" "sqft" "")
(command "erase" (ssget "x" ' ((8 . "temp"))) ""
"purge" "la" "temp" "n")
(command "layer" "on" "sqft" "on" "cab lines" "on" "cabnets" "")
(command "chprop" dim "" "la" "sqft" "")
(command "undo" "end")
(princ)
)

SteveK
26th Oct 2009, 10:31 pm
Hi, I've highlighted red what I've added that I think will delete your polyline. The blue highlight are other minor things I changed:

;;;;;;;;;;;;;;;;;;;;;;;;;;;Total Square Footage for Job
;
(defun c:totalft(/ AREA AREATOP DIM FEET PT TEMP TOP TXTPT)
(command "undo" "BE")
(setq dim (ssget "x" '((0 . "dimension"))))
(command "chprop" dim "" "la" "sqft" "")
(command "layer" "off" "sqft" "off" "cab lines" "off" "cabnets" "")

(setq area 0)
(command "layer" "m" "sqft" "c" "7" "sqft" "")
;(if not
(command "layer" "m" "temp" "c" "50" "temp" "");)
(while
(setq pt (getpoint "Please pick inside the area:"))
(command "-boundary" "a" "i" "n" "+x" "" PT "")
(setq temp (entlast))
(command "area" "o" "l")
(setq areatop (getvar "area"))
(setq top (rtos (/ AREAtop 92903.04) 2 1))
(setq top (strcat top " sqft"))
(setq PT (getpoint "\n pick location for text"))
(command "text" "m" PT 0 top)
(command "chprop" "l" "" "la" "sqft" "")
(command "area" "o" temp
"pedit" temp "w" "5" "")
(entdel temp)

(setq area (+ area (getvar "area")))
)
(command "layer" "set" "0" "")
(setq FEET (rtos (/ AREA 92903.04) 2 1))
(setq FEET (strcat FEET " sqft"))
(princ "\n")
(setq TXTPT (getpoint "\n Select Location for sqft total"))
(command "text" txtPT 0 FEET)
(command "chprop" "l" "" "la" "sqft" "")
(command "erase" (ssget "x" ' ((8 . "temp"))) ""
"purge" "la" "temp" "n")
(command "layer" "on" "sqft" "on" "cab lines" "on" "cabnets" "")
(command "chprop" dim "" "la" "sqft" "")
(command "undo" "end")
(princ)
)

vladthedog
27th Oct 2009, 04:19 pm
That works perfectly, thank you. I'm new to lisps, and i was trying to do (command "del" ______) and couldn't figure out what i was doing wrong. forgot about entdel.

alanjt
27th Oct 2009, 05:27 pm
That works perfectly, thank you. I'm new to lisps, and i was trying to do (command "del" ______) and couldn't figure out what i was doing wrong. forgot about entdel.

While I always encourage entdel or vla-delete, the command method is called with (command "_.erase".

SteveK
27th Oct 2009, 10:05 pm
While I always encourage entdel or vla-delete, the command method is called with (command "_.erase".
Alan, wouldn't you need to add the temp variable to a selection set to use the erase command? Which is more effort.

vladthedog - you're welcome. (perhaps you should put your real name in your profile?) :)

alanjt
27th Oct 2009, 10:16 pm
Alan, wouldn't you need to add the temp variable to a selection set to use the erase command? Which is more effort.

vladthedog - you're welcome. (perhaps you should put your real name in your profile?) :)

Long Answer: I didn't add a closing paren because I hadn't completed the call, I was just give enough info to get the ball rolling. It seemed like he knew what to do, he just had "del" instead of "erase".

Short Answer: Yes

My addition wasn't really needed, I just wanted to make sure he knew how to erase by command.

SteveK
27th Oct 2009, 10:42 pm
Long Answer: I didn't add a closing paren because I hadn't completed the call, I was just give enough info to get the ball rolling. It seemed like he knew what to do, he just had "del" instead of "erase".

Short Answer: Yes

My addition wasn't really needed, I just wanted to make sure he knew how to erase by command.
No worries, just making sure (I got a lot of holes in my lisp knowledge) :unsure:

alanjt
28th Oct 2009, 12:42 am
No worries, just making sure (I got a lot of holes in my lisp knowledge) :unsure:
Mine are just in my head.