what's wrong in my code (
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 Tand the (10% * Area)
The (10% * Area) is safety factor that why is important because
if (10% * Area) > T the the toleranceis the T
and
if (10% * Area)
-------------------------------------------------------------
(defun c:ktim ( / a l i s ) (if (setq s (ssget '( (0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (-4 . "") ) ) ) (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) please help i need this ... 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? (defun c:ktim ( / a l i s e ) (if (setq s (ssget '( (0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE") (-4 . "") ) ) ) (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)) 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 . 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 . "") ) ) ) (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*
... Kind of hard to evaluate all of those PRINC calls, if the PROGN call never happens (due to s = Nil). 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 . "") ) ) )(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)) i neeed something moreif 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 thisT = [((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) nice job but the calculation is wrong, any ideas ???????????? 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 . "") ) ) ) ) (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.
页:
[1]
2