Check to see if polyline is closed.

Discussion in 'AutoCAD' started by Casey, Aug 15, 2003.

  1. Casey

    Casey Guest

    Is there a dxf code that indicates wether a polyline is closed or not? If
    not... how would one go about checking this?

    Thanks,

    Casey
     
    Casey, Aug 15, 2003
    #1
  2. Casey

    R.K. McSwain Guest

    Wouldn't this work just as good?

    (defun isclosed (ent)
    (= 1 (logand 1 (cdr (assoc 70 (entget ent)))))
    )

    I'm not saying one or the other is right or wrong, only this saves a few keystrokes.

    ----------------------
     
    R.K. McSwain, Aug 15, 2003
    #2
  3. Casey

    Casey Guest

    Do i have to use the logand function (not exactly sure how it works)...
    Isn't dxf code 70 equal to 0 for an open pline and 1 for a closed?

    just checkin.


    Thanks,
     
    Casey, Aug 15, 2003
    #3
  4. Yes, you must use (logand) as bit 128 could be set as well.
     
    Jason Piercey, Aug 15, 2003
    #4
  5. Casey

    Fatfreek Guest

    I'm looking at a drawing right now that has closed polylines with (70 .
    129) for group codes. Then I checked one of my little selection routines
    and it includes the 129 value as an OR to the 1. Am I missing something on
    this thread?

    (setq PolyOne (ssget ":s"
    '((0 . "LWPOLYLINE")
    (-4 . "<OR")
    (70 . 1)
    (70 . 129)
    (-4 . "OR>")
    )
    )
    )

    Len
     
    Fatfreek, Aug 18, 2003
    #5
  6. Casey

    Paul Turvill Guest

    You could simplify it to
    (setq PolyOne (ssget ":S" '((-4 . "&")(70 . 1))))
    ___
     
    Paul Turvill, Aug 18, 2003
    #6
  7. Casey

    R.K. McSwain Guest

    Yours is fine if you are trying to return a selection set.
    I think the OP was looking for a function that returns T or nil.
     
    R.K. McSwain, Aug 18, 2003
    #7
  8. Casey

    Fatfreek Guest

    Hmmm ... looks slick. Ummm ... no 129 needed?

    Len
     
    Fatfreek, Aug 18, 2003
    #8
  9. Casey

    Paul Turvill Guest

    No, since all you're interested in is the "1" value. The bitwise and filter
    ("&") will tell you if that bit is set in any bitmapped value.
    ___
     
    Paul Turvill, Aug 18, 2003
    #9
  10. Casey

    Fatfreek Guest

    Thank you.

    Len
     
    Fatfreek, Aug 18, 2003
    #10
  11. Casey

    BTO Guest

    thx everybody, many years i had this error on some routines (but never saw
    in fact no, because i used :
    (setq Ferme (cdr (assoc 70 (entget Nom_Entite ))))
    .....
    ......
    (if (/= (- (/ Ferme 2.0 ) (/ Ferme 2 )) 0.0 ) ........

    I did not know logand, when i wrote these old lisp.

    Bruno Toniutti
    (sorry for my english level)
     
    BTO, Aug 26, 2003
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.