wimal Posted February 19, 2018 Posted February 19, 2018 How to identify the selected polyline is closed or not by LISP Quote
rkmcswain Posted February 19, 2018 Posted February 19, 2018 Here is one way to only select closed polylines (ssget '((0 . "POLYLINE,LWPOLYLINE")(-4 . "&")(70 . 1))) Quote
tombu Posted February 19, 2018 Posted February 19, 2018 Lisp to select a lwpolyline and see if it's closed: (vlax-curve-isClosed (car(entsel))) You could also use the function to test preselected entities as well. Quote
wimal Posted February 20, 2018 Author Posted February 20, 2018 Thanks everybody for your codes and quick replies. Quote
ronjonp Posted February 20, 2018 Posted February 20, 2018 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. 1 Quote
rkmcswain Posted February 20, 2018 Posted February 20, 2018 @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. Quote
ronjonp Posted February 20, 2018 Posted February 20, 2018 @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! Quote
Lee Mac Posted February 20, 2018 Posted February 20, 2018 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. Quote
Recommended Posts
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.