Jump to content

Recommended Posts

Posted

Hi,

 

How can I select all the rectangles in the drawing with no content?

 

Thx for a tip.

example.dwg

Posted (edited)

Here's one way:

(defun c:foo (/ a b s)
  ;; RJP » 2021-04-26
  (if (setq s (ssget '((0 . "LWPOLYLINE") (90 . 4))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (vla-getboundingbox (vlax-ename->vla-object e) 'a 'b)
      (or (= 1 (sslength (ssget "_C" (vlax-safearray->list a) (vlax-safearray->list b))))
	  (ssdel e s)
      )
    )
  )
  (sssetfirst nil s)
  (princ)
)

 

Edited by ronjonp
Posted

if I'm understanding this

 

- Make selection set of polylines that are selected by user & have 4 vertices.

  - for each of those selected polylines find the bounding box points

   - create a temp 2nd selection set using those points

     - if only the polyline is selected keep else delete that polyline from the selection set.

- Select everything thing that is left in the selection set.

 

That is crazy simple! When i saw this problem i didn't know how to go about to solve this.

Posted
3 hours ago, mhupp said:

if I'm understanding this

 

- Make selection set of polylines that are selected by user & have 4 vertices.

  - for each of those selected polylines find the bounding box points

   - create a temp 2nd selection set using those points

     - if only the polyline is selected keep else delete that polyline from the selection set.

- Select everything thing that is left in the selection set.

 

That is crazy simple! When i saw this problem i didn't know how to go about to solve this.

Very simple :)

Posted

Hi ronjonp,

 

Thank you for resolving my issue.

 

👍

Posted
12 hours ago, ronjonp said:

Very simple :)

 

I hope your not taking what i said as an insult. The word I should have used is elegant. The one thing I try to do when coding is to find the most efficient way to do things. That usually turns out to be the most simplistic way to doing things. I thought it was going to take alot more code to get what Juergen wanted. That's why I come to this forum to find stuff like this.

Posted
7 hours ago, mhupp said:

 

I hope your not taking what i said as an insult. The word I should have used is elegant. The one thing I try to do when coding is to find the most efficient way to do things. That usually turns out to be the most simplistic way to doing things. I thought it was going to take alot more code to get what Juergen wanted. That's why I come to this forum to find stuff like this.

Not at all .. glad you are studying the code and figuring out what it does. 👍 

I like simplicity as well! 🍻

Posted

It is better to use the co-ordinates of the pline rather than bounding box, compare a rectang at 45 angle may get stuff outside of rectang. Still use "WP" co-ords

 

image.png.282c2edb9430bfdda6147a543adc7e59.png

Posted
1 hour ago, BIGAL said:

It is better to use the co-ordinates of the pline rather than bounding box, compare a rectang at 45 angle may get stuff outside of rectang. Still use "WP" co-ords

 

image.png.282c2edb9430bfdda6147a543adc7e59.png

Sure. But sometimes you have to look at the example drawing. 😉

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