Grip Sensitive Lisp??

Discussion in 'AutoCAD' started by Mark Ingram, Feb 13, 2004.

  1. Mark Ingram

    Mark Ingram Guest

    Hello,

    How would I make the following example sensitive to an object already
    gripped?

    (defun c:R ()
    (if (setq ENT (entsel "\nPick obj to rotate:"))
    (command ".rotate" ENT "" pause pause)
    )
    (princ)
    )

    Thank you very much,
    Mark
     
    Mark Ingram, Feb 13, 2004
    #1
  2. Have you looked at (ssgetfirst)?
     
    Allen Johnson, Feb 13, 2004
    #2
  3. You might also look at (ssget "I")
     
    Allen Johnson, Feb 13, 2004
    #3
  4. You need to check the implied selection set.

    (defun C:R (/ ss)
    (cond ((setq ss (ssget "I")))
    ((setq ss (ssget))))
    (cond (ss (command ".rotate" ss "" pause pause)))
    (princ))

    Note that I changed your initial selection method from (entsel) to (ssget),
    as an implied selection set can have more than one object. Due to that, the
    user might be confused as to why they can only select one object sometimes,
    but other times rotate many objects.

    If you *want* single object rotation, post back if you cannot figure out how
    to do it with the implied selection set.


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    Hello,

    How would I make the following example sensitive to an object already
    gripped?

    (defun c:R ()
    (if (setq ENT (entsel "\nPick obj to rotate:"))
    (command ".rotate" ENT "" pause pause)
    )
    (princ)
    )

    Thank you very much,
    Mark
     
    R. Robert Bell, Feb 13, 2004
    #4
  5. Mark Ingram

    Rudy Tovar Guest

    ssgetfirst?
     
    Rudy Tovar, Feb 13, 2004
    #5
  6. You can use (ssget) to get the currently selected objects,
    or prompt for a selection if nothing is currently selected.

    However, regarding this code from another post:

    (cond ((setq ss (ssget "I")))
    ((setq ss (ssget))))

    The above is entirely pointless, because that is exactly
    what the _first_ call to the (ssget) function from your C:
    function is doing internally (it returns objects currently
    selected, or it prompts for a selection if there are no
    currently objects selected).

    So, you just use (ssget) and it will either prompt for a
    selection set or return the current selection set. If you
    want to limit the selection to a single object, then you
    can use the ":s" option to (ssget):

    (setq ss (ssget ":S")) ; Allow only a single object

    The caveat with :S is if there are currently multiple objects
    selected, then all of them will be selected. The ":S" option
    only works when there are no currently selected objects. If
    you really want to limit the selection to a single object,
    you can check the length of the resulting selection set, then
    reject it:

    (if (and (setq ss (ssget ":i"))
    (> (sslength ss) 1)
    )
    (setq ss (ssget ":i"))
    )

    (if ss
    (progn
    (setq ent (ssname ss 0))
    (command ".rotate" ENT "" pause pause)
    )
    )

    The major difference between this and your original version
    is that this does not offer a prompt for the entity ("Pick
    Obj to rotate")



    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Feb 13, 2004
    #6
  7. Mark Ingram

    Mark Ingram Guest

    Thank you all very much, this will get me going.

    Have a great weekend,
    Mark
     
    Mark Ingram, Feb 13, 2004
    #7
  8. Oops.... the ":i" in the code example posted is wrong,
    It should be ":S" instead:

    (if (and (setq ss (ssget ":S"))
    (> (sslength ss) 1)
    )
    (setq ss (ssget ":S"))
    )

    (if ss
    (progn
    (setq ent (ssname ss 0))
    (command ".rotate" ENT "" pause pause)
    )
    )




    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Feb 13, 2004
    #8
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.