Author Topic: Lost ability to use AutoCAD icons whilst trying to get a PromptPointResult  (Read 3551 times)

0 Members and 1 Guest are viewing this topic.

Grishe

  • Guest
Hi there...

I recently found this forum in a post from the Autodesk .NET one... Can't belive i've only just found out about it!

I wander if anyone has had a problem with zooming and panning using the AutoCAD icons (i.e. not the wheelie ball mouse)... Whilst trying to get say a simple point location from the user??? 

If i attach the code to a toolbar created so...

Dim Tb As Autodesk.AutoCAD.Interop.AcadToolbar = acadApp.MenuGroups.Item(0).Toolbars.Add("A Tool Bar")

Dim tbBut0 As Autodesk.AutoCAD.Interop.AcadToolbarItem = PenMapTb.AddToolbarButton(0, "Pick a point", "Pick a point", "_PickaPoint ")
tbBut0.SetBitmaps("PICK.bmp", "PICK.bmp")

Tb.Dock(Autodesk.AutoCAD.Interop.Common.AcToolbarDockStatus.acToolbarDockLeft)[/color][/color]

... Where pickapoint is called such...

 <CommandMethod("PickaPoint")> _
Public Sub ShowKeyboard()
    QueryLocation
End Sub

...and QueryLocation looks like...

Public Sub QueryLocation()
            Dim ed As Autodesk.AutoCAD.EditorInput.Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
            Dim RP As New Autodesk.AutoCAD.EditorInput.PromptPointOptions("Pick Point" & vbCrLf)
            Dim ResPt As Autodesk.AutoCAD.EditorInput.PromptPointResult
            Dim Doc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim Abort As Boolean

            RP.AllowNone = True
         
            Try


                Do Until Abort

                    ResPt = ed.GetPoint(RP)


                    Select Case ResPt.Status

                        Case PromptStatus.OK
                            Dim QueryLocation As New AICpoint3D(ResPt.Value.X, ResPt.Value.Y, ResPt.Value.Z) 'send the location back
                            Abort = True

                        Case PromptStatus.Keyword
                            'Dim command As String = ResPt.StringResult.Substring(2)
                            Doc.SendStringToExecute("_PAN",True, False, True)
                            'Dim Ret As Integer = aced.Invoke("command", "_.pan")

                        Case PromptStatus.Cancel
                            Abort = True

                        Case PromptStatus.Error
                            Abort = True

                    End Select

                Loop

            Catch ex As Exception
                MsgBox("Error getting location: " & ex.Message & vbCrLf & ex.StackTrace)
            End Try

       
        End Sub

Everything works perfectly.... I.e. you can zoom and pan whilst still picking... However, If you run the PickaPoint routine from a button on a form which you have popped up, you can still pick a point, but none of the AutoCAD buttons work...!!!

I have basically created a new larger toolbar as the tiny little icons are difficult to hit for some of our users... It's a just a form at the end of the day, which contains a toolstrip and is displayed by clicking one of said smaller icons. and calling..

Dim App As Autodesk.AutoCAD.ApplicationServices.Application
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(App.MainWindow, Toolbar)

The click event of the button then simply calls PickaPoint.  But for the life of me i can not use the pan and zoom tools at the same time.  Which is obviously pretty crucial when trying to move around the drawing.

I've tried executing the command in the document context, API calls, and also using SendStringToExecute on the Document to send the Pan and zoom commands again... but nothing works

I've been struggling with this for a while now and so far everythng i've tried has failed... Unless i run the code direct from the AutoCAD toolbar!

If anyone out there has any suggestions i would really appreciate it....

Kindest regards

Phil Langrishe


Glenn R

  • Guest
I noticed you're using ShowModelessDialog...are you locking the document?

Paul Richardson

  • Guest
I have basically created a new larger toolbar as the tiny little icons are difficult to hit for some of our users... It's a just a form at the end of the day, which contains a toolstrip and is displayed by clicking one of said smaller icons. and calling..

You can increase the icon size in options->display->use large buttons for toolbars.

Grishe

  • Guest
Hi There...

Thanks for those suggestions...

We're developing an application which basically allows AutoCAD to be taken outside and connected to some GPS kit costing 20k+ which allows Civil engineers and Surveyors to accurate surveys of Roads and Housing estates etc.. i.e. using the GPS as a mouse... on a rugged Tablet PC. Unfortunately even the larger icons in AutoCAD are not big enough for our users to press easily with a pen stylus... With a mouse it's a doddle, but in the wind and rain of the great out doors apparently bigger is better.  So that’s why I can't using the larger icons ..  :cry:

I've also tried locking the document but, unfortunately that doesn't allow the pan and zooms commands to work either...

The closest I’ve come is to use..

Case PromptStatus.Keyword
Dim command As String = ResPt.StringResult '.Substring(2)
app.ActiveDocument.SendCommand(command & " ")

Where app is declaired...

Dim app As AcadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication

This allows the pan/zoom or which ever command the user clicks to fire correctly, however they will not exit!! If you click the Pan and then right click the mouse to exit, it won't exit, It just keeps panning!!  It's got to be something to do with the loop it's running inside, but the SendCommand method does not wait until the command exits... so another ed.GetPoint is fired straight after, which must be screwing it up.
« Last Edit: August 22, 2007, 05:48:03 AM by Grishe »

Grishe

  • Guest
For anyone interested I've sorted it...

The solution was to setup a new command class which would basically do all the picking, so you could in effect call it with the keyboard.  But then call the command class on the click event of the toolstripbutton in the toolbar, using SendStringToExecute on the Active Document.  A real round the houses solution... But if you want to initiate a pick from a form, which isn't initially spawned from an AutoCAD toolbar, it seems like the only way...

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
By doing that (putting the picking in a command) you are letting acad handle the windows messages, while you are picking the point, windows is handling many other messages (such as WM_PAINT every pixel the mouse moves), to add to that acad has to catch the 'transparent' commands like zoom etc.
I think picking these by buttons in the middle of a command from a dialog is the biggest hurdle here and the zoom using the mouse wheel is probably handled by a windows event, it doesn't invoke a command proper and isn't so much a problem.

Picking a button mid command is starting another command and is in effect is saying "I'm in this command and I'm up to this part of it, do your zoom command thing and come straight back to here so I can continue", complicated stuff!

If you look back at earlier autocad you will see that menus and buttons simply activated a command and dialogs were primarily used for things like settings. Commands knew how to handle other commands in situ but nowadays people are using dialog boxes for a lot more than just settings allowing the user to pick objects and fill the dialog with info for instance, this has made handling transparent commands a bit harder (probably to do with all the dialog-editor-dialog interaction and windows) and may be a reason that transactions were implemented to help handle the transparent commands, I don't know but it's something to consider.
« Last Edit: August 22, 2007, 06:32:20 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Grishe

  • Guest
Yes i appreciate marshalling the all the user inputs, as well as handling calls made by applications trying to drill in via the .NET API, is no easy task.  It's just frustrating when something works one way... But the law of sod says that you can't use that approach in certain circumstances. All i was trying to do was keep the same level of user interaction people expect i.e. Zooming and Panning, whilst picking a point.  Unfortunately doing this from a form, rather than an AutoCAD command, seemed to block these calls... 

From what i remember from the courses i attended... Transactions are used to drill into a drawing database and manage changes, plus at the same time keeping the undo engine in check... I didn't know they also aided user interactions... Unfortunately starting and subsequently disposing of a Transaction didn't help in this particular instance....  My circumstances are probably unique and no one will ever run into the same problems I did....