LISP Request - Acre to Text

LISP Request - Acre to Text

JohnC_ISM
Collaborator Collaborator
1,720 Views
8 Replies
Message 1 of 9

LISP Request - Acre to Text

JohnC_ISM
Collaborator
Collaborator

we use a lisp to get the acreage of a poly-line for when we measure lot sizes. if possible could someone add extra steps into the routine to take the acreage displayed and automatically create a text with +/- after it at 7.5% of the current scale and certain layer. for example the image 

 

 

(DEFUN C:AC ( / PLATE SS1 COUNT EMAX)
(WHILE
(NOT (SETQ PLATE
(ENTSEL "\Pick entity for area: "))))
(COMMAND "_.AREA" "_E" PLATE "")
(COMMAND "" "")
(SETQ AA (GETVAR "AREA"))
(PROMPT (STRCAT " AREA "
(RTOS (GETVAR "AREA" ) 2)
" S.F."))

(PROMPT (STRCAT " ACRES "
(RTOS (/ AA 43560) 2)
" AC."))
(PRINC)
)

0 Likes
Accepted solutions (1)
1,721 Views
8 Replies
  • Lisp
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

A Search of this Forum will find routines to label lot outlines with acres.  [Some require picking an object such as a Polyline, some only picking inside an area, some label with square feet and  acres, some with other features, most include setting a Layer and text Style, some place the label in the middle and some ask the User where to put it, etc.]  Any of them could be easily modified to set the height as you want it instead of whatever they originally use, and to add the plus-or-minus at the end.  If you find one that does what you want but just needs those modifications, post it and we can suggest adjustments.

Kent Cooper, AIA
0 Likes
Message 3 of 9

JohnC_ISM
Collaborator
Collaborator

i looked and found this but the command line box pops up and says invalid . its trying insert something and idk why. i just want it to make mtext out of the acreage data

 

(Defun C:AREAT ()
(setvar "CMDECHO" 0 )
(SETQ SS (entsel "Select Object To Get Area of:"))
(PROGN (COMMAND "AREA" "o" SS))
(SETQ SQF2 (/ (GETVAR "AREA") 1)) ;decimal
(setq ACRE2 (cvunit SQF2 "sq feet" "acres"))
(setq SQYD2 (cvunit SQF2 "sq feet" "sq yard"))
(setq SQMT2 (cvunit SQF2 "sq feet" "sq meter"))
(setq HECT2 (cvunit SQF2 "sq feet" "hectare"))
(princ
(strcat "\n Decimal Scale"
"\n"
"\n Square Feet = " (rtos SQF2 2 2)
"\n Acres = " (rtos ACRE2 2 3)
"\n"
)
) ;put up alert box
(PRINC)
(setq pt (getpoint "Specify Insertion Point"))
(command "insert" "darea" pt 1 1 0 "Area" (strcat (rtos SQF2 2 2) " SF") (strcat (rtos ACRE2 2 3) " AC"))
)

0 Likes
Message 4 of 9

