Tamim Posted January 19 Share Posted January 19 Here is an example of an array that needs to be worked on and I need an easy way to count the number of rows and columns. For example, I have 3 rows and 20 columns and I need to be able to select for multiple arrays. Quote Link to comment Share on other sites More sharing options...
Tamim Posted January 19 Author Share Posted January 19 For example, if 10 arrays with different row and column counts are used and I select all the arrays, I need to know the individual row and column count of all 10 arrays. Quote Link to comment Share on other sites More sharing options...
mrharris78 Posted January 20 Share Posted January 20 (edited) (if (setq sel (ssget "_:L")) (progn (setq lst '()) (repeat (setq inc (sslength sel)) (setq ent (ssname sel (setq inc (1- inc)))) (if (eq (getpropertyvalue ent "ClassName") "AcDbAssociativeRectangularArray") (progn (setq col (getpropertyvalue ent "Items") rws (getpropertyvalue ent "RowsWithExpression") tot (list (col rws)) lst (append tot lst) ) ) ) ) (princ lst) ) ) Something like this? Edited January 20 by mrharris78 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 20 Share Posted January 20 Try this as a starting point, found it by Googling. ; big thanks to KGA for source code ; Google will find code with error checking (defun c:wow ( / enm elst x lst) (setq enm (car (entsel "\nPick array "))) (setq elst (entget enm)) (setq elst (cdr (member '(102 . "{ACAD_REACTORS") elst))) (setq elst (entget (cdr (assoc 330 elst)))) (setq elst (entget (cdr (assoc 330 elst)))) (setq x 0 lst '()) (repeat (length elst) (if (= (cdr (nth (setq x (1+ x)) elst)) "Items") (setq lst (cons (cdr (nth (+ x 3) elst)) lst)) ) (if (= (cdr (nth (setq x (1+ x)) elst)) "Rows") (setq lst (cons (cdr (nth (+ x 3) elst)) lst)) ) ) (alert (strcat (rtos (car lst) 2 0) " Columns " (rtos (cadr lst) 2 0) " Rows")) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tamim Posted January 22 Author Share Posted January 22 @BIGAL Thanks but not work for this code below the image shows up after the WOw comment Quote Link to comment Share on other sites More sharing options...
Tamim Posted January 22 Author Share Posted January 22 @mrharris78 Thanks, as per the code just show only the total count array number Quote Link to comment Share on other sites More sharing options...
mrharris78 Posted January 22 Share Posted January 22 (edited) (defun c:arraycountdemo ( / doc hgt sel clx rwx spc inc ent col rws pnt ret ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq hgt 25) ;_*** Required Text Height *** (prompt "\nSelect Rectangular Arrays: ") (if (and hgt (setq sel (ssget "_:L"))) (progn (setq clx '() rwx '()) (setq spc (vlax-get doc (if (= 1 (getvar 'cvport)) 'paperSpace 'modelSpace))) (repeat (setq inc (sslength sel)) (setq ent (ssname sel (setq inc (1- inc)))) (if (eq (getpropertyvalue ent "ClassName") "AcDbAssociativeRectangularArray" ) (progn (setq col (getpropertyvalue ent "Items") rws (getpropertyvalue ent "RowsWithExpression") pnt (list (getpropertyvalue ent "Base/X")(getpropertyvalue ent "Base/Y")(getpropertyvalue ent "Base/Z")) clx (append clx (list col)) rwx (append rwx (list rws)) ) (vla-AddText spc (strcat (itoa rws) " Rows & " (itoa col) " Columns") (vlax-3d-point pnt) hgt) ) ) ) (alert (setq ret (strcat "\nTotal Rows: " (itoa (apply '+ rwx)) "\nTotal Columns: " (itoa (apply '+ clx)) ) ) ) ) ) (princ) ) Edited January 23 by mrharris78 Quote Link to comment Share on other sites More sharing options...
Tamim Posted January 22 Author Share Posted January 22 @mrharris78 Amazing code, but I need the results to look like the image 01 below. According to your code, the selection array should show up as image 02 below. image 01 Image 02 Quote Link to comment Share on other sites More sharing options...
mrharris78 Posted January 23 Share Posted January 23 Tamim, I have updated code above - not tested and no error checking. 1 Quote Link to comment Share on other sites More sharing options...
Tamim Posted January 23 Author Share Posted January 23 Mrharris, Thanks for your support now worked Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 23 Share Posted January 23 @mrharris78 FWIW you could narrow down your selection set with a filter like so: (setq sel (ssget "_:L" '((0 . "INSERT") (2 . "`*U*")))) Quote Link to comment Share on other sites More sharing options...
mrharris78 Posted January 24 Share Posted January 24 10 hours ago, ronjonp said: @mrharris78 FWIW you could narrow down your selection set with a filter like so: (setq sel (ssget "_:L" '((0 . "INSERT") (2 . "`*U*")))) Thank you @ronjonp very interesting! Quote Link to comment Share on other sites More sharing options...
Tamim Posted January 25 Author Share Posted January 25 can't understand Quote Link to comment Share on other sites More sharing options...
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.