SendCommand...Yeah right.

Discussion in 'AutoCAD' started by joeynich, Jan 22, 2004.

  1. joeynich

    joeynich Guest

    I am having my program create a block and then insert it. It works fine, but the way I was doing it asked for a point and then a direction and it inserted the block fine. What I changed was that the block would create itself from 0,0 and then I use the sendcommand to insert the block so that I can see the block turn at any angle. That works fine also. Then I have it go into a loop until the user hits cancel or any button. That doesn't work. My question:
    How do I cancel out of a sendcommand using coding?
    I know the sendcommand waits for whatever to finish before it goes back to VBA coding. How do I get it to cancel from the sendcommand?
     
    joeynich, Jan 22, 2004
    #1
  2. joeynich

    Edward Bagby Guest

    Do not be too frustrated, if I get the gist of what you are saying, it is
    entirely possible. I'm having a difficult time following your description,
    however. The actual code would be worth 1000 words.

    I wouldn't use send command, first of all. I would use VBA commands. The
    ThisDrawing.Utility has a number of user input functions and with command
    line messages you can make it look like a real AutoCAD command.

    Edward



    but the way I was doing it asked for a point and then a direction and it
    inserted the block fine. What I changed was that the block would create
    itself from 0,0 and then I use the sendcommand to insert the block so that I
    can see the block turn at any angle. That works fine also. Then I have it go
    into a loop until the user hits cancel or any button. That doesn't work. My
    question:
    VBA coding. How do I get it to cancel from the sendcommand?
     
    Edward Bagby, Jan 22, 2004
    #2
  3. joeynich

    joeynich Guest

    I can do it VBA but then I can't see my block rotate. I just want to be able to insert a block from a point and the block rotating to pick the rotation point. Is this possible with VBA? If so, please share. Thanks.
     
    joeynich, Jan 22, 2004
    #3
  4. joeynich

    developer Guest

    If you can find out when the user hits escape or any other key, you can do a SendKeys {ESC} while you are running the SendCommand. I tested SendKeys while in the process of a SendCommand, and the command was cancelled as expected. I know SendKeys is not a programmer friendly function, but hey, if it works, why not use it?
     
    developer, Jan 22, 2004
    #4
  5. Look for and download GetXX.
    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Jan 22, 2004
    #5
  6. James Belshan, Jan 22, 2004
    #6
  7. joeynich

    developer Guest

    I've got some time this morning, so I'll try to produce some code for ya. The only problem I can see is how to find out if the user has pressed a key while the ghosting rotation is taking place. If anybody has an idea, please let us know. Otherwise, I have the code almost written already.
     
    developer, Jan 23, 2004
    #7
  8. joeynich

    joeynich Guest

    Thanks.
     
    joeynich, Jan 23, 2004
    #8
  9. joeynich

    developer Guest

    Well, here's what I've got. I thought there would at least be a Win API function to detect any keyboard input. With the limited research I've done, I found out there may not be any.
    Public Sub MyTest()
    Dim I As Integer
    Dim InsPt(0 To 2) As Double
    Dim KeyPressed As Boolean
    ThisDrawing.SetVariable "ORTHOMODE", 0
    ' set your insertion point values
    InsPt(0) = 1615
    InsPt(1) = 730
    ' start your loop
    For I = 1 To 10
    ' this insert command assumes X and Y scale factors = 1
    ThisDrawing.SendCommand "-INSERT" & vbCr & "LABELDWG" & _
    vbCr & InsPt(0) & "," & InsPt(1) & vbCr & vbCr & vbCr
    ' check here to see if the user pressed a key
    If KeyPressed Then
    SendKeys "{ESC}", True
    Exit For
    Else
    SendKeys "{ESC}", True
    End If
    Next I
    End Sub
    I hope this helps you.
     
    developer, Jan 23, 2004
    #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.