Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Quick area lisp

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
587 Views, 8 Replies

Quick area lisp

Hi Experts!
i need help with this lisp routine. my problem is i am trying to update this old routine to use the default text style and prompt the user for a text height and i have no clue as to how to do it. Your help is greatly appreciated!

tmaj

(princ "\n Quick Boundary Area")
(princ "\n BA - BOUNDARY ACRES BS - BOUNDARY SQUARE FEET ")
(princ)

(DEFUN C:ba ()
(SETQ PT1 (GETPOINT "\n Pick point inside: "))
(command "-boundary" PT1 "")
(setq ent (entlast))
(COMMAND "CHANGE" "L" "" "PROP" "COLOR" 1 "")
(REDRAW ENT)
(COMMAND "_.AREA" "o" ENT "")
(COMMAND "" "")
(SETQ AA (GETVAR "AREA"))
(PROMPT (STRCAT " AREA "
(RTOS (GETVAR "AREA" ) 2)
" S.F."))
(PROMPT (STRCAT " ACRES "
(RTOS (/ AA 43560) 2)
" AC."))
(PRINC)
(COMMAND "TEXT" PT1 "0" (strcat (RTOS (/ AA 43560) 2 ) " " "ACRES"))
(ENTDEL ENT)
)

(DEFUN C:bs ()
(SETQ PT1 (GETPOINT "\n Pick point inside: "))
(command "-boundary" PT1 "")
(setq ent (entlast))
(COMMAND "CHANGE" "L" "" "PROP" "COLOR" 1 "")
(REDRAW ENT)
(COMMAND "_.AREA" "o" ENT "")
(COMMAND "" "")
(SETQ AA (GETVAR "AREA"))
(PROMPT (STRCAT " AREA "
(RTOS (GETVAR "AREA" ) 2)
" S.F."))

(PROMPT (STRCAT " ACRES "
(RTOS (/ AA 43560) 2)
" AC."))
(PRINC)
(COMMAND "TEXT" PT1 "1" (strcat (RTOS (/ AA ) 2) " " "S.F."))
(ENTDEL ENT)
)
(princ)

j
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

I don't have time to go over all the details, but here's a nice head-start:

(COMMAND "TEXT" PT1 "1" (strcat (RTOS (/ AA ) 2) " " "S.F."))

The above line is way down near the end of your code. The COMMAND function
is calling the command prompt, basically, so everything after that is being
entered, just as if you were entering it at the command line.

Going through your exact steps and modifying the above line to suit will get
you where you want to be.

wrote in message news:6032663@discussion.autodesk.com...
Hi Experts!
i need help with this lisp routine. my problem is i am trying to update this
old routine to use the default text style and prompt the user for a text
height and i have no clue as to how to do it. Your help is greatly
appreciated!
Message 3 of 9
Anonymous
in reply to: Anonymous

forgive me here, i am not sure i know enough to make it work. it seems that the default style is good, but when it prompts for the text height no matter what i input it still is not working. if i set a text style with a value of anything other than 0 is works....sigh
Message 4 of 9
Anonymous
in reply to: Anonymous

Here, I'll further help out:
(RTOS (/ AA ) 2)
Message 5 of 9
Anonymous
in reply to: Anonymous

Hi tmaj9447,

You've answered your own question.

At the command line when you enter text
- if the text style has a height, you are not prompted to enter a height
- if the text style height is zero you get a prompt

Hence there are a different number of responses required depending on
the text height of the style.

As a user you probably hardly notice this and just respond accordingly.

But lisp, like all programming languages is PEDANTIC.

You need a different line of code depending on text height of the style.


Regards


Laurie Comerford

tmaj9447 wrote:
> forgive me here, i am not sure i know enough to make it work. it seems that the default style is good, but when it prompts for the text height no matter what i input it still is not working. if i set a text style with a value of anything other than 0 is works....sigh
Message 6 of 9
Anonymous
in reply to: Anonymous

Hi,
Replace with this routine... i changed almost all the style of your way.

Regards,
Manoj Kumar P.C
Chief draughtsman
Cowi Larsen JV.
Development of Seeb and Salalah international Airport



(princ "\n QUICK BOUNDARY AREA")
(princ "\n Command:QAR (Boundary Area in Acres or feet) ")
(princ)
(defun C:QAR (/ pt1 ent ans aa txt_ht txt_ht_usr msg)
(defun *error* (msg)
(if ent
(progn
(redraw ent 4)
(entdel ent)))
(princ "*exited*")
(princ)
)
(setq pt1 (getpoint "\nPick inside the boundary: "))
(if pt1
(progn
(vl-cmdf "._boundary" pt1 "")
(setq ent (entlast))
(redraw ent 3)
(vl-cmdf "_.area" "o" ent "")
(setq aa (getvar "area"))
(prompt (strcat " Area " (rtos (getvar "area" ) 2)" Sq.ft."))
(prompt (strcat " Acres " (rtos (/ aa 43560) 2)" Acr."))
(princ)
(initget "Acres Feet")
(setq ans (getkword "\nArea Unit in Acres/Feet :"))
(cond ((= ans "Acres")
(setq txt_ht (cdr (assoc 40 (tblsearch "Style" (getvar "textstyle")))))
(if (= txt_ht 0.0)
(progn
(initget 7)
(setq txt_ht_usr (getreal "\nText Height for lables: "))
(vl-cmdf "._text" pt1 txt_ht_usr "0" (strcat (rtos (/ aa 43560) 2 ) " " "acres"))
)

(vl-cmdf "._text" pt1 "0" (strcat (rtos (/ aa 43560) 2 ) " " "acres"))
))
((= ans "Feet")
(setq txt_ht (cdr (assoc 40 (tblsearch "Style" (getvar "textstyle")))))
(if (= txt_ht 0.0)
(progn
(initget 7)
(setq txt_ht_usr (getreal "\nText Height for lables: "))
(vl-cmdf "._text" pt1 txt_ht_usr "0" (strcat (rtos (/ aa ) 2) " " "Sq.ft."))
)

(vl-cmdf "._text" pt1 "0" (strcat (rtos (/ aa ) 2) " " "Sq.ft."))
))
)
(redraw ent 4)
(entdel ent)
(princ)
)
(princ)
)
)
;programme modified by pcku@cowi.dk
;according to the civil3d community request
;done by manojkumar
;date 9/17/08 9:17 AM
;thanks and enjoy civil3d 2009
Message 7 of 9
Anonymous
in reply to: Anonymous

