Jump to content

Area by hectare


centa wenzel

Recommended Posts

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 by rkmcswain
Added [CODE] tags
Link to comment
Share on other sites

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 ""))
(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 )
)

 

  • Like 1
Link to comment
Share on other sites

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) )

 

 

 

  • Like 1
Link to comment
Share on other sites

when I apload lisp, show this massage:

error: malformed list on input

Edited by centa wenzel
Link to comment
Share on other sites

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)))

 

  • Like 1
  • Thanks 1
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...