Getting the number of objects based on selection and filtering by block name

Getting the number of objects based on selection and filtering by block name

gustavobernardi
Advocate Advocate
851 Views
3 Replies
Message 1 of 4

Getting the number of objects based on selection and filtering by block name

gustavobernardi
Advocate
Advocate

Why I can't have the number of objects with this code:

 

(setq selectiopanel (ssget '((2 . "Painel Fotovoltaico" ))))
(setq n (sslength selectiopanel))

The selection works fine, but the n value returns nil. And on the command line screen it returns this error:

 

:CALLBACK-ENTRY.6 (:CALLBACK-ENTRY)
:ARQ-SUBR-CALLBACK.3 (nil 0)

Error: bad function: <Selection set: 92>

 

TIA

 

0 Likes
Accepted solutions (1)
852 Views
3 Replies
Replies (3)
Message 2 of 4

cadffm
Consultant
Consultant
Accepted solution

Re-open the file or open a new one, or better re-open Acad, still a problem with ONLY these two lines?

Sebastian

Message 3 of 4

Sea-Haven
Mentor
Mentor

You have to get blocks 1st then 2nd order name

 

(setq selectiopanel (ssget '((cons 0 "Insert")(2 . "Painel Fotovoltaico" ))))

Message 4 of 4

gustavobernardi
Advocate
Advocate

Thanks for the answer

 

I've tried it before, and it was unsuccessful. I don't know what was wrong, perhaps some part of the code had broke some definition of my AutoCAD and it was recovered when I restarted.

 

I don't know if it have a further problem, but it is working without verifying if it is a Reference Block.

0 Likes