why not use PARCELs and label styles?

--
Thanks, Joe

Joseph D. Bouza, P.E.
Civil 3D 2008
LDT 2008
Win XP pro
v 2002, sp 2
hp workstation xw4600
Intel Core Duo CPU
E7200 @2.53 GHz
3 GB RAM
NIVDIA Quadro FX 1700 (512MB)

The mantra of a former Flamer:

If you are forced to eat an Elephant, don't complain about it; Take one bite
at a time.

*****************************************************************************************
In memory of the King of Work-arounds
"The only Constant is Change".

"The only thing worse than training your staff, and having them leave is -
not training your staff, and having them stay." 😮
A reminder taken from Graphics Solution Providers' Calendar page
*****************************************************************************************
wrote in message news:6032663@discussion.autodesk.com...
Hi Experts!
i need help with this lisp routine. my problem is i am trying to update this
old routine to use the default text style and prompt the user for a text
height and i have no clue as to how to do it. Your help is greatly
appreciated!

tmaj

(princ "\n Quick Boundary Area")
(princ "\n BA - BOUNDARY ACRES BS - BOUNDARY SQUARE FEET ")
(princ)

(DEFUN C:ba ()
(SETQ PT1 (GETPOINT "\n Pick point inside: "))
(command "-boundary" PT1 "")
(setq ent (entlast))
(COMMAND "CHANGE" "L" "" "PROP" "COLOR" 1 "")
(REDRAW ENT)
(COMMAND "_.AREA" "o" ENT "")
(COMMAND "" "")
(SETQ AA (GETVAR "AREA"))
(PROMPT (STRCAT " AREA "
(RTOS (GETVAR "AREA" ) 2)
" S.F."))
(PROMPT (STRCAT " ACRES "
(RTOS (/ AA 43560) 2)
" AC."))
(PRINC)
(COMMAND "TEXT" PT1 "0" (strcat (RTOS (/ AA 43560) 2 ) " " "ACRES"))
(ENTDEL ENT)
)

(DEFUN C:bs ()
(SETQ PT1 (GETPOINT "\n Pick point inside: "))
(command "-boundary" PT1 "")
(setq ent (entlast))
(COMMAND "CHANGE" "L" "" "PROP" "COLOR" 1 "")
(REDRAW ENT)
(COMMAND "_.AREA" "o" ENT "")
(COMMAND "" "")
(SETQ AA (GETVAR "AREA"))
(PROMPT (STRCAT " AREA "
(RTOS (GETVAR "AREA" ) 2)
" S.F."))

(PROMPT (STRCAT " ACRES "
(RTOS (/ AA 43560) 2)
" AC."))
(PRINC)
(COMMAND "TEXT" PT1 "1" (strcat (RTOS (/ AA ) 2) " " "S.F."))
(ENTDEL ENT)
)
(princ)

j
Message 8 of 9
Anonymous
in reply to: Anonymous

Hi All, sorry for the delay.

Thank you all so much for your input and help. I totally agree, using parcels is better! But you know it is a painful implementation in the area of teaching old dogs new tricks!
Until then, thank you for help in the work around's!

Tmaj
Message 9 of 9
Anonymous
in reply to: Anonymous

I hear ya.

--
Thanks, Joe

Joseph D. Bouza, P.E.
Civil 3D 2008
LDT 2008
Win XP pro
v 2002, sp 2
hp workstation xw4600
Intel Core Duo CPU
E7200 @2.53 GHz
3 GB RAM
NIVDIA Quadro FX 1700 (512MB)

The mantra of a former Flamer:

If you are forced to eat an Elephant, don't complain about it; Take one bite
at a time.

*****************************************************************************************
In memory of the King of Work-arounds
"The only Constant is Change".

"The only thing worse than training your staff, and having them leave is -
not training your staff, and having them stay." 😮
A reminder taken from Graphics Solution Providers' Calendar page
*****************************************************************************************
wrote in message news:6033666@discussion.autodesk.com...
Hi All, sorry for the delay.

Thank you all so much for your input and help. I totally agree, using
parcels is better! But you know it is a painful implementation in the area
of teaching old dogs new tricks!
Until then, thank you for help in the work around's!

Tmaj

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report