Jump to content

Ssget divide object on window filter


Kowal

Recommended Posts

I selected objects function ssget.

(setq s ssget)

I have a list of corner windows (white squares on drawing).

'((x y) (x y) (x y) (x y) (x y))

How to divide the objects on those that are inside the window.

I need a list entity of objects in each window.

'((<Entity name: 7ffff931b40> <Entity name: 7ffff931b40> ...)
(...) (...) (...) (...))

Is there a way to use the filters window on the system variable ssget (ssget "_W"

The example in the drawing.

1.jpg

Link to comment
Share on other sites

Something like this? :

(defun c:test ( / SS i ent lst x SelN n Nlst Tlst )
(if 
	(and 
		(princ "\nSelect the closed(white) plines: ")
		(setq SS (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
	);and
	(progn
		(repeat (setq i (sslength SS)) ; repeat for each closed polyline
			(setq ent (ssname SS (setq i (1- i))))
			(setq	lst (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) (entget ent))))
			
			(if 
				(and 
					(setq SelN (ssget "_WP" lst))
					(or (not (ssmemb ent SelN)) (ssdel ent SelN))
					(< 0 (sslength SelN))
				)
				(progn
					(repeat (setq n (sslength SelN)) ; repeat for each entity inside the polyline
						(setq Nlst (cons (ssname SelN (setq n (1- n))) Nlst)) ; create list for the SS
					)
					(setq Tlst (cons (reverse Nlst) Tlst)) ; store the SS list into the global list
					(setq Nlst nil) ; reset the SS list
				)
			); if
		); repeat
		(princ "\n") (print Tlst) ; print the global list
	);progn
); if/while
(princ)
)

 

This is heavily modified code, the original is from Lee Mac (MatchCenInsPoly) - by my old request. :)

Link to comment
Share on other sites

An alternative method maybe a bit more complex is to pick one window only but check the min/max Y value of the object so it becomes part of only 1 window group. Look also at bounding box methods. You can vary the window sizes then.

Link to comment
Share on other sites

It must be simple and quick.

I used a solution in which first choose the coordinates the windows and then ssget (window).

(setq lst '(((x y) (x y)) ((x y) (x y))  ((x y) (x y)) ...))

 

(mapcar '(lambda (%) (ssget "_W" (car %) (cadr %))) lst)

Sorry for my English.

Link to comment
Share on other sites

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...