Jump to content

Filter to line list angle 90


wimal

Recommended Posts

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

How can filter lines in layer1 and angle 90

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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