Jump to content

Anyone can impove this area computation lsp


nelsonfok

Recommended Posts

Hi friends

 

 

It's a very useful lsp for area computation but it does not work in my new CAD. Can anyone tell what's worng with this lsp?

 

 

 

(defun C:AUTOAREA (/ N SS1 NUM EN )

(if (not "acadapp.exp") (xload "acadapp.exp"))

(setq N 0)

(setq SS1 (ssadd))

(while (setq PT (getpoint "\nSelect internal point:"))

(C:BPOLY PT)

(setq SS1 (ssadd (entlast) SS1))

);while

(setq NUM (sslength SS1))

(command ".area" "a" "e")

; (command ".area" "e")

(while (/= NUM N)

(setq EN (ssname SS1 N))

(command EN)

(setq area (getvar "area"))

(setq areaac (/ area 4046.85))

(setq areasf (* area 10.7639))

(princ

(strcat (rtos area 2 2) "m" (chr 178 "\t" (rtos areaac 2 3) "ac." "\t" (rtos areasf 2 0) "ft" (chr 178)

); princ

(setq N (1+ N))

);while

(command "" "")

(command "erase" SS1 "")

(command "redraw")

(setq SS nil)

(command "textscr")

(prin1)

);end autoarea.lsp

Link to comment
Share on other sites

Get area direct from polyline

 

This line has multiple errors check chr 1st also if you get a smiley on end then something hidden is there.

(strcat (rtos area 2 2) "m" (chr 178 "\t" (rtos areaac 2 3) "ac." "\t" (rtos areasf 2 0) "ft" (chr 178)

);

 

(setq area (vlax-get-property (vlax-ename->vla-object en) 'Area))

Link to comment
Share on other sites

please use code Tag to prevent smiley 8)


(defun C:AUTOAREA (/ N SS1 NUM EN )
;;;(if (not "acadapp.exp") (xload "acadapp.exp"))
(setq N 0)
(setq SS1 (ssadd))
(while (setq PT (getpoint "\nSelect internal point:"))
(BPOLY PT)
(setq SS1 (ssadd (entlast) SS1))
);while
(setq NUM (sslength SS1))
;;;(command ".area" "a" "e") ;removed
; (command ".area" "e")
(while (/= NUM N)
(setq EN (ssname SS1 N))[color="red"]
(setq area (vlax-get-property (vlax-ename->vla-object EN ) 'Area)) ;as suggested by BIGAL[/color]
;;;(command EN) ;removed
;;;(setq area (getvar "area")) ;removed
(setq areaac (/ area 4046.85))
(setq areasf (* area 10.7639))
(princ
[color="red"](strcat "\n"(rtos area 2 2) "m" (chr 178) "\t" (rtos areaac 2 3) "ac." "\t" (rtos areasf 2 0) "ft" (chr 178))[/color]
); princ 
(setq N (1+ N)) 
);while
;;;(command "" "") ;removed
(command "erase" SS1 "")
(command "redraw")
(setq SS nil)
(command "textscr")
(prin1)
);end autoarea.lsp

 

your routine too old? try advanced

Area label

area to field

Edited by hanhphuc
link for OP reference
Link to comment
Share on other sites

Sorry friends. I'll remove the smile :) next time

In fact i use R14 but My company upgrade the CAD system recently. Many old lsps do not function well in the new CAD.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...