.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Following code does not work in AutoCAD 2007 (Zooming Object)

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
365 Views, 2 Replies

Following code does not work in AutoCAD 2007 (Zooming Object)

This code below works perfectly fine with ACAD 2008 but not with ACAD 2007. What is needed to change to make it work in ACAD 2007?

{code}

public static void ZoomObject(ObjectId id, double zoomFactor)
{
Database db = HostApplicationServices.WorkingDatabase;
AcadApplication app = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;

Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Extents3d ext;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity en = (Entity)tr.GetObject(id, OpenMode.ForRead);
ext = en.GeometricExtents;
ed.SetImpliedSelection(new ObjectId[] { id });
}
Vector3d v = new Vector3d((ext.MinPoint - ext.MaxPoint).ToArray());
app.ZoomWindow((ext.MinPoint - v * 100.0 / zoomFactor).ToArray(), (ext.MaxPoint + v * 100.0 / zoomFactor).ToArray());

app.Update();
}

{code}
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

'works perfectly fine with ACAD 2008 but not with ACAD 2007'.

Unless someone here recognizes something in the code, You'll
need to describe what happens exactly when you try it on 2007.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6285395@discussion.autodesk.com...
This code below works perfectly fine with ACAD 2008 but not with ACAD 2007.
What is needed to change to make it work in ACAD 2007?

{code}

public static void ZoomObject(ObjectId id, double zoomFactor)
{
Database db = HostApplicationServices.WorkingDatabase;
AcadApplication app =
(AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;

Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Extents3d ext;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity en = (Entity)tr.GetObject(id, OpenMode.ForRead);
ext = en.GeometricExtents;
ed.SetImpliedSelection(new ObjectId[] { id });
}
Vector3d v = new Vector3d((ext.MinPoint - ext.MaxPoint).ToArray());
app.ZoomWindow((ext.MinPoint - v * 100.0 / zoomFactor).ToArray(),
(ext.MaxPoint + v * 100.0 / zoomFactor).ToArray());

app.Update();
}

{code}
Message 3 of 3
Anonymous
in reply to: Anonymous

Hello Tony

In ACAD 2007, it does not zoom like it does in ACAD 2008. When I try to zoom using the code posted, it does take some action in the drawing. But does not zoom to the zoomfactor I specifiy. I think it zooms at very low zoomfactor.

Thanks & Regards,
Sachin

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report