Jump to content

Recommended Posts

Posted

Hi all,

 

I got 2 criteria of selection wich i wanna use to make 1 selectionset...

I want all blocks of a predefined layername and blockname list

I want all line,arc and polyline of a predefinied layername list...

Can this be written in 1 ssget function?

If not... how to easily combine both?

 

thanks in advance.

 

(setq ssvalid (ssget "_X" (list (cons 0 "INSERT" (cons 8 validlisttotal) (cons 2 validlisttotalblocks))))
(setq ssvalid (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE" (cons 8 validlisttotal))))

 

Posted

Maybe this will help, http://lee-mac.com/ssget.html, looking towards the bottom and the 'or' option, you want to select entities that are blocks OR lines (use the description in the AND box above for a good example, changing it to OR of course)

 

If your code is working nicely though a bit long, not changing anything that works (always good...) this  https://www.afralisp.net/autolisp/tutorials/selection-sets.php has a description of how to add 2 existing selection sets together (about 2/3 of the way down the page, creating a 'union' between selection sets). Not sure what happens if an entity is in both sets, probably will exist twice in the new selection set and be processed twice subsequently.

  • Agree 1
Posted

Best to use the Logical Operators shown in lee mac's website to create one selection set like Steven says.

While afralisp also works I don't like to use counters so here is the foreach way.

 

(setq SS (ssget "_X" (list (cons 0 "INSERT") (cons 8 validlisttotal) (cons 2 validlisttotalblocks)))) ;was missing ) on (cons 0 INSERT
(setq SS1 (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE") (cons 8 validlisttotal)))) ;use a diffrent selection set name 
(foreach ent (mapcar 'cadr (ssnamex SS1)) ;builds a list of entity names from selection set ss1
  (ssadd ent ss) ;adds each entity from ss1 to ss
)

 

 

 

 

  • Like 1
Posted

Thanks for the suggestions, i think i found a simple one...

 

	(setq ssvalid1 (ssget "_X" (list (cons 0 "INSERT") (cons 8 validlisttotal) (cons 2 validlisttotalblocks))))
	(setq ssvalid2 (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE") (cons 8 validlisttotal))))
	(setq ssvalid (acet-ss-union (list ssvalid1 ssvalid2)))

 

Works like a charm! :D

  • Like 2
Posted (edited)

Nice learning something every day!

Edited by mhupp
Posted
3 hours ago, Aftertouch said:

Hi all,

 

I got 2 criteria of selection wich i wanna use to make 1 selectionset...

I want all blocks of a predefined layername and blockname list

I want all line,arc and polyline of a predefinied layername list...

Can this be written in 1 ssget function?

If not... how to easily combine both?

 

thanks in advance.

 

(setq ssvalid (ssget "_X" (list (cons 0 "INSERT" (cons 8 validlisttotal) (cons 2 validlisttotalblocks))))
(setq ssvalid (ssget "_X" (list (cons 0 "LINE,ARC,LWPOLYLINE" (cons 8 validlisttotal))))

 

Nothing will work with your examples because they are invalid to begin with.

image.thumb.png.92d3fb3e308de0f362e144e64279bda2.png

Try this untested:

(ssget "_X"
       (list '(-4 . "<OR")
	     '(-4 . "<AND")
	     '(0 . "INSERT")
	     (cons 8 validlisttotal)
	     (cons 2 validlisttotalblocks)
	     '(-4 . "AND>")
	     '(-4 . "<AND")
	     '(0 . "LINE,ARC,LWPOLYLINE")
	     (cons 8 validlisttotal)
	     '(-4 . "AND>")
	     '(-4 . "OR>")
       )
)


 

 

 

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...