RepCad Posted December 26, 2018 Share Posted December 26, 2018 hi guys, i need a lisp to get Count of Object in a specific layer by get layer name, can someone help me? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 26, 2018 Share Posted December 26, 2018 Layer Count 1 Quote Link to comment Share on other sites More sharing options...
RepCad Posted December 26, 2018 Author Share Posted December 26, 2018 (edited) hi thanks, i have seen that topic already, but i want to know count of object only in one layer, i wrote this code but it doesn't work : (sorry i'm beginner in autolisp) (defun c:LC () (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq cnt (vla-get-Count (vla-item (vla-get-Layers doc) "Wall"))) ) "Wall" is layer name Edited December 26, 2018 by amir0914 Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 26, 2018 Share Posted December 26, 2018 (defun c:LC nil (if (ssget "_X" '((8 . "Wall"))) (progn (prompt "\nTotal : ") (princ (sslength (ssget "_X" '((8 . "Wall"))))) (prompt " entities in Layer : \"Wall\"") ) (prompt "\nNo entities in Layer : \"Wall\"") ) (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
RepCad Posted December 26, 2018 Author Share Posted December 26, 2018 (edited) Thank you marko, i used your code and my problem is resolved, Which part of my code is wrong?? Edited December 26, 2018 by amir0914 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 27, 2018 Share Posted December 27, 2018 (edited) A little add on not hard codedfor layer name. (defun c:LC ( / layname ) (setq layname (vla-get-layer (vlax-ename->vla-object (car (entsel))))) (if (setq ss (ssget "_X" (list (cons 8 layname)))) (Alert (strcat "\nTotal : " (rtos (sslength ss) 2 0) " entities \n\nIn Layer : " layname)) (Alert (strcat "\nNo entities in Layer : " layname)) ) (princ) ) (c:lc) (vla-get-Layers doc) this gets the list of layer names from the layer table, not objects within that layer. Edited December 28, 2018 by BIGAL 1 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 27, 2018 Share Posted December 27, 2018 17 hours ago, amir0914 said: Which part of my code is wrong?? A VLA Layer object does not have a count property - you can check the available properties & methods for an object using the vlax-dump-object function. 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted December 27, 2018 Share Posted December 27, 2018 11 hours ago, BIGAL said: (setq ss (ssget "_X" (list (cons 8 layname I think you're missing a few closing parenthesis 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 28, 2018 Share Posted December 28, 2018 Thanks ronjonp must have cut and pasted wrong. 1 Quote Link to comment Share on other sites More sharing options...
RepCad Posted December 29, 2018 Author Share Posted December 29, 2018 Thank you all for your honest help and advice, lee Mac, I check and study vlax-dump-object , it was useful and great. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 29, 2018 Share Posted December 29, 2018 1 hour ago, amir0914 said: Thank you all for your honest help and advice, lee Mac, I check and study vlax-dump-object , it was useful and great. You're most welcome @amir0914 - You may find my Dump Object utility useful in this regard - it's a simple program and merely a wrapper for the vlax-dump-object function to allow you to select a primary or nested object. 1 Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 29, 2018 Share Posted December 29, 2018 4 hours ago, Lee Mac said: You may find my Dump Object utility useful in this regard - it's a simple program and merely a wrapper for the vlax-dump-object function Lee, just an idea for fun - you could include accepting a handle argument [STR]. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 29, 2018 Share Posted December 29, 2018 (edited) 1 hour ago, Grrr said: Lee, just an idea for fun - you could include accepting a handle argument [STR]. An excellent idea Grrr! I have now updated the utility to achieve exactly that - I've also rewritten it to handle the various data types more elegantly - thank you for this suggestion. Edited December 29, 2018 by Lee Mac 1 Quote Link to comment Share on other sites More sharing options...
RepCad Posted January 7, 2019 Author Share Posted January 7, 2019 Thank you Lee mac, Sorry for the delay in replying, I see your website and post about Dump-Object, I'm sure it will help me a lot , thanks again.. 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.