Hi guys,
im new here so dont be to hard on memy lisp skills are minimal so.
Currently im working with a routine that returns the amount and property value of a certain block.
This is the situation:
Im having 1 block called "Mesh panels H1900"
This block has an dynamic property called "Width" and at the moment this is what the routine returns:
Now the thing i want is the Total width of All the mesh panels, could you guys help me with that ?Code:There are 1 instances of "Mesh panels H1900" with property "Width" set to 1198. There are 2 instances of "Mesh panels H1900" with property "Width" set to 1298. There are 59 instances of "Mesh panels H1900" with property "Width" set to 1498. There are 8 instances of "Mesh panels H1900" with property "Width" set to 398. There are 1 instances of "Mesh panels H1900" with property "Width" set to 498. There are 1 instances of "Mesh panels H1900" with property "Width" set to 698. There are 1 instances of "Mesh panels H1900" with property "Width" set to 798. There are 1 instances of "Mesh panels H1900" with property "Width" set to 898.
Code:;;;effname = name of block to count ;;;property = name of dynamic property to count (vl-load-com) (defun db_counts(effname property / sset proplist cnt en props old ) (setq sset(ssdblk effname)) (if(not sset) (alert(strcat "No Dynamic Blocks with effective name: " effname)) (progn;else (setq proplist(list) cnt 0 ) (repeat(sslength sset) (setq en(ssname sset cnt) cnt(1+ cnt) ) (setq props(vlax-safearray->list(variant-value (vla-getdynamicblockproperties(vlax-ename->vla-object en)))) ) (foreach n props (if(= (strcase(vla-get-propertyname n)) (strcase property)) (cond ((=(variant-type(vla-get-value n))2) (setq proplist(cons(itoa(variant-value(vla-get-value n)))proplist)) ) ((<(variant-type(vla-get-value n))8) (setq proplist(cons(rtos(variant-value(vla-get-value n)))proplist)) ) (T (setq proplist(cons(variant-value(vla-get-value n))proplist))) );cond );if );foreach (setq proplist(vl-sort proplist '<)) );repeat (setq cnt 0) (setq old nil) (foreach n proplist (setq cnt(-(length proplist)(length(setq proplist(vl-remove n proplist))))) (if(/= old n) (princ(strcat"\nThere are " (itoa cnt) " instances of \"" effname "\" with property \"" property "\" set to " n "." ) ) ) (setq old n) );foreach );progn );if (setq sset nil) (princ) );defun (princ "\n(DB_COUNTS \"EFFNAME\" \"PROPERTY\")")


Reply With Quote

