Jump to content

The polyline closed or not


wimal

Recommended Posts

Here is one way to only select closed polylines

 

(ssget '((0 . "POLYLINE,LWPOLYLINE")(-4 . "&")(70 . 1)))

FWIW, you also need to check for:

(ssget '((0 . "lwpolyline") (-4 . "<OR") (70 . 1) [b](70 . 129)[/b] (-4 . "OR>")))

When PLINEGEN is set to 1.

  • Like 1
Link to comment
Share on other sites

@ronjonp - did you try it?

 

The [&] is a Bitwise AND operator. To determine if the polyline is closed, you are looking for the presence of the "1" bit in the dxf70 code, not just the two values "1" and "129".

 

So the code I posted works on both heavy and lightweight polylines, regardless of the setting of PLINEGEN, whether or not it is a 3D polyline, spline fit, curve fit, etc.

 

Your code will only select lightweight closed polylines. It ignores closed heavy polylines, closed 3D polylines, closed spline fit/curve fit polylines, etc.

Link to comment
Share on other sites

@ronjonp - did you try it?

 

The [&] is a Bitwise AND operator. To determine if the polyline is closed, you are looking for the presence of the "1" bit in the dxf70 code, not just the two values "1" and "129".

 

So the code I posted works on both heavy and lightweight polylines, regardless of the setting of PLINEGEN, whether or not it is a 3D polyline, spline fit, curve fit, etc.

 

Your code will only select lightweight closed polylines. It ignores closed heavy polylines, closed 3D polylines, closed spline fit/curve fit polylines, etc.

 

Thanks for the reply I did not know that! :)

Link to comment
Share on other sites

For what it's worth, when matching a single bit-code (such as 1=Closed), I would be inclined to use the bitwise masked equals operator ("&=") which behaves the same as (= (logand )); though this is just syntactic sugar, as both bitwise operators will perform equally well in this case.

 

This post may help to explain the difference between the two bitwise operators ("&" and "&="), I also provide some examples in my reference here.

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