Looking for a little fish ....

Discussion in 'AutoCAD' started by Chip Harper, Jul 23, 2004.

  1. Chip Harper

    Chip Harper Guest

    Looking for a snip of code to replace this ....

    (while (null (setq PLSEL (entsel)))
    (princ "\nSelect Closed Polyline...")
    (princ)
    )

    I want to verify / limit selection to a closed polyline .... Thanks
     
    Chip Harper, Jul 23, 2004
    #1
  2. Chip Harper

    BillZ Guest

    (while (null (setq ent (SSGET "+.:E:S" (list '(0 .
    "POLYLINE,LWPOLYLINE")'(-4 . "&")'(70 . 1))))))


    Bill
     
    BillZ, Jul 23, 2004
    #2
  3. Chip Harper

    mnash Guest

    would this help:

    (defun c:test ()

    (prompt "\nSelect Closed Polyline...")
    (setq ent (car (entsel)))
    (setq VP (entget ent))
    (setq var (cdr (assoc 70 VP)))
    (if(= var 1)(do your command for the closed polyline)(enter your error))
    )

    hope this helps
     
    mnash, Jul 23, 2004
    #3
  4. Hi Chip,

    Look for a thread in this group titled "entsel help..."
    and post(s) by me. Might be more than what you
    need at this time, but is a good way to handle this
    type of user interface.
     
    Jason Piercey, Jul 23, 2004
    #4
  5. Chip Harper

    Jürg Menzi Guest

    Hi Chip

    Checks also for 3D-Polylines, 3DMesh and Pface. Allows the user to press
    'Enter' (returns nil).

    (defun SelPline ( / CurEnt EntFlg EntLst EntNme ExLoop)
    (while (not ExLoop)
    (initget " ")
    (setq CurEnt (entsel "\nSelect polyline: "))
    (cond
    ((= CurEnt "") (setq ExLoop T CurEnt nil))
    (CurEnt
    (setq EntLst (entget (car CurEnt))
    EntNme (cdr (assoc 0 EntLst))
    EntFlg (cdr (assoc 70 EntLst))
    )
    (cond
    ((or
    (not (member EntNme '("LWPOLYLINE" "POLYLINE")))
    (= (logand EntFlg 8) 8)
    (= (logand EntFlg 16) 16)
    (= (logand EntFlg 64) 64)
    )
    (princ "selected entity is not a Polyline. ")
    )
    ((/= (logand EntFlg 1) 1)
    (princ "selected Polyline is not closed. ")
    )
    ((setq ExLoop T))
    )
    )
    ((princ "1 selected, 0 found"))
    )
    )
    CurEnt
    )

    Cheers
     
    Jürg Menzi, Jul 23, 2004
    #5
  6. Chip Harper

    Chip Harper Guest

    Thanks Bill, mnash, Jason and Jurg. My table is covered in fresh fish. :)
     
    Chip Harper, Jul 23, 2004
    #6
  7. Chip Harper

    Jürg Menzi Guest

    Hi Chip

    Welcome, and good appetite...¦-)

    Cheers
     
    Jürg Menzi, Jul 23, 2004
    #7
  8. Chip Harper

    BTO Guest

    Hi,

    need to controle code 70 set to 1 but 129 too
    to control closed polyligne, here 6 methods :

    AFTER SELECTION :

    (if (= (logand 1 (cdr (assoc 70 (entget e_name )))) 1) "closed" "not
    cloded") ; 1ere methode

    or

    (setq object_name (vlax-ename->vla-object e_name ))
    (if (= (vlax-get-property object_name 'Closed) ':vlax-true) "closed" "not
    cloded") ; 2eme methode
    or
    (if (= (vla-get-closed object_name ) ':vlax-true) "closed" "not cloded") ;
    3eme methode
    or
    (if (= (vlax-get object_name 'Closed) 0) "not cloded" "closed" ) ; 4eme
    methode
    or
    (if (= (vlax-curve-isClosed object_name ) T ) "closed" "not cloded" ); 5eme
    methode

    or

    DURING SELECTION :

    (ssget (list (cons 0 "*polyline")'(-4 . "<OR")'(70 . 1)'(70 . 129)'(-4 .
    "OR>"))); 6eme methode



    Bruno Toniutti
     
    BTO, Jul 30, 2004
    #8
  9. Chip Harper

    Paul Turvill Guest

    (ssget '((0 . "*POLYLINE")(-4 . "&")(70 . 1)))
    works as well, and will detect the "1" bit in other values, such as 65, 33,
    etc.
    ___
     
    Paul Turvill, Jul 30, 2004
    #9
  10. Chip Harper

    BTO Guest

    Paul,
    thanks, your comment is necessary and welcome


    but, depends what Chip Harper wants,
    (ssget '((0 . "*POLYLINE")(-4 . "&")(70 . 1))) selects all closed
    *polylignes but this will crash many routines, because you get 3D mesh
    etc...

    I prefer to consider classical answer :
    (if (= (logand 1 (cdr (assoc 70 (entget e_name )))) 1) "closed" "not
    closed")
    as a trap for many routines

    I think :
    (ssget '((0 . "*polyline" )(-4 . "<OR")(70 . 1)(70 . 129)(-4 . "OR>")))
    is best way to avoid traps and to work with "classical" polylines, isn't it
    ?

    Bruno Toniutti
    (sorry for my english level)
     
    BTO, Aug 2, 2004
    #10
  11. Chip Harper

    Jürg Menzi Guest

    Hi Bruno
    No... the correct filter must be:
    Code:
    '(
    (0 . "POLYLINE,LWPOLYLINE")	;avod selection of customer objects
    (-4 . "&") (70 . 1)
    (-4 . "<NOT")
    (-4 . "<OR")
    (-4 . "&") (70 . 8)	;3D-Polyline
    (-4 . "&") (70 . 16)	;3DMesh
    (-4 . "&") (70 . 64)	;Pface
    (-4 . "OR>")
    (-4 . "NOT>")
    )
    
    Cheers
     
    Jürg Menzi, Aug 2, 2004
    #11
  12. Chip Harper

    BTO Guest

    Hi Juerg
    (0 . "*POLYLINE") was a step, for me today a good back step is :
    (0 . "POLYLINE,LWPOLYLINE")

    thx
    yes if he wants "Fit and Spline"

    just curious, why you don't add (-4 . "&") (70 . 32) ?

    important point to keep in mind : with "polyline" there are different kinds
    of entities.

    have a nice day
    Bruno Toniutti.
     
    BTO, Aug 2, 2004
    #12
  13. Chip Harper

    Jürg Menzi Guest

    Hi Bruno

    Welcome...¦-)
    If not, the filter has to be changed like this:
    Code:
    '(
    (0 . "POLYLINE,LWPOLYLINE")   ;avoid selection of customer objects
    (-4 . "&") (70 . 1)
    (-4 . "<NOT")
    (-4 . "<OR")
    (-4 . "&") (70 . 2) 	;Curve-fit vertices
    (-4 . "&") (70 . 4) 	;Spline-fit vertices
    (-4 . "&") (70 . 8) 	;3D-Polyline
    (-4 . "&") (70 . 16)        ;3DMesh
    (-4 . "&") (70 . 64)        ;Pface
    (-4 . "OR>")
    (-4 . "NOT>")
    )
    
    Flag 32 is only present if Flag 16 is set (from help):
    32= The polygon mesh is closed in the N direction

    Cheers
     
    Jürg Menzi, Aug 2, 2004
    #13
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.