Jump to content
wimal

Filter to line list angle 90

Recommended Posts

wimal

(setq lineset (ssget"C"pt1 pt2  '((0 . "LINE") (8 . "Layer1")))); lines on laye1

How can filter lines in layer1 and angle 90

Share this post


Link to post
Share on other sites
Tharwat

Hi,

 

You need to iterate through each line entity name from the selection set then get the start and end coordinates and assign them to variable names 'p1' and 'p2' and the following codes would return T if the angle of line is equal to 90.0 Degs.

 

(vl-some '(lambda (ang)
           (equal ang (* pi 0.5) 1e-4)
         )
        (list (angle p1 p2) (angle p2 p1))
)

 

Good luck.

Share this post


Link to post
Share on other sites
wimal
Hi,

 

You need to iterate through each line entity name from the selection set then get the start and end coordinates and assign them to variable names 'p1' and 'p2' and the following codes would return T if the angle of line is equal to 90.0 Degs.

 

(vl-some '(lambda (ang)
           (equal ang (* pi 0.5) 1e-4)
         )
        (list (angle p1 p2) (angle p2 p1))
)

 

Good luck.

 

Thanks Mr. Tharwat.

Share this post


Link to post
Share on other sites
Tharwat
Thanks Mr. Tharwat.

 

You're welcome anytime wimal.

Share this post


Link to post
Share on other sites
ronjonp
Hi,

 

You need to iterate through each line entity name from the selection set then get the start and end coordinates and assign them to variable names 'p1' and 'p2' and the following codes would return T if the angle of line is equal to 90.0 Degs.

 

(vl-some '(lambda (ang)
           (equal ang (* pi 0.5) 1e-4)
         )
        (list (angle p1 p2) (angle p2 p1))
)

 

Good luck.

 

FWIW .. you could simplify to this:

(eq (rem angle pi) (/ pi 2.))

Share this post


Link to post
Share on other sites
Tharwat
FWIW .. you could simplify to this:

(eq (rem angle pi) (/ pi 2.))

 

Nice approach ronjonp.

Share this post


Link to post
Share on other sites
ronjonp
Nice approach ronjonp.

Cheers!! :)

Share this post


Link to post
Share on other sites
Lee Mac

Not sure whether OP wants to test for +/- pi/2 or multiples of pi/2, but for the former you could use:

(equal 0 (cos <angle>) 1e-

And for the latter:

(or (equal 0 (cos <angle>) 1e- (equal 1 (cos <angle>) 1e-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×