suriwaits Posted April 30, 2013 Posted April 30, 2013 (edited) Hi, I am in need of a lisp to do the following Find the individual area of poly line in layer 1 & Layer 2 Multiply the area in layer 1 by a factor 3.1 and Place text within polyline Multiply the area in layer 2 by factor 4.1 and Place text within polyline Sum of text as alert message Please help me on this.. Thanks in Advance Suriwaits Edited April 30, 2013 by suriwaits Quote
pBe Posted April 30, 2013 Posted April 30, 2013 (edited) (defun c:areafrom (/ data TotalArea ss i en area lay) (setq data '(("LAYER1" 3.1) ("LAYER2" 4.1)));;<-- change this to.... [of course you know that] [b][color="blue"](and (null unit) ;<-- will only ask you once (not (initget "M MM")) (setq unit (cadr (assoc (getkword "\nChoos units to use [M/MM]: ") '(("M" 1.0)("MM" 0.000001)))))) (setq TextHt (cond ((getreal (strcat "\nEnter Text Height" (if TextHt (strcat " <" (rtos TextHt) ">: ") ": ") )))(TextHt)) )[/color][/b] (if (and (setq TotalArea nil ss (ssget '((0 . "LWPOLYLINE") (8 . "LAYER1,LAYER2"))) ) ) (progn (repeat (setq i (sslength ss)) (setq en (ssname ss (setq i (1- i))) area [b][color="blue"](* (vlax-curve-getarea en) unit)[/color][/b] Lay (Strcase (cdr (assoc 8 (entget en)))) ) (vla-getboundingbox (vlax-ename->vla-object en) 'mn 'mx) (setq pt (mapcar '(lambda (x y) (* 0.5 (+ x y))) (vlax-safearray->list mn) (vlax-safearray->list mx))) (entmakex (list (cons 0 "TEXT") (cons 10 pt)(cons 8 lay) (cons 11 pt) [b][color="blue"](cons 40 TextHt) '(72 . 1) '(73 . 2) [/color][/b] (cons 1 (rtos (setq area (* (cadr (assoc lay data)) area)) 2 2)) ) ) (setq TotalArea (cons area TotalArea)) ) (alert (Strcat "Total area: " (rtos (apply '+ TotalArea) 2 2))) ) ) (princ) ) Code updated Edited April 30, 2013 by pBe Quote
suriwaits Posted April 30, 2013 Author Posted April 30, 2013 Exactly what i am looking for. I appreciate you can help me to control the size of text Quote
pBe Posted April 30, 2013 Posted April 30, 2013 We can add a prompt for Text Height. Which one did you use? Demo or Demo2? Quote
suriwaits Posted April 30, 2013 Author Posted April 30, 2013 I used Demo2. Is it possible to write the area value divided by 1000000 incase i use in mm units. Quote
pBe Posted April 30, 2013 Posted April 30, 2013 I used Demo2.Is it possible to write the area value divided by 1000000 incase i use in mm units. See update code at post # 2 HTH Quote
suriwaits Posted April 30, 2013 Author Posted April 30, 2013 Awesome! Thanks agian pBe for your efforts I have changed factor for mm 0.000001 insted of 0.001 since it is area. Quote
pBe Posted April 30, 2013 Posted April 30, 2013 ...Thanks agian pBe for your effortsI have changed factor for mm 0.000001 insted of 0.001 since it is area. Oh yeah.. silly me.. Glad i could help 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.