centa wenzel Posted April 8, 2020 Posted April 8, 2020 (edited) Hi This Lisp represents the area based on the square meter.How to modify this Lisp to display the area in hectares?Each hectare is equal to 10,000 square meters: ======================== (defun c:aa (/ c a b) (command "style" "romans" "romans" 8 0.85 "" "" "" "" ) (setq os(getvar "osmode")) (setvar "osmode" 0) (SETQ p0 (GETPOINT "\n PICK A CLOSED AREA:")) (command "BPOLY" p0 "") (COMMAND "AREA" "E" "L" ) (COMMAND "ERASE" "L" "") (COMMAND "REDRAW" ) (SETQ A (GETVAR "area")) (SETQ B (GETPOINT "\n PICK A POINT TO WRITE AREA:")) (SETQ C (RTOS a)) (COMMAND "COLOR" 3 ) (SETQ Text (strcat "Area=" C)) (COMMAND "TEXT" B "0" (strcat text "m²")) (COMMAND "COLOR" "BYLAYER" ) (command "style" "italict" "" 0 0.85 "" "" "" "" ) (setvar "osmode" os) (setq w nil ) ) Edited April 9, 2020 by rkmcswain Added [CODE] tags Quote
dlanorh Posted April 8, 2020 Posted April 8, 2020 3 hours ago, centa wenzel said: Hi This Lisp represents the area based on the square meter.How to modify this Lisp to display the area in hectares?Each hectare is equal to 10,000 square meters: ======================== (defun c:aa (/ c a b) (command "style" "romans" "romans" 8 0.85 "" "" "" "" ) (setq os(getvar "osmode")) (setvar "osmode" 0) (SETQ p0 (GETPOINT "\n PICK A CLOSED AREA:")) (command "BPOLY" p0 "") (COMMAND "AREA" "E" "L" ) (COMMAND "ERASE" "L" "") (COMMAND "REDRAW" ) (SETQ A (GETVAR "area")) (SETQ B (GETPOINT "\n PICK A POINT TO WRITE AREA:")) (SETQ C (RTOS a)) (COMMAND "COLOR" 3 ) (SETQ Text (strcat "Area=" C)) (COMMAND "TEXT" B "0" (strcat text "m²")) (COMMAND "COLOR" "BYLAYER" ) (command "style" "italict" "" 0 0.85 "" "" "" "" ) (setvar "osmode" os) (setq w nil ) ) 1 hectare is 10000 sq m therefore divide your area by this figure to get the result you require (see below) (defun c:aa (/ c a b) (command "style" "romans" "romans" 8 0.85 "" "" "" "" ) (setq os(getvar "osmode")) (setvar "osmode" 0) (SETQ p0 (GETPOINT "\n PICK A CLOSED AREA:")) (command "BPOLY" p0 "") (COMMAND "AREA" "E" "L" ) (COMMAND "ERASE" "L" "") (COMMAND "REDRAW" ) (SETQ A (GETVAR "area")) (SETQ B (GETPOINT "\n PICK A POINT TO WRITE AREA:")) (SETQ C (RTOS (/ a 10000)) (COMMAND "COLOR" 3 ) (SETQ Text (strcat "Area=" C)) (COMMAND "TEXT" B "0" (strcat text "ha")) (COMMAND "COLOR" "BYLAYER" ) (command "style" "italict" "" 0 0.85 "" "" "" "" ) (setvar "osmode" os) (setq w nil ) ) 1 Quote
hanhphuc Posted April 9, 2020 Posted April 9, 2020 20 hours ago, centa wenzel said: Hi This Lisp represents the area based on the square meter.How to modify this Lisp to display the area in hectares?Each hectare is equal to 10,000 square meters: ======================== (defun c:aa (/ c a b);; ) artos function? click here (artos 1.234 ) ;--> 1.2 m² (artos -1234.56 ) ;--> -0.123 ha (artos 12345.678 ) ;--> 1.23 ha (artos (getvar 'area)) ;--> 0.00 m² example in your code Quote (COMMAND "TEXT" B "0" (strcat text "ha")) change to: Quote (COMMAND "TEXT" B "0" (artos A) ) 1 Quote
centa wenzel Posted April 11, 2020 Author Posted April 11, 2020 (edited) when I apload lisp, show this massage: error: malformed list on input Edited April 11, 2020 by centa wenzel Quote
Jonathan Handojo Posted April 11, 2020 Posted April 11, 2020 dlanorh missed one closing bracket: On 4/9/2020 at 12:55 AM, dlanorh said: (SETQ C (RTOS (/ a 10000)) should be: (SETQ C (RTOS (/ a 10000))) 1 1 Quote
Recommended Posts
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.