SPACECADET Posted April 11, 2011 Posted April 11, 2011 I have been searching forum a while, no definative answer. I need to count how many blocks are in a drawing but only those that contain attributes. I can't seem to do this with the filter command as it only shows number of all blocks regardless of whether they contain attributes or not. Is this do-able via search options or would it be a lisp thing? Many thanks Quote
Lee Mac Posted April 11, 2011 Posted April 11, 2011 In LISP, it could be: (defun c:test ( / a ) (if (setq a (ssget "_X" '((0 . "INSERT") (66 . 1)))) (princ (strcat "\nThere are " (itoa (sslength a)) " attributed blocks in the Drawing.")) (princ "\nThere are no attributed blocks in the Drawing.") ) (princ) ) Or perhaps more grammatically correct: (defun c:test ( / a ) (princ (cond ( (not (setq a (ssget "_X" '((0 . "INSERT") (66 . 1))))) "\nThere are no attributed blocks in the Drawing." ) ( (= 1 (sslength a)) "\nThere is 1 attributed block in the Drawing." ) ( (strcat "\nThere are " (itoa (sslength a)) " attributed blocks in the Drawing.") ) ) ) (princ) ) Quote
SPACECADET Posted April 11, 2011 Author Posted April 11, 2011 Wow, did you cut and paste that or do people actually code as fast as the show in films? yes that seems along the lines Lee. Thank you. I assume that counts all the model space and paper space blocks as a whole? So it would pick up likes of drawing borders etc in the paperspace. How difficult would it be to add the option to count only the attributed blocks in a selection? Quote
Lee Mac Posted April 11, 2011 Posted April 11, 2011 Hi SpaceCadet, Didn't cut and paste, just typed it To count all in selection only, remove the "_X" from the ssget function. Quote
SLW210 Posted April 13, 2011 Posted April 13, 2011 Why do I always kill threads Maybe it is your avatar. Quote
Rebel Posted April 14, 2011 Posted April 14, 2011 HA. Nonsense! The monocle smile would never do such things. Quote
SPACECADET Posted April 14, 2011 Author Posted April 14, 2011 Why do I always get sent out of the office when i'm trying to get answers. Back at the workstation now. re:data extraction. It's during this process that the number I need to check seems to disappear. I am doing a check that the number of blocks (with attributes) in the drawing is equal to the number that end up in the excel file after extraction. If we have a mixture of attributed blocks and non-attributed blocks in a drawing The filtered search result gives me all blocks. I then dx and tick boxes to extract only blocks with attributes, but it doesn't tell me in that process what the total number of those attributed blocks is... Does any of this make sense? Ideally it would be good if during the extraction process when you tick a box in the settings it could tell you "you now have xxx block selected for extraction" Quote
SPACECADET Posted April 14, 2011 Author Posted April 14, 2011 Hi SpaceCadet, Didn't cut and paste, just typed it To count all in selection only, remove the "_X" from the ssget function. yes that worked. Excellent. Sorry all got sent out of the office...always good to get out though. They keep me in a basement you know! 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.