Jump to content

Until enter pressed ?


chavlji

Recommended Posts

I would like to make a "Multiple" kind of command that would be continuously asking user to "Pick object", change it and ask for another one. Until user would hit "Enter" or "Space" (or esc of course, but this is not the point here).

 

Something like this:

(while (setq SS (ssget)) (ChangeObj SS) )

 

But this code exits even if user tryed to select something but he clicked on empty area -> Selection was NIL. And I don't want that.

 

Trim command works like I would like it to work:

It prompts user to select an edge to cut.

Even if user clicks on empty area it asks user to select an edge again.

Until user hits "Enter", "Space" or "Esc".

 

How to do that?

Link to comment
Share on other sites

Im not a lisp expert, but what you want can be done. I have a multi fillet command that works like what your asking for. Maybe this will give you some insight

(DEFUN C:MFILT ()
 (setvar "filletrad" 0.125)
 (SETQ A (ENTSEL "\nPick Master Line: ")
B (ENTSEL "\nPick Secondary Line: ")
 )
 (COMMAND "FILLET" A B)
 (WHILE B
   (SETQ B (ENTSEL "\nPick Secondary Line: "))
   (COMMAND "FILLET" A B)
 )
)

Link to comment
Share on other sites

I would like to make a "Multiple" kind of command that would be continuously asking user to "Pick object", change it and ask for another one. Until user would hit "Enter" or "Space" (or esc of course, but this is not the point here).

 

Something like this:

(while (setq SS (ssget)) (ChangeObj SS) )

But this code exits even if user tryed to select something but he clicked on empty area -> Selection was NIL. And I don't want that.

 

Trim command works like I would like it to work:

It prompts user to select an edge to cut.

Even if user clicks on empty area it asks user to select an edge again.

Until user hits "Enter", "Space" or "Esc".

 

How to do that?

 

 

ssget will not exit until you right click or select something.

if you are looking for single selection style, this will work:

(setvar "errno" 0)
(while (and (/= (getvar "errno") 52)
           (not Ent)
           )
 (setq Ent (entsel "\nSelect some stuff: "))
 (princ "\nMissed, try again.")
 )

Link to comment
Share on other sites

If you really wanted a multiple selection, but your function used single ents:

 

maybe

 

(setvar "errno" 0)
(while (and (/= (getvar "errno") 52)
       (not ss))
 (setq ss (ssget)))
(mapcar    'ChangeObj
 (vl-remove-if 'listp
   (mapcar 'cadr (ssnamex ss))))

 

PS, Alan, would you happen to have any information on the "errno" variable? I have never really used it and would like to learn more :)

 

Cheers

 

Lee

Link to comment
Share on other sites

Lee,

 

Here is what I have on errno. It's reliablity has been suspect over the years. Maybe that has changed some. Also, it is an associative list, not a bit flag.

 

 

  (setq err_list '(
        ( 1 . "Invalid symbol table name")
        ( 2 . "Invalid entry or selection set name")
        ( 3 . "Exceeded maximum number of selection sets")
        ( 4 . "Invalid selection set")
        ( 5 . "Improper use of of block definition")
        ( 6 . "Improper use of block definition")
        ( 7 . "Object selection: pick failed")
        ( 8 . "End of entity file")
        ( 9 . "End of block definition file")
        (10 . "Failed to find last entity")
        (11 . "Illegal attempt to delete viewport object")
        (12 . "Operation not allowed during PLINE")
        (13 . "Invalid handle")
        (14 . "handles not enabled")
        (15 . "Invalid arguments in coordinate transform request" )
        (16 . "Invalid space in coordinate transform request")
        (17 . "Invalid use of deleted entity")
        (18 . "Invalid table name")
        (19 . "Invalid table function argument")
        (20 . "Attempt to set read-only variable")
        (21 . "Zero value not allowed")
        (22 . "Value out of range")
        (23 . "Complex REGEN in progress")
        (24 . "Attempt to change entity")
        (25 . "Bad layer name")
        (26 . "Bad linetype name")
        (27 . "Bad color name")
        (28 . "Bad text style name")
        (29 . "Bad shape name")
        (30 . "Bad field for entity type")
        (31 . "Attempt to modify deleted entity")
        (32 . "Attempt to modify seqend subentity")
        (33 . "Attempt to change handle")
        (34 . "Attempt to modify viewport visibility")
        (35 . "Entity on locked layer")
        (36 . "Bad entity type")
        (37 . "Bad polyline type")
        (38 . "Incomplete complex entity in block")
        (39 . "Invalid block name field")
        (40 . "Duplicate block flag fields")
        (41 . "Duplicate block name fields")
        (42 . "Bad normal vector")
        (43 . "Missing block name")
        (44 . "Missing block flags")
        (45 . "Invalid anonymous block")
        (46 . "Invalid block definition")
        (47 . "Mandatory field missing")
        (48 . "Unrecognized extended XDATA type")
        (49 . "Improper nesting of list in XDATA")
        (50 . "Improper location of APPID field")
        (51 . "Exceeded maximum XDATA size")
        (52 . "Entity selection: null response")
        (53 . "Duplicate APPID")
        (54 . "Attempt to make or modify viewport entity")
        (55 . "Attempt to make or modify an xref, xdef, or xdep")
        (56 . "ssget filter: unexpected end of list")
        (57 . "ssget filter: missing test operand")
        (58 . "ssget filter: invalid opcode (-4) string")
        (59 . "ssget filter: improper nesting or empty conditional clause")
        (60 . "ssget filter: mismatched begin and end of conditional clause")
        (61 . "ssget filter: wrong number of arguments in conditional clause (for NOT or XOR)")
        (62 . "ssget filter: exceeded maximum nesting limit")
        (63 . "ssget filter: invalid group code")
        (64 . "ssget filter: invalid string test")
        (65 . "ssget filter: invalid vector test")
        (66 . "ssget filter: invalid real test")
        (67 . "ssget filter: invalid integer test")
        (68 . "Digitizer isn't a tablet")
        (69 . "Tablet is not calibrated")
        (70 . "Invalid arguments")
        (71 . "ADS error: Unable to allocate new result buffer")
        (72 . "ADS error: Null pointer detected")
        (73 . "Can't open executable file")
        (74 . "Application is already loaded")
        (75 . "Maximum number of applications already loaded")
        (76 . "Unable to execute application")
        (77 . "Incompatible version number")
        (78 . "Unable to unload nested application")
        (79 . "Application refused to unload")
        (80 . "Application is not currently loaded")
        (81 . "Not enough memory to load application")
        (82 . "ADS error: Invalid transformation matrix")
        (83 . "ADS error: Invalid symbol name")
        (84 . "ADS error: Invalid symbol value")
        (85 . "AutoLISP/ADS operation prohibited while a dialog box was displayed")))

-David

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...