.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I have an app that uses a paletteset. The paletteset displays a modal dialog on a particular action. From the modal dialog, the user needs to be able to click a button to zoom to a particular coordinate. I have it all working, with one problem. The Zoom doesn't occur until the user closes the modal dialog. I know this is related to my limited understanding of contexts in AutoCAD, and am hoping that someone can point me in the right direction.
I've tried calling my Zoom method from the modal dialog, from the parent paletteset, and asynchronously using doc.SendStringToExecute() back to my main commands class, with the same result. The Zoom occurs after exiting the modal dialog.
Any advice on how I can make the zoom occur while remaining in the modal dialog?
Thanks!
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You can't really get much help without showing some code, It's difficult to guess what your code is doing.
For example, how exactly, are you performing the ZOOM in the click handler?
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I am not sure but maybe it can help you, but if is possible for you please put your current Code here then we can help you better.
private static void ZoomWin(
Editor ed, Point3d min, Point3d max
)
{
Point2d min2d = new Point2d(min.X, min.Y);
Point2d max2d = new Point2d(max.X, max.Y);
ViewTableRecord view =
new ViewTableRecord();
view.CenterPoint =
min2d + ((max2d - min2d) / 2.0);
view.Height = max2d.Y - min2d.Y;
view.Width = max2d.X - min2d.X;
ed.SetCurrentView(view);
}
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You wrote
>>I am not sure but maybe it can help you
Do you know who is DiningPhilosopher?
LOL
C6309D9E0751D165D0934D0621DFF27919
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
No I don't know who is he?
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
autodeskprogrammer wrote:
No I don't know who is he?
Then read: http://forums.autodesk.com/t5/NET/What-happens-wit
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sorry for the delay in responding. I was travelling and just got back. Thanks for the replies.
I was trying to be concise by not posting pages of code, but I know I could have done a better job of explaining. First, I should mention that I am using AutoCAD Map 3D and there is an FDO data layer involved, BUT I don't believe that has anything to do with the issue I'm facing. (Maybe I'm wrong, though...)
I'm trying to Zoom to a specific X,Y point - either at the same scale or at a specific zoom scale. I was originally using the Zoom code in the documentation called "Manipulate the Current View" here:
No matter what I tried, the Zooms would take me out in space somewhere. I tried a lot of different things,but never could get it to Zoom to the right place. Apparently, the transformations don't take into account the Map 3D coordinate system assigned.
I then discovered the Map API call AcMapMap.ZoomToExtent() using an MgEnvelope object. This works correctly for me using this code:
Public Shared Sub ZoomMapCenter(ZoomCenterPoint As Point3d, ObjectHeight As Double)
'zoom to a specific point on the map at a reasonable zoom scale to view object
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
ZoomCenterPoint.TransformBy(ed.CurrentUserCoordina teSystem)
Dim map As AcMapMap = AcMapMap.GetCurrentMap()
Dim mapExtent As MgEnvelope = map.GetMapExtent()
'There is some FDO feature source connected
If Not mapExtent.IsNull() Then
Dim centerX As Double = ZoomCenterPoint.X
Dim centerY As Double = ZoomCenterPoint.Y
'ed.WriteMessage("center:" & centerX.ToString() & "," & centerY.ToString() & vbLf)
Dim newExtent As New MgEnvelope(ZoomCenterPoint.X - (ObjectHeight * 3.0), ZoomCenterPoint.Y - (ObjectHeight * 2.0), ZoomCenterPoint.X + (ObjectHeight * 3.0), ZoomCenterPoint.Y + (ObjectHeight * 2.0))
map.ZoomToExtent(newExtent)
Else
'no FDO data source, use AutoCAD API
Using Tx As Transaction = db.TransactionManager.StartTransaction()
ed.UpdateTiledViewportsInDatabase()
Dim viewportTableRec As ViewportTableRecord = TryCast(Tx.GetObject(ed.ActiveViewportId, OpenMode.ForWrite), ViewportTableRecord)
viewportTableRec.CenterPoint = New Point2d(ZoomCenterPoint.X, ZoomCenterPoint.Y)
ed.UpdateTiledViewportsFromDatabase()
Tx.Commit()
End Using
End If
End Sub
Again, everything works just fine and I'm getting the results I need, except for the fact that the view does not change until the user closes the modal dialog. The zoom then occurs as expected and recenters the map on the correct location. I just need for the Zoom to occur when the user clicks the button.
The button calling this function is on a modal form which is launched from a paletteset. At the moment, I am trying by placing the ZoomMapCenter method above in my command class, calling it asynchronously using SendStringToExecute as shown below:
Private Sub btnZoomTo_Click(sender As System.Object, e As System.EventArgs) Handles btnZoomTo.Click
'zoom to the correct coordinates
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
'zoom to the point based on the selected InventoryID
If Not CurrentPoint.Equals(New Point3d()) = True Then
Using edUsrInt As EditorUserInteraction = ed.StartUserInteraction(Me.Handle)
'zoom to the point
Dim centerPoint As String = CurrentPoint.X.ToString + "," + CurrentPoint.Y.ToString
Dim stringToExecute As String = "ZoomToPlant " + centerPoint + " " + CurrentPlantBlockScale.ToString() + " "
doc.SendStringToExecute(stringToExecute, True, False, False)
edUsrInt.End()
Me.Focus()
End Using
End If
End SubI also tried it without using the ed.StartUserInteraction() with no success.
Again, everything works just fine except that the view doesn't change until the user closes the modal form. I'm sure the problem is related to me not fully understanding the session/document context that I'm running under.
Thanks for your help.
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try call Editor.Regen() at the end of your ZoomMapCenter() method.
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Do you try to use Document.SendStringToExecute from button handler of modal dialog? Document.SendStringToExecute is executed asynchronously. That is why execution will be done only after command is ended. Try to call one of ZoomXXX function from this topic: http://forums.autodesk.com/t5/NET/ZoomWindow-and-Z
Also can be useful:
Re: Zoom from modal dialog
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
but I implemented your code and it worked perfectly - only I disabled some part of your code
Public Shared Sub ZoomMapCenter(ZoomCenterPoint As Point3d, ObjectHeight As Double)
'zoom to a specific point on the map at a reasonable zoom scale to view object
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
ZoomCenterPoint.TransformBy(ed.CurrentUserCoordina teSystem)
'Dim map As AcMapMap = Nothing
'AcMapMap.GetCurrentMap()
'Dim mapExtent As MgEnvelope = Nothing
'map.GetMapExtent()
'There is some FDO feature source connected
If False Then
'Dim centerX As Double = ZoomCenterPoint.X
'Dim centerY As Double = ZoomCenterPoint.Y
''ed.WriteMessage("center:" & centerX.ToString() & "," & centerY.ToString() & vbLf)
'Dim newExtent As New MgEnvelope(ZoomCenterPoint.X - (ObjectHeight * 3.0), ZoomCenterPoint.Y - (ObjectHeight * 2.0), ZoomCenterPoint.X + (ObjectHeight * 3.0), ZoomCenterPoint.Y + (ObjectHeight * 2.0))
'map.ZoomToExtent(newExtent)
Else
'no FDO data source, use AutoCAD API
Using Tx As Transaction = db.TransactionManager.StartTransaction()
ed.UpdateTiledViewportsInDatabase()
Dim viewportTableRec As ViewportTableRecord = TryCast(Tx.GetObject(ed.ActiveViewportId, OpenMode.ForWrite), ViewportTableRecord)
viewportTableRec.CenterPoint = New Point2d(ZoomCenterPoint.X, ZoomCenterPoint.Y)
ed.UpdateTiledViewportsFromDatabase()
Tx.Commit()
End Using
End If
End Sub





