+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Senior Member
    Discipline
    Construction
    wimal's Discipline Details
    Occupation
    cadoperator
    Discipline
    Construction
    Using
    AutoCAD 2016
    Join Date
    Oct 2011
    Location
    sri lanka
    Posts
    488

    Default Filter to line list angle 90

    Registered forum members do not see this ad.

    Code:
    (setq lineset (ssget"C"pt1 pt2  '((0 . "LINE") (8 . "Layer1")))); lines on laye1
    How can filter lines in layer1 and angle 90

  2. #2
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,177

    Default

    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.

    Code:
    (vl-some '(lambda (ang)
                (equal ang (* pi 0.5) 1e-4)
              )
             (list (angle p1 p2) (angle p2 p1))
    )
    Good luck.

  3. #3
    Senior Member
    Discipline
    Construction
    wimal's Discipline Details
    Occupation
    cadoperator
    Discipline
    Construction
    Using
    AutoCAD 2016
    Join Date
    Oct 2011
    Location
    sri lanka
    Posts
    488

    Default

    Quote Originally Posted by Tharwat View Post
    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.

    Code:
    (vl-some '(lambda (ang)
                (equal ang (* pi 0.5) 1e-4)
              )
             (list (angle p1 p2) (angle p2 p1))
    )
    Good luck.
    Thanks Mr. Tharwat.

  4. #4
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,177

    Default

    Quote Originally Posted by wimal View Post
    Thanks Mr. Tharwat.
    You're welcome anytime wimal.

  5. #5
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    835

    Default

    Quote Originally Posted by Tharwat View Post
    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.

    Code:
    (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:
    Code:
    (eq (rem angle pi) (/ pi 2.))

  6. #6
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,177

    Default

    Quote Originally Posted by ronjonp View Post
    FWIW .. you could simplify to this:
    Code:
    (eq (rem angle pi) (/ pi 2.))
    Nice approach ronjonp.

  7. #7
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    835

    Default

    Quote Originally Posted by Tharwat View Post
    Nice approach ronjonp.
    Cheers!!

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,531

    Default

    Registered forum members do not see this ad.

    Not sure whether OP wants to test for +/- pi/2 or multiples of pi/2, but for the former you could use:
    Code:
    (equal 0 (cos <angle>) 1e-8)
    And for the latter:
    Code:
    (or (equal 0 (cos <angle>) 1e-8) (equal 1 (cos <angle>) 1e-8))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Define DIMRADIUS dimension line angle (not text angle)
    By ng80092a in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 8
    Last Post: 17th May 2017, 05:43 am
  2. Filter List - Variables
    By abra-CAD-abra in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 7th Nov 2016, 11:40 pm
  3. Filter a Layer List for List Box
    By waders in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 20th Sep 2012, 01:22 am
  4. Filter Device list
    By Small Fish in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 9th Jun 2010, 11:22 am
  5. Replies: 0
    Last Post: 2nd Nov 2006, 11:51 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts