Dustin11 Posted May 24, 2013 Share Posted May 24, 2013 I have this rough draft code I'm building to be used as a layer checker but I also need to to loop through once using the first item in the list, then loop through a second time using the second item on the list, then a third, fouth, etc..... but I can't seem figure out a way to make it do that. I'm also pretty sure that where I have the "repeat" function is incorrect because after I added it the code stopped working, but I haven't tried messing around with that to get it working again. (defun c:mscheck (/ sys ss count msg) (setq sys (list "H-LOWP")) (setq sys (append sys '("H-LOWP-EXST" "H-MEDP" "H-MEDP-EXST" "H-EXHS" "H-EXHS-EXST" "H-GRDS" "H-GRDS-EXST" "H-RTRN" "H-RTRN-EXST" "G-GENL-TEXT" "G-GENL-TEXT-EXST" "G-EQPM" "G-EQPM-EXST" "H-STAT" "H-STAT-EXST" "H-OAIR" "H-OAIR-EXST"))) (setq count (length sys)) (repeat count (if (tblsearch "layer" sys)foreach (progn (setq ss (ssget "_X" (list (cons 8 sys)))) (if (= ss nil) (progn (setq count "0") );progn (progn (setq count (sslength (ssget "_P"))) );progn );if );progn (progn (setq count "DNE") );progn );if (setq msg (cons sys count)) (print msg) (princ) );repeat );defun Quote Link to comment Share on other sites More sharing options...
BlackBox Posted May 24, 2013 Share Posted May 24, 2013 (defun c:FOO (/ ss) (foreach layerName '("H-LOWP" "H-LOWP-EXST" "H-MEDP" "H-MEDP-EXST" "H-EXHS" "H-EXHS-EXST" "H-GRDS" "H-GRDS-EXST" "H-RTRN" "H-RTRN-EXST" "G-GENL-TEXT" "G-GENL-TEXT-EXST" "G-EQPM" "G-EQPM-EXST" "H-STAT" "H-STAT-EXST" "H-OAIR" "H-OAIR-EXST" ) (prompt (strcat "\n[" layerName "] : " (if (setq ss (ssget "_x" (list (cons 8 layerName)))) (itoa (sslength ss)) "0" ) ) ) ) (textpage) (princ) ) Quote Link to comment Share on other sites More sharing options...
Dustin11 Posted May 24, 2013 Author Share Posted May 24, 2013 Nice. it works perfectly. I'll have to dissect your code a littie bit and see what you did incase I need to write something like that again in the future. Thanks. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted May 24, 2013 Share Posted May 24, 2013 Nice. it works perfectly. I'll have to dissect your code a littie bit and see what you did incase I need to write something like that again in the future. Thanks. You're welcome; I'm happy to help. Essentially, Foreach layerName in the list of layerNames, Prompt the user the layerName, and If there are Entities on that layer, include how many, Else zero. 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.