kirbysturner Posted June 7, 2013 Posted June 7, 2013 (edited) I need some help solving a problem with a lisp routine. The routine work in earlier version of cad2009 but will not work in 2013. I am trying to replace text value with the area in sq. ft.after picking a polyline. I am onlygetting text replacement in sq. inches. [font=Times New Roman][size=3][/size][/font] [font=Calibri];;;CADDMAN: Area7.LSP Area Output (c) 2007 Kirby Turner [/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](defun c:area7 (/ a1)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](SETQ A1 (ENTSEL "Area of tract<pickobject>: "))[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](command "area" "e" a1)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](setq el (getvar "area"))[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](setq d1 144)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (setqfl (rtos (el 2 2))[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (setqe1 ( / f1 d1)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] ;;;(rtos(/ e1 144.0) 2 3)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri];;;(rtos (/ e1 144.0) 2 3)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (SETQED(ENTGET (CAR (NENTSEL "\nPick TEXT to change:"))))[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (setvar"CMDECHO" 0)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (COMMAND"TEXTEVAL" 1)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (SETQ ED(SUBST (cons 1 e1)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (ASSOC 1 ED)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] ED[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] )[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri])[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](ENTMOD ED)[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri])[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](alert[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] (strcat"area7.LSP"[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri] "\n\n Type area7 to start"))[/font] [font=Times New Roman][size=3][/size][/font] [font=Calibri](princ)[/font] [font=Times New Roman][size=3] [/size][/font] Edited June 10, 2013 by rkmcswain Added [CODE] tags Quote
Guest Posted June 7, 2013 Posted June 7, 2013 (edited) i have this ;GetArea.lsp - Total the areas of selected polyline entities. (defun C:GetArea() ;turn off the system echo (setvar "cmdecho" 0) ;set up a variable to hold the accumulated areas (setq myArea 0) ;while the user keeps making a selection (while(setq ent(entsel)) ;if an entity was selected and not a point in space (if(car ent) (progn ;let AutoCAD get the area of the object...cheap yet effective way out... ;Note: AutoCAD stores the area in the system variable "Area" (command "area" "Object" (car ent)) ;print the area to the command line (princ (strcat "\n Ε = " (rtos (getvar "Area") 2 2)" sq.m")) ;accumulate the area if it exist (if (getvar "Area")(setq myArea(+ myArea (getvar "Area")))) ) ) ) ;ask for a text insertion point (setq pt1(getpoint "\n pick a point: ")) ;print the area in the drawing (command "text" pt1 "" "" (strcat "E = "(rtos myArea 2 2)" sq.m")) ;suppress the last echo (princ) ) Edited June 10, 2013 by rkmcswain Added [CODE] tags Quote
irneb Posted June 10, 2013 Posted June 10, 2013 Have you tried looking at the units of the drawing? Also use the cvunits function instead of just multiplying / dividing manually. Else you could try various other routines available from many who have given their code on these forums (and others) - just do a search, I'm sure you should be able to get something. E.g. my DimArea command actually places an auto-updating field inside a text object which can be made up from adding and/or subtracting multiple polylines/hatches/etc. Quote
danellis Posted June 10, 2013 Posted June 10, 2013 Do you need to do this in LISP? By R2012 I'd suggest that fields is a better way to do this. dJE Quote
Dadgad Posted June 10, 2013 Posted June 10, 2013 Welcome to CADTutor. I am inclined to agree that this could be easily done with a field, and that the -dwgunits command may shed some light on the units in which the area is being reported. If you really want lisp, Lee Mac has at least 3 different ones dealing with AREA functions, of which this link will take you to one ...http://www.lee-mac.com/arealabel.html . Thanks Lee! 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.