.GetEntity doesn't accept keywords?

Discussion in 'AutoCAD' started by Jeff Mishler, Apr 1, 2005.

  1. Jeff Mishler

    Jeff Mishler Guest

    Well, the way I see these situations is like this:

    If the user is bothered by the sequence you have provided, they will adapt
    to the way it is written.

    Otherwise they don't care

    Or they are really slow learners and deserve to do things twice....and I
    doubt that this is the only thing they do twice in a day's work ;-)
     
    Jeff Mishler, Apr 1, 2005
    #1
  2. Jeff Mishler

    Mark Propst Guest

    For a little routine to create dimstyles
    I want to allow the user to select a viewport or enter a scale factor at the
    command line

    the line to allow selection of the viewport is like

    oDoc.Utility.GetEntity opvp, vpt, "Pick viewport or <enter> to specify
    dimscale "

    so if they select a viewport, i read the scale factor and create style
    accordingly.

    If they hit enter, I trap the error and present the next prompt

    dReturnDimScale = oDoc.Utility.GetReal("Please enter dimscale: ")

    however, if they don't bother to read the prompts (very likely) they may
    enter the dimscale
    at the getentity line above

    this acts the same as an enter
    (throws the error "Method 'GetEntity' of object 'IAcadUtility' failed")
    but i can't find a difference between
    1) entering a value and then an enter
    or
    2) just an enter

    what I want to know is if there is a way to detect what was entered at the
    command line
    before hitting the enterkey or spacebar

    according to the docs,
    ..GetEntity does not accept keywords
    so I don't know of a way to get the value they already put in at the command
    line
    when they were just supposed to hit the enter key (and put the value in the
    next prompt line.)

    do i have to trap all keystrokes some how and save the most recent
    so that if they put a value on the command line and it was a valid numeric
    value i don't have
    to re-prompt them for the scale factor,
    but if they just hit enter (like they're supposed to) then I give the next
    prompt.

    Actually it would be cleaner if they didn't have to hit enter and then enter
    the value and hit
    enter a second time.

    so the question becomes
    how can I have a line like
    oDoc.Utility.GetEntity opvp, vpt, "Pick viewport or specify dimscale "
    and have it either get the selection or read the input?
    (it seems like InitializeUserInput isn't going to help with a .getEntity
    call)
    from the help:
    The user-input methods that can accept keywords are: GetKeyword, GetInteger,
    GetReal, GetDistance, GetAngle, GetOrientation, GetPoint, and GetCorner.

    but maybe i'm misreading something

    or one could use initializeuserinput and create a keyword list of all valid
    scale factors
    (seems like really bad idea) then use .getpoint to get a point then use the
    point to get a selection set to get the entity
    (seems like a really really bad idea)

    it's no big deal, it works ok as it is, it's just if they don't read the
    prompt and enter a value and then an enter then I reprompt them and they
    have to enter a value again it is double work for them. :)


    any thoughts appreciated
    :)
    tia
    Mark
     
    Mark Propst, Apr 1, 2005
    #2
  3. This might work.

    If ThisDrawing.GetVariable("LASTPROMPT") = "Command: Pick viewport or <enter> to specify dimscale" Then

    Regards - Nathan
     
    Nathan Taylor, Apr 1, 2005
    #3
  4. Jeff Mishler

    Mark Propst Guest

    Hi Jeff,
    True enough.
    In my case, I sure don't want to imply I work with bad or lazy users.
    That's not the case at all. We're a very small company here and everyone is
    great, smart and tries their hardest. But it happened once with this
    routine, (which has only just been put on the server recently), that a user
    didn't see the enter part (to get to the next prompt) and just put in the
    scale factor, so my first response was, well the user didn't follow
    directions....
    However on further reflection I realized that that's a much more intuitive
    way for it to work anyway.
    If I could overcome my limitation of not knowing how to do it, then a user
    is free to use it either way.
    (granted, saving one keystroke is only a small improvement)
    but it still would seem nicer to be able to either pick a viewport or enter
    a value in one response eh?

    Thanks as always for your input.
    Mark
     
    Mark Propst, Apr 1, 2005
    #4
  5. Do a search for GetXX, download it and incorporate it. It works around the
    limitations of the vanilla GetX methods, and, if I remember correctly,
    it'll handle your situation.

    On our side topic here, being a full time developer I've run across many
    poor, bad, lazy and just plain stupid users. While many times I would have
    loved to cram my solution down their throats, that doesn't gain you any
    notoriety or respect. If they see you are trying to accomodate them, it
    makes the whole process easier and easier. Plus, you don't learn anything
    either if you don't try to get around an issue such as this.

    There's also the fact that no matter how clear and streamlined a coder's
    gui design is, no one else ever sees it that way - but we won't go into
    that ;-)

    -- Mike
    ___________________________
    Mike Tuersley
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Apr 1, 2005
    #5
  6. Jeff Mishler

    Jürg Menzi Guest

    Hi Mark

    In opposite to the help, GetEntity accepts keywords:
    Code:
    Public Function MeExtEntSel(ByVal UsrPmt As String, ByVal KeyWrd As String, _
    RetVal As Variant, PicPnt As Variant) As Boolean
    
    Dim UtlObj As AcadUtility
    Dim CurEnt As AcadEntity
    
    On Error GoTo Err_Control
    
    MeExtEntSel = True
    Set UtlObj = ThisDrawing.Utility
    
    With UtlObj
    .InitializeUserInput 0, KeyWrd
    .GetEntity CurEnt, PicPnt, vbCrLf & UsrPmt
    End With
    
    Set RetVal = CurEnt
    
    Exit_Here:
    Exit Function
    
    Err_Control:
    Select Case Err.Number
    Case -2145320928
    Err.Clear
    RetVal = UtlObj.GetInput
    Case Else
    Err.Clear
    MeExtEntSel = False
    End Select
    
    End Function
    Cheers
     
    Jürg Menzi, Apr 1, 2005
    #6
  7. Jeff Mishler

    fantum Guest

    GetEntity will accept keywords. It will not accept arbitrary input (Utility.InitializeUserInput 128). When a non-keyword alphabetic string is entered "*Invalid selection*" is displayed at the command line and the prompt is repeated. When a numeric string that can't be interpreted as a point is entered an error (&H80020009 (-2147352567) : Method 'GetEntity' of object 'IAcadUtility' failed.) is thrown. You can trap that error and parse the "LASTPROMPT" system variable to retrieve the numeric string if one was entered.
     
    fantum, Apr 1, 2005
    #7
  8. Jeff Mishler

    Mark Propst Guest

    Thanks very much.
    :)
    Mark
     
    Mark Propst, Apr 2, 2005
    #8
  9. Jeff Mishler

    Mark Propst Guest

    Awesome,
    Muchisimas Gracias.
    Danka (?)
    Thank you.
    Mark

     
    Mark Propst, Apr 2, 2005
    #9
  10. Jeff Mishler

    Mark Propst Guest

    Highly excellent.
    Thank you.
    That's funny I didn't even think to try it when the help didn't include it
    in its list.
    Duh!
    Thanks
    Mark

    (Utility.InitializeUserInput 128). When a non-keyword alphabetic string is
    entered "*Invalid selection*" is displayed at the command line and the
    prompt is repeated. When a numeric string that can't be interpreted as a
    point is entered an error (&H80020009 (-2147352567) : Method 'GetEntity' of
    object 'IAcadUtility' failed.) is thrown. You can trap that error and parse
    the "LASTPROMPT" system variable to retrieve the numeric string if one was
    entered.
     
    Mark Propst, Apr 2, 2005
    #10
  11. Jeff Mishler

    Jürg Menzi Guest

    Muchisimas Gracias.
    Alegre ayudarle...¦-)
    Glad to help you...¦-)

    My sample doesn't have a error handling for 'pick nothing', 'Enter', etc.
    Check the GetXXX functions (see Mike's answer) to get more information.

    Cheers
     
    Jürg Menzi, Apr 2, 2005
    #11
  12. Jeff Mishler

    MP Guest

    I've never used the lastprompt var before.
    It seems kinda weird here -
    I only get the last word or two returned
    eg
    " dimscale 12"
    (if 12 had been entered at the command line)

    Then I tried to look it up to see how it's supposed to work and I can find
    no topics in acad help
    (2004 here.)
    Is that an undocumented variable?
    so I'd have to get the last part of the string, test for numeric value and
    then use that -
    I'll look into that.
    Thanks
    Mark
     
    MP, Apr 4, 2005
    #12
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.