Originally Posted by
Ed Jobe
If you already have something, post your code.
here's what i have so far
Code:
(defun c:penrodcount ( ) ;/ unsup effname num unsupstring
(vl-load-com)
(setq BB1 (getpoint "\nWindow select areas to be counted:\n")) ;asks 1st point of area
(setq BB2 (getcorner BB1)) ;asks 2nd point of area
(if (setq blks (ssget "w" bb1 bb2 (list (cons 0 "insert") (cons 8 "TIE - Pencil Rod")))) ;selection set of blocks in current bounding box
(progn ;start progn
(setq num 0) ;set block number to 0, aka first
(repeat (sslength blks) ;repeat this the number of blocks found
(setq blk (ssname blks num)) ;set current block
(setq effname (vla-get-EffectiveName (vlax-ename->vla-object blk))) ;gets effective name of current block
(cond ;conditional that puts the current entity into the correct selection set based on effective name
((= effname "Pencil Rod") (findlength)) ;if effective name is Pencil Rod, run findlength subroutine
(t (setq unsup effname)) ;if effective name is not, then set unsup name to current block name
) ;end of cond
(setq num (+ 1 num)) ;adds 1 to block number so can go to next block
) ;end of repeat
) ;end progn
) ;end if
(if (/= unsup nil) ;if unsup has value
(progn ;progn
(setq unsupstring (strcat "Unsupported block " unsup " found in count process")) ;create alert string
(alert unsupstring) ;alert
) ;end progn
) ;end if
) ;end
(defun findlength ( / currentlength)
;; (setq currentlength ?????????????????????????????????? ;PART IM ASKING ABOUT
;; round to nearest inch ;haven't written yet
;; if this size doesnt exist, ;start of if
;; create new size & add this entity to count of current size ;
;; add this entity to count of existing size ;
;; ;end of if
)
I attempted to insert both of the proposed sections of code by Tharwat and dlanor instead of (findlength) and they resulted in an error saying that there were too few arguments. I think part of the problem is that I don't know what I'm supposed to put for "prp" if using code suggested by dlanor, or "val" if using code suggested by Tharwat.
If I copy (vlax-invoke blk 'getdynamicblockproperties) into the command line after running the program, i get ; error: bad argument type: VLA-OBJECT <Entity name: 163161a1480>
Don't know if this helps or not, but thank you all for your help.
If I can figure out how to upload the block i'm working with, i'd be willing to do that if it would help too.
Thanks again - Aaron