zoom WIndow .NET

zoom WIndow .NET

Anonymous
Not applicable
1,841 Views
9 Replies
Message 1 of 10

zoom WIndow .NET

Anonymous
Not applicable
Using VS2005 and AutoCAD 07/08 and SQL Server 2000


Hopefully maybe a stupid question but i guess we'll see....Why doesnt this work??????

MORE CODE ABOVE HERE..........................

Dim Xmax As Decimal
Dim Xmin As Decimal
Dim Ymax As Decimal
Dim Ymin As Decimal
Xmax = (MyEnt.GeometricExtents.MaxPoint.X + 1)
Xmin = (MyEnt.GeometricExtents.MinPoint.X - 1)
Ymax = (MyEnt.GeometricExtents.MaxPoint.Y + 1)
Ymin = (MyEnt.GeometricExtents.MinPoint.Y - 1)
'Dim zoomRec As New DatabaseServices.ViewTableRecord
'Dim ZoomHelp As (Autodesk.AutoCAD.Runtime.Interop)MyDWG

Dim zoomwindow As New Autodesk.AutoCAD.GraphicsSystem.View
Dim lowerbounds As New Geometry.Point2d(Xmin, Ymin)
Dim UpperBounds As New Geometry.Point2d(Xmax, Ymax)
zoomwindow.ZoomWindow(lowerbounds, UpperBounds)

MORE CODE bELOW HERE..........................

What i am doing is selecting labels that are mtext. That is where the coordinates come from. I am trying to zoom to each one in a for next statement. It wont zoom to the window though. There are no errors thrown. Through out the Whole code. Just cant get it to zoom to the entity. I did look through the posts on here and they mention "interop" I dont know what that is and have never used it.


I
0 Likes
1,842 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
you can't create a new view without more code.
I think what you want is to use the modelspace view to zoom around the drawing, in which case you should add some code like this:

Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim cVP As Integer = System.Convert.ToInt32(Application.GetSystemVariable("CVPORT"))

then instead of creating a new view, set the view obj. to the current view like so:

Dim zoomwindow As Autodesk.AutoCAD.GraphicsSystem.View = doc.GraphicsManager.GetGsView(cVP, True)

then make sure to call zoomwindow.update() everytime you change the zoomwindow object.
0 Likes
Message 3 of 10

Anonymous
Not applicable
Also,

you probably don't want to use zoomwindow, you probably want to use zoomextents()

otherwise you are drawing a zoom window based on the size of your entity, instead of zooming the screen to the entity.

oh, and you are actually creating a temporary view of modelspace. when the user regen's they will find they are in the spot they were before the command executed. so you may want to do a regen programmatically to compensate for the screen not being where they think it is.
0 Likes
Message 4 of 10

Anonymous
Not applicable
THAT WORKS GREAT!!! Thank you so much. I did use the zoomextents() also.
0 Likes
Message 5 of 10

Anonymous
Not applicable
Hi,

the zooms works, but it looks different from the view before. That is,
1) before I had 2-line view of the pipe network on white background
2) in zoom i have some kind of polygon view on grey background
3) after regen I have the old view, but on grey background, mousewheel
acts funny and it suddenly jumps to a view of the complete modelspace

Here is the code, what is wrong?

Document doc = AcadApp.DocumentManager.MdiActiveDocument;
Int32 cVP =
System.Convert.ToInt32(Application.GetSystemVariable("CVPORT"));
Autodesk.AutoCAD.GraphicsSystem.View zoomwindow =
doc.GraphicsManager.GetGsView(cVP, true);
zoomwindow.ZoomExtents( obj.GeometricExtents.MinPoint,
obj.GeometricExtents.MaxPoint);
zoomwindow.Update();

AcadApp.ShowAlertDialog("Click me to exit zoom.");
doc.SendStringToExecute("REGEN ", false, false, false);

Thanks,
Patrick

Cadkid82 wrote:
> Also,
>
> you probably don't want to use zoomwindow, you probably want to use zoomextents()
>
> otherwise you are drawing a zoom window based on the size of your entity, instead of zooming the screen to the entity.
>
> oh, and you are actually creating a temporary view of modelspace. when the user regen's they will find they are in the spot they were before the command executed. so you may want to do a regen programmatically to compensate for the screen not being where they think it is.
0 Likes
Message 6 of 10

Anonymous
Not applicable
I have some code at work that fixed that. I fought with it for the longest time. I will email it to you in the morning.
0 Likes
Message 7 of 10

arcticad
Advisor
Advisor
Please Post your code to the Forum for the Benefit of all.

