SSGET filter with block attribute value

SSGET filter with block attribute value

traci_haberghamJQEJT
Enthusiast Enthusiast
1,041 Views
11 Replies
Message 1 of 12

SSGET filter with block attribute value

traci_haberghamJQEJT
Enthusiast
Enthusiast

Hi there,

 

I am trying to filter a selection of a block using block name, layer name and ideally I would like it to select the block if the attribute value is a certain value.

 

(setq exdemise (ssget "_X" (list '(0 . "INSERT") '(2 . "PG_Ann_Area_Roomtag_Pln_Dyn") '(8 . "PG_Annotation_RoomTag_Existing"))))

 

I would like to add to the filter for it to select blocks with attribute data tag AREATYPE which is equal to 'Ex Demise Area'.

 

Is this possible?  I've looked everywhere and can't find a solution.

 

Thank you

Traci

0 Likes
Accepted solutions (1)
1,042 Views
11 Replies
Replies (11)
Message 2 of 12

ВeekeeCZ
Consultant
Consultant

There is NO way to create ss filter for att tags or even its values. You need to select all inserts with atts '(66 . 1), then filter them out afterward.

0 Likes
Message 3 of 12

komondormrex
Mentor
Mentor

hey,

you cannot do this with ssget only. can be done with ssgetting attributed blocks and filtering out ones not suitable for a certain attribute tag and value selection.

0 Likes
Message 4 of 12

traci_haberghamJQEJT
Enthusiast
Enthusiast

Thank you, is there any guidance on how to filter the attribute values, I don't know how to even see them in Autolisp?  

0 Likes
Message 5 of 12

ВeekeeCZ
Consultant
Consultant

Do you know how to process the selection set?

 

https://www.lee-mac.com/selsetprocessing.html

 

BTW this part only works if blocks are NOT dynamic, are they?

'(2 . "PG_Ann_Area_Roomtag_Pln_Dyn")

 

 

 

Edit: Example for your case...

 

(if (setq exdemise (ssget "_X" (list '(0 . "INSERT") '(2 . "PG_Ann_Area_Roomtag_Pln_Dyn") '(8 . "PG_Annotation_RoomTag_Existing"))))
  (repeat (setq index (sslength exdemise))
    (setq ename (ssname exdemise (setq index (1- index))))
    (if (/= (getpropertyvalue ename "AREATYPE") "Ex Demise Area")
      (ssdel ename exdemise))))

 

0 Likes
Message 6 of 12

komondormrex
Mentor
Mentor
Accepted solution

and lm free one

 

(setq insert_sset (ssadd)) 
(sssetfirst nil
			(foreach insert
					 (vl-remove-if-not '(lambda (insert) (and (= "PG_Ann_Area_Roomtag_Pln_Dyn" (vla-get-effectivename (vlax-ename->vla-object insert))) 
					 										  (vl-some '(lambda (attribute) (and (= "AREATYPE" (vla-get-tagstring attribute))
																								 (= "Ex Demise Area" (vla-get-textstring attribute))
																						   	)
																	   	)
																	   	(vlax-invoke (vlax-ename->vla-object insert) 'getattributes)
														      )
														 )
										)
										(vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "_x" '(
																									(0 . "insert") 
																								  	(8 . "PG_Annotation_RoomTag_Existing")
																								  	(66 . 1)
																								 )
																					)
																		   )
															 )
										)
					 )
					 (ssadd insert insert_sset)
			)
)

 

Message 7 of 12

traci_haberghamJQEJT
Enthusiast
Enthusiast

Thank you, much appreciated.

 

I'll have a look at the link and no its not a dynamic block (not sure why its called that, was created before I joined).

0 Likes
Message 8 of 12

traci_haberghamJQEJT
Enthusiast
Enthusiast

Thank you, greatly appreciated.  I'll have a look at sorting the selection set with the above to filter what I need.

0 Likes
Message 9 of 12

traci_haberghamJQEJT
Enthusiast
Enthusiast

This works a treat - thank you (& lm too) 🙂

 

Message 10 of 12

traci_haberghamJQEJT
Enthusiast
Enthusiast

Sorry its me again!  Just one question, I have updated my lisp to include the above so it narrows down my selection set to the relevant attributes but I don't think that the new selection set created by this takes all the information across - is this possible?    If I ran the table before it populated the area values but since updating the selection set using the attribute code it doesn't populate those attributes.  Any  ideas why?  Thank you (again!!)

 

traci_haberghamJQEJT_0-1732113478051.png

 

 

0 Likes
Message 11 of 12

komondormrex
Mentor
Mentor

@traci_haberghamJQEJT wrote:

... I have updated my lisp to include the above so it narrows down my selection set to the relevant attributes but I don't think that the new selection set created by this takes all the information across - is this possible?  


hardly, if only your attributes are not exactly same in writing in which case strcase will generally help. do you want to get area attributes value from every block in filtered selection set to put into the table generated?

 


@traci_haberghamJQEJT wrote:

If I ran the table before it populated the area values but since updating the selection set using the attribute code it doesn't populate those attributes.  Any  ideas why?  Thank you (again!!)

 


need to see your updated code.

0 Likes
Message 12 of 12

traci_haberghamJQEJT
Enthusiast
Enthusiast

Sorry it was user error, its all working great now.  Thank you 😀

0 Likes