Meassuring distances "by layer"

Meassuring distances "by layer"

Anonymous
Not applicable
880 Views
4 Replies
Message 1 of 5

Meassuring distances "by layer"

Anonymous
Not applicable

Hi everyone!

 

I have the next routine which i took from the forum. Just wanted to add a new filter so it selects only the items which are inside a specific layer (_AUX-COMENT).

I tried to add an ssget, but it says: mistake, wrong point argument.

 

(defun C:SUM (/ ss tl n ent itm obj l)
(setq ss (ssget (8 . "_AUX-COMENT"))
tl 0
n (1- (sslength ss)))
(while (>= n 0)
(setq ent (entget (setq itm (ssname ss n)))
obj (cdr (assoc 0 ent))
l (cond
((= obj "LINE")
(distance (cdr (assoc 10 ent))(cdr (assoc 11 ent))))
((= obj "ARC")
(* (cdr (assoc 40 ent))
(if (minusp (setq l (- (cdr (assoc 51 ent))
(cdr (assoc 50 ent)))))
(+ pi pi l) l)))
((or (= obj "CIRCLE")(= obj "SPLINE")(= obj "POLYLINE")
(= obj "LWPOLYLINE")(= obj "ELLIPSE"))
(command "_.area" "_o" itm)
(getvar "perimeter"))
(T 0))
tl (+ tl l)
n (1- n)))
(command "_erase" ss "")
(alert (strcat "La longitud total es: " (rtos tl)))
(princ)
)

 

Thank you for your help!

0 Likes
Accepted solutions (2)
881 Views
4 Replies
Replies (4)
Message 2 of 5

devitg
Advisor
Advisor

change to 

 

(ssget "X" (list (8 .  "_AUX-COMENT")))

Filter shall be a list 

0 Likes
Message 3 of 5

doaiena
Collaborator
Collaborator
Accepted solution

It should be like this: (ssget '((8 . "_AUX-COMENT")))

Message 4 of 5

CodeDing
Advisor
Advisor
Accepted solution

@Anonymous ,

 

Looks like you were close. Does this solve your issue? It seems to be working for me..

(defun C:SUM (/ ss tl n ent itm obj l)
(setq ss (ssget '((8 . "_AUX-COMENT")))
      tl 0
      n (1- (sslength ss)))
(while (>= n 0)
  (setq ent (entget (setq itm (ssname ss n)))
        obj (cdr (assoc 0 ent))
        l (cond
	    ((= obj "LINE")
	      (distance (cdr (assoc 10 ent))(cdr (assoc 11 ent))))
	    ((= obj "ARC")
	      (* (cdr (assoc 40 ent))
	         (if (minusp (setq l (- (cdr (assoc 51 ent))
				        (cdr (assoc 50 ent)))))
	             (+ pi pi l)
		     l)))
	    ((or (= obj "CIRCLE")(= obj "SPLINE")(= obj "POLYLINE")
	         (= obj "LWPOLYLINE")(= obj "ELLIPSE"))
	      (command "_.area" "_o" itm)
	      (getvar "perimeter"))
	    (T 0)
	  );cond
        tl (+ tl l)
	n (1- n)
  );setq
);while
(command "_erase" ss "")
(alert (strcat "La longitud total es: " (rtos tl)))
(princ)
)

Best,

~DD

Message 5 of 5

Anonymous
Not applicable

Thank you so much!

Problem solved!

0 Likes