INDEFINITE MOUSE SELECTION

Discussion in 'AutoCAD' started by MiD-AwE, Jan 11, 2005.

  1. MiD-AwE

    MiD-AwE Guest

    I need to allow the user to select an undefined number of boundaries before a LISP can continue. I've used PAUSE but that only works if I can define the number of mouse clicks it will take to select all necessary boundaries which cannot be defined. How can I tell the LISP to allow the user to continue selecting boundaries until the user presses the enter key before continuing the routine? thanks.
     
    MiD-AwE, Jan 11, 2005
    #1
  2. MiD-AwE

    T.Willey Guest

    (setvar "errno" 0)
    (while (/= (getvar "errno") 52)
    <do what you want.>
    )

    Tim
     
    T.Willey, Jan 11, 2005
    #2
  3. MiD-AwE

    TCEBob Guest

    .. . .
    (command "pline") ;make a closed pline
    (while (= (logand (getvar "cmdactive") 1) 1) (command pause))
    .. . .

    rs
     
    TCEBob, Jan 11, 2005
    #3
  4. MiD-AwE

    Jeff Mishler Guest

    Use (ssget) to get the objects. It will continue until the user hits
    enter......, if using in a (command) sequence, get the ss prior to running
    the command such as:
    (prompt "\nSelect boundaries: ")
    (setq ss (ssget))
    (command "your_command" ss ......)
     
    Jeff Mishler, Jan 11, 2005
    #4
  5. MiD-AwE

    TCEBob Guest

    Jeff, native commands will behave with selection sets. But many vertical addins
    and express tool routines are not so gracious and demand points or windows.
    Some, you can fool them by getting the sset and immediately calling the routine,
    entering P, not the selection set variable name.

    rs
     
    TCEBob, Jan 11, 2005
    #5
  6. MiD-AwE

    MiD-AwE Guest

    I' having difficulty implementing your suggested method to my LISP. Could you please help?

    Here is my code:

    (DEFUN C:HP ()
    (COMMAND "LAYER" "S" "RESIDENCE" "" "COLOR" "2" "HATCH" "SOLID" <need to allow indefinite selection here>)
    (COMMAND "COLOR" "ByLayer")
    (COMMAND "ERASE" "P" "" "REDRAW")
    )

    Thanks to anyone that can help with this.
     
    MiD-AwE, Jan 12, 2005
    #6
  7. MiD-AwE

    TCEBob Guest

    I think you are packing too much into a single (command). If you break it up you
    will have an opportunity to debug each separate command. Example:

    (defun longpause( / ) ;wait for multiple user input.
    (while (= (logand (getvar "cmdactive") 1) 1) (command pause))
    )

    (command "layer" "s" "Residence" "c" "2" "" "") ;note the closing ""s.
    (princ "\nSelect items to hatch solid: ") ;need to prompt user
    (command "hatch" "solid" (longpause))
    .. . . .

    This assumes that you are trying to set layer Residence AND change its color to
    yellow. Your code is ambiguous, you might be trying to set the layer and then
    set the operating color to yellow. In which case you would say:
    (command "layer" "s" "Residence" "")
    (command "color" "2")

    Can't help a couple minor suggestions: 1. Use lower case in lisp code; it's much
    easier on the eyes. 2. End every c: function with (princ) to suppress unwanted
    command line output. 3. Make your "first cut" routine as elementary as
    possible -- use a lot of setqs and break down (command) as I mentioned. Then
    when it all works you can kill intermediate steps and variables.

    rs
     
    TCEBob, Jan 13, 2005
    #7
  8. No, the code is not ambiguous about the layer and color stuff. The "" in
    their original clearly ends the Layer command, and the "Color" is the
    command, not the option in Layer. That's why there's a Color command again
    later, to reset it. There are other ways to do this, of course (e.g., don't
    use the Color command but use CHPROP or CHANGE on the object afterwards),
    but there's nothing wrong with that part of their code.

    [And for what it's worth, I don't object to upper case code; in fact I find
    it easier to read -- you can more easily tell a 1 from an L, for example. I
    happen to like using upper case for AutoCAD command names and system
    variables, and lower case for most other things. To each his or her own.]

    As for the indefinite object selection, the SELECT command might do what's
    wanted, if you can select the hatch boundary object(s) prior to invoking the
    Hatch command:

    (command "select" pause "hatch" "s" "p" "")

    lets you pick any number of objects by any selection means you like,
    including the Remove and Multiple options, with just the one pause, before
    going on to the hatch command. You could add a prompt line if you want to
    "match" the way it looks within Hatch, but its prompt is on two lines, the
    second of which is just "Select objects:" anyway, just like the one for
    Select..
     
    Kent Cooper, AIA, Jan 13, 2005
    #8
  9. MiD-AwE

    MiD-AwE Guest

    Thank you all,

    I'm sure that I have enough information to rethink how I write commands now. Some great suggestions here! Thanks again.
     
    MiD-AwE, Jan 13, 2005
    #9
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.