Thank You.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 8 of 10

Anonymous
Not applicable
My "email address" is NOT nospam@autodesk.com. Please post it to the list.

Did you clone the old view, or create a new view from the old ptr?
I just discovered there is "SetViewFromViewport" and so on.

ampplee37 wrote:
> I have some code at work that fixed that. I fought with it for the
> longest time. I will email it to you in the morning.
0 Likes
Message 9 of 10

Anonymous
Not applicable
Here you go Hope this helps you out. There is still some junk in there i need to clean up. its just left over from trying to get it to work properly.

Dim Layout As String = SwitchTabs("Model")
Dim Mytransman As Autodesk.AutoCAD.DatabaseServices.TransactionManager
Dim Mytrans As Autodesk.AutoCAD.DatabaseServices.Transaction
Dim MyDWG As Autodesk.AutoCAD.ApplicationServices.Document
Dim MyDWGDB As Autodesk.AutoCAD.DatabaseServices.Database
Dim MyEd As EditorInput.Editor
MyDWG = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Mytransman = MyDWG.TransactionManager
Mytrans = Mytransman.StartTransaction
MyDWGDB = MyDWG.Database
MyEd = MyDWG.Editor
Dim currentvisstyle As New Autodesk.AutoCAD.GraphicsInterface.VisualStyle


Dim lowerbounds1 As New Geometry.Point3d(-10000, -10000, 0)
Dim UpperBounds1 As New Geometry.Point3d(10000, 10000, 0)


Dim cVP1 As Integer = System.Convert.ToInt32(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("CVPORT"))
Dim ZoomWindow1 As Autodesk.AutoCAD.GraphicsSystem.View = MyDWG.GraphicsManager.GetGsView(cVP1, True)
ZoomWindow1.ZoomExtents(lowerbounds1, UpperBounds1)
MyDWG.GraphicsManager.SetViewportFromView(cVP1, ZoomWindow1, True, True, False)
'MyEd.Regen()


ZoomWindow1.Dispose()
Mytrans.Commit()
Mytrans.Dispose()
Mytransman.Dispose()
SwitchTabs(Layout)
0 Likes
Message 10 of 10

Anonymous
Not applicable
Thank you! The "SetViewportFromView" did the job. Here is the
alternative version going through Interop:

AcadApplication app =
(AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
Extents3d ext = mem.GeometricExtents;
Vector3d v = new Vector3d((ext.MinPoint -
ext.MaxPoint).ToArray());
Point3d ll = (ext.MinPoint - v * 100.0 / zoomFactor);
Point3d ur = (ext.MaxPoint + v * 100.0 / zoomFactor);
app.ZoomWindow(ll.ToArray(), ur.ToArray());

Just make sure you dont have DOTNET3.5SP1 installed, it has a LOT of
side effects.

Ampplee37 wrote:
> Here you go Hope this helps you out. There is still some junk in there i
> need to clean up. its just left over from trying to get it to work
> properly. Dim Layout As String = SwitchTabs("Model") Dim Mytransman As
> Autodesk.AutoCAD.DatabaseServices.TransactionManager Dim Mytrans As
> Autodesk.AutoCAD.DatabaseServices.Transaction Dim MyDWG As
> Autodesk.AutoCAD.ApplicationServices.Document Dim MyDWGDB As
> Autodesk.AutoCAD.DatabaseServices.Database Dim MyEd As
> EditorInput.Editor MyDWG =
> Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
> Mytransman = MyDWG.TransactionManager Mytrans =
> Mytransman.StartTransaction MyDWGDB = MyDWG.Database MyEd = MyDWG.Editor
> Dim currentvisstyle As New
> Autodesk.AutoCAD.GraphicsInterface.VisualStyle Dim lowerbounds1 As New
> Geometry.Point3d(-10000, -10000, 0) Dim UpperBounds1 As New
> Geometry.Point3d(10000, 10000, 0) Dim cVP1 As Integer =
> System.Convert.ToInt32(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("CVPORT"))
> Dim ZoomWindow1 As Autodesk.AutoCAD.GraphicsSystem.View =
> MyDWG.GraphicsManager.GetGsView(cVP1, True)
> ZoomWindow1.ZoomExtents(lowerbounds1, UpperBounds1)
> MyDWG.GraphicsManager.SetViewportFromView(cVP1, ZoomWindow1, True, True,
> False) 'MyEd.Regen() ZoomWindow1.Dispose() Mytrans.Commit()
> Mytrans.Dispose() Mytransman.Dispose() SwitchTabs(Layout)
0 Likes