hak_vz
Advisor
Advisor
(Defun C:AREAT ( / ss sqf2 acre2 sqyd2 hect2 pt)
(setq ss (entsel "\nSelect Object To Get Area of: "))
(if ss
	(progn 
	(command "AREA" "o" SS)
	(setq sqf2 (/ (getvar 'AREA) 1)) ;decimal
	(setq acre2 (cvunit sqf2 "sq feet" "acres"))
	(setq sqyd2 (cvunit sqf2 "sq feet" "sq yard"))
	(setq sqmt2 (cvunit sqf2 "sq feet" "sq meter"))
	(setq hect2 (cvunit sqf2 "sq feet" "hectare"))
	(princ
	(strcat "\n Decimal Scale"
	"\n"
	"\n Square Feet = " (rtos sqf2 2 2)
	"\n Acres = " (rtos acre2 2 3)
	"\n"
	)
	) 
	(PRINC)
	(setq pt (getpoint "Specify Insertion Point"))
	(entmake
		(list
		(cons 0 "MTEXT") 
		(cons 100 "AcDbEntity")
		(cons 100 "AcDbMText")
		(cons 1 (strcat "Area = " (rtos sqf2 2 2) " SF " (rtos acre2 2 3) " AC"))
		(cons 10 pt)   ; Insertion Point
		)
	   )
	(princ)
	)
)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 9

Kent1Cooper
Consultant
Consultant

@JohnC_ISM wrote:

.... its trying insert something and idk why. ....

....

(command "insert" "darea" pt 1 1 0 "Area" (strcat (rtos SQF2 2 2) " SF") (strcat (rtos ACRE2 2 3) " AC"))
)


Because that one does it by means of a Block with Attributes.  If @hak_vz 's suggestion in Message 4 doesn't do what you want, describe what you would like to be different.

Kent Cooper, AIA
0 Likes
Message 6 of 9

JohnC_ISM
Collaborator
Collaborator

okay that worked and i tweaked the output to come out as 0.005 Acres+/- how would i set it to come out as ROMANS font at 10% the dimscale ive got other lisp with (* 0.2 (getvar 'dimscale))) in it but im not sure where or how itd go in there

0 Likes
Message 7 of 9

hak_vz
Advisor
Advisor
Accepted solution
(Defun C:AREAT ( / ss sqf2 acre2 sqyd2 hect2 pt)
(setq ss (entsel "\nSelect Object To Get Area of: "))
(if ss
	(progn 
	(command "AREA" "o" SS)
	(setq sqf2 (/ (getvar 'AREA) 1)) ;decimal
	(setq acre2 (cvunit sqf2 "sq feet" "acres"))
	(setq sqyd2 (cvunit sqf2 "sq feet" "sq yard"))
	(setq sqmt2 (cvunit sqf2 "sq feet" "sq meter"))
	(setq hect2 (cvunit sqf2 "sq feet" "hectare"))
	(princ
	(strcat "\n Decimal Scale"
	"\n"
	"\n Square Feet = " (rtos sqf2 2 2)
	"\n Acres = " (rtos acre2 2 3)
	"\n"
	)
	) 
	(PRINC)
	(setq pt (getpoint "Specify Insertion Point"))
	(entmake
		(list
		(cons 0 "MTEXT") 
		(cons 100 "AcDbEntity")
		(cons 100 "AcDbMText")
		(cons 40 (* 0.1 (getvar 'dimscale)))
		(cons 7 "Romans")
		(cons 1 (strcat "Area = " (rtos sqf2 2 2) " SF " (rtos acre2 2 3) " AC"))
		(cons 10 pt)   ; Insertion Point
		)
	   )
	(princ)
	)
)
)

 

For MTEXT DXF codes consult this link.

 

To use ROMANS font create text style Romans with font Romans used. Apply for other fonts

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 8 of 9

ronjonp
Mentor
Mentor

@JohnC_ISM wrote:

okay that worked and i tweaked the output to come out as 0.005 Acres+/- how would i set it to come out as ROMANS font at 10% the dimscale ive got other lisp with (* 0.2 (getvar 'dimscale))) in it but im not sure where or how itd go in there


Here's are the entmake mods for your text:

(entmake (list '(0 . "MTEXT")
	       '(100 . "AcDbEntity")
	       '(100 . "AcDbMText")
	       (cons 1 (strcat "Area = " (rtos sqf2 2 2) " SF " (rtos acre2 2 3) " AC"))
	       '(8 . "MtextLayer")	; Layer
	       (cons 10 pt)		; Insertion Point
	       (cons 40 (* 0.1 (getvar 'dimscale))) ; Height 10% of dimscale
	       (cons 7
		     (if (tblobjname "style" "Romans")
		       "Romans"
		       "Standard"
		     )
	       )			; Style .. check that it exists
	 )
)

*oops too slow .. will leave as is for reference.

Message 9 of 9

Kent1Cooper
Consultant
Consultant

@hak_vz wrote:

....

To use ROMANS font create text style Romans with font Romans used. Apply for other fonts


@JohnC_ISM, you can use any  name for the Style, as long as the font you want is assigned to it [you may have one already defined].  Just be aware that it is the Style  name, not the Font  name, that goes into the code.

 

Also, as an aside, I wouldn't bother using Mtext for this.  The M stands for Multi-line -- if you're doing only one line, use plain Text.  Only if you want more than one line in one object, such as to show square feet and acres on separate lines, or if you need stacked fractions, or if you want to change some property of only part of the contents [such as some characters in a different color], is there any reason to use Mtext.  [And plain Text uses slightly less memory for single-line content.]

Kent Cooper, AIA