Guest Posted June 7, 2013 Posted June 7, 2013 (edited) T = [((sqrtA) + 1)^ 2) - A] * [ L/( 4*(sqrtA)] A= Area of a polyline L= Perimetr of a polyline T= tolerance I try to print the area and the perimetr but i have (syntax error) with the print of T and the (10% * Area) The (10% * Area) is safety factor that why is important because if (10% * Area) > T the the tolerance is the T and if (10% * Area) ------------------------------------------------------------- (defun c:ktim ( / a l i s ) (if (setq s (ssget '( (0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (-4 . "<NOT") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . 80) (-4 . "AND>") (-4 . "NOT>") ) ) ) (progn (setq a 0.0) (repeat (setq i (sslength s)) (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i)))))) ) (progn (setq l 0.0) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) ) ) (princ "\nTotal Length: ") (princ (rtos l 2 2)) ) (princ "\nTotal Area: ") (princ (rtos a 2 2)) ) (princ "\n Tolerance: ") (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1) ) a) l) (* (sqrt a) 4) 2 2)) ) (princ "\n 10 % Area : ") (princ (rtos (* a 0.1) 2 2)) ) ) (princ) ) (vl-load-com) (princ) Edited June 10, 2013 by SLW210 Add Code Tags!! Quote
ReMark Posted June 7, 2013 Posted June 7, 2013 Syntax errors in lisp programs are often a result of incorrect placement or number of parentheses. Have you checked your code for such a likelihood? Quote
marko_ribar Posted June 7, 2013 Posted June 7, 2013 (edited) (defun c:ktim ( / a l i s e ) (if (setq s (ssget '( (0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (-4 . "<NOT") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . [highlight]8[/highlight]) (-4 . "AND>") (-4 . "NOT>") ) ) ) (progn (setq a 0.0) (repeat (setq i (sslength s)) (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i)))))) ) (setq l 0.0) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) ) ) ) ) (princ "\nTotal Length: ") (princ (rtos l 2 2)) (princ "\nTotal Area: ") (princ (rtos a 2 2)) (princ "\nTolerance: ") (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1) ) a) l) (* (sqrt a) 4)[highlight])[/highlight] 2 2)) (princ "\n10 % Area : ") (princ (rtos (* a 0.1) 2 2)) (princ) ) (vl-load-com) (princ) You missed ) - see highlighted... And also you had extra ) after (princ...) You also had invalid DXF 70 for 3dpolyline - it should be (70 . Edited June 7, 2013 by marko_ribar You also had invalid DXF 70 for 3dpolyline - it should be (70 . 8) Quote
BlackBox Posted June 7, 2013 Posted June 7, 2013 I *think* this is what you're after: (defun c:ktim (/ a l i s) (if (setq s (ssget '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (-4 . "<NOT") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . 80) (-4 . "AND>") (-4 . "NOT>") ) ) ) (progn (setq a 0.0) (repeat (setq i (sslength s)) (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i)))))) ) ;;; (progn (setq l 0.0) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) ) ) ) (princ "\nTotal Length: ") (princ (rtos l 2 2)) ;;; ) (princ "\nTotal Area: ") (princ (rtos a 2 2)) ;;; ) (princ "\n Tolerance: ") (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1)) a) l) (* (sqrt a) 4) 2 2 ) ) ) (princ "\n 10 % Area : ") (princ (rtos (* a 0.1) 2 2)) ) ) (princ) ) (vl-load-com) (princ) *not sure* Quote
BlackBox Posted June 7, 2013 Posted June 7, 2013 You missed ) - see highlighted... And also you had extra ) after (princ...) ... Kind of hard to evaluate all of those PRINC calls, if the PROGN call never happens (due to s = Nil). Quote
lyky Posted June 7, 2013 Posted June 7, 2013 (edited) Has revised, here you go: (defun c:ktim ( / A E I L S) (vl-load-com) (setq s (ssget '( (0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE") (-4 . "<NOT") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . 80) (-4 . "AND>") (-4 . "NOT>") ) ) ) (if (/= s nil) (progn (setq l 0.0 a 0.0 i 0) (while (< i (sslength s)) (progn (setq e (ssname s i) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) a (+ a (vlax-curve-getarea e)))) (setq i (1+ i))) (princ "\nTotal Length: ") (princ (rtos l 2)) (princ "\nTotal Area: ") (princ (rtos a 2)) (princ "\n Tolerance: ") (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1) ) a) l) (* (sqrt a) 4) 2 2))) (princ "\n 10 % Area : ") (princ (rtos (* a 0.1) 2 2)) )) (princ)) Edited June 8, 2013 by lyky Quote
Guest Posted June 7, 2013 Posted June 7, 2013 (edited) i neeed something more if it is posible if the scale 1: 1000 we have this T = [((sqrtA) + 1)^ 2) - A] * [ L/( 4*(sqrtA)] if the scale 1: 5000 we have this T = [((sqrtA) + 4)^ 2) - A] * [ L/( 4*(sqrtA)] and for the two cases we have if (10% * Area) > T the the tolerance is the T and if (10% * Area) Edited June 7, 2013 by prodromosm Quote
Guest Posted June 7, 2013 Posted June 7, 2013 nice job but the calculation is wrong, any ideas ???????????? Quote
BlackBox Posted June 7, 2013 Posted June 7, 2013 (edited) Really stabbing in the dark here (not sure I understand fully what you're trying to do), but building on my earlier code revision, give this a try: (defun c:ktim (/ cannoscale tval a l i s) (if (and (setq tval (cond ((= "1\" = 10000'" (setq cannoscale (getvar 'cannoscale)) ) 2 ) ((= "1\" = 50000'" cannoscale) 4 ) ) ) (setq s (ssget '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (-4 . "<NOT") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . 80) (-4 . "AND>") (-4 . "NOT>") ) ) ) ) (progn (setq a 0.0) (repeat (setq i (sslength s)) (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i)))))) ) ;;; (progn (setq l 0.0) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) ) ) ) (princ "\nTotal Length: ") (princ (rtos l 2 2)) ;;; ) (princ "\nTotal Area: ") (princ (rtos a 2 2)) ;;; ) ;;if the scale 1: 1000 we have this T = [((sqrtA) + 1)^ 2) - A] * [ L/( 4*(sqrtA)] ;;if the scale 1: 5000 we have this T = [((sqrtA) + 1)^ 4) - A] * [ L/( 4*(sqrtA)] (princ "\n Tolerance: ") (princ (rtos (* (- (* (+ 1 (sqrt a)) tval) a) (/ l (* (sqrt a) 4))) 2 2 ) ;;; (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1)) a) l) ;;; (* (sqrt a) 4) ;;; 2 ;;; 2 ;;; ) ;;; ) ) (princ "\n 10 % Area : ") (princ (rtos (* a 0.1) 2 2)) ) (cond (tval (prompt "\n** invalid selection ** ")) ((prompt "\n** Scale must be \"1:1000\" or \"1:5000\" ** ")) ) ) (princ) ) ** Note - This code assumes that your drawing's annotation scale is equal to the desired scale of either 1:1000, or 1:5000. Edited June 7, 2013 by BlackBox Quote
marko_ribar Posted June 7, 2013 Posted June 7, 2013 OP changed formulas at 05:14 pm... But I think that now can finish the code right... Cheers, Black Box... Quote
Guest Posted June 7, 2013 Posted June 7, 2013 Command: (LOAD "C:/Users/Prodromos/Desktop/ktimtel.lsp") C:KTIM Command: ktim ** Scale must be "1:1000" or "1:5000" Command: !!!!!!!!!!!!!!!!!!!!!!!!!! Quote
Guest Posted June 7, 2013 Posted June 7, 2013 (edited) a) if the scale 1: 1000 we have this T = [((sqrtA) + 1)^ 2) - A] * [ L/( 4*(sqrtA)] b) if the scale 1: 5000 we have this T = [((sqrtA) + 4)^ 2) - A] * [ L/( 4*(sqrtA)] something is wrong here because for A=266.50sqm and L=66.18 m calculate a) T=8.526 and the correct is T = 34.10 b) T=37.144 and the correct is T = 148.58 here is the code -------------------------------- (defun c:ktim (/ a l i s) (if (setq s (ssget '((0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (-4 . "<NOT") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&") (70 . 80) (-4 . "AND>") (-4 . "NOT>") ) ) ) (progn (setq a 0.0) (repeat (setq i (sslength s)) (setq a (+ a (vlax-curve-getarea (ssname s (setq i (1- i)))))) ) ;;; (progn (setq l 0.0) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) ) ) ) (textscr) (princ "\nTotal Length: ") (princ (rtos l 2 2)) ;;; ) (princ "\nTotal Area: ") (princ (rtos a 2 2)) ;;; ) (princ "\n Tolerance 1:1000: ") (princ (rtos (/ (* (- (* (+ (sqrt a) 1) (+ (sqrt a) 1)) a) l) (* (sqrt a) 4) 2 2 ) ) ) (princ "\n Tolerance 1:5000: ") (princ (rtos (/ (* (- (* (+ (sqrt a) 4) (+ (sqrt a) 4)) a) l) (* (sqrt a) 4) 2 2 ) ) ) (princ "\n 10 % Area : ") (princ (rtos (* a 0.1) 2 2)) ) ) (princ) ) (vl-load-com) (princ) Edited June 10, 2013 by SLW210 Add Code Tags!! Quote
BlackBox Posted June 7, 2013 Posted June 7, 2013 Command: (LOAD "C:/Users/Prodromos/Desktop/ktimtel.lsp") C:KTIMCommand: ktim ** Scale must be "1:1000" or "1:5000 ** " Command: !!!!!!!!!!!!!!!!!!!!!!!!!! How are you determining your scale (1:1000 vs. 1:5000)? As I mentioned at the bottom of this post, I could only speculate that you were using Annotative Scale... Perhaps you're using DimScale? In any event, without knowing which scale to check for the two specific values you requested, there's no way to ensure that the calculation is accurate. more information is needed, so that we're not confused. Quote
Guest Posted June 7, 2013 Posted June 7, 2013 Select objects: Total Length: 66.18 Total Area: 266.50 Tolerance 1:1000: 8.526 Tolerance 1:5000: 37.144 10 % Area : 26.65 Command: 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.