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

Zoom to selected entities

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
2284 Views, 6 Replies

Zoom to selected entities

Hi,

I wrote a simple program which selects some entities from a drawing. Is there a way to zoom to the result programmatically?
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

{code}

namespace MyExtensionMethods
{
public static class EditorExtensionMethods
{
static MethodInfo runCommand = typeof( Editor ).GetMethod(
"RunCommand", BindingFlags.NonPublic | BindingFlags.Instance );

public static PromptStatus Command( this Editor editor, params
object[] args )
{
return (PromptStatus) runCommand.Invoke( editor, new object[] {
args } );
}

public static void ZoomObjects( ObjectId[] ids )
{
Editor editor =
Application.DocumentManager.MdiActiveDocument.Editor;
Application.SetSystemVariable( "CMDECHO", 0 );
Command( editor, "._ZOOM", "_O", ids );
}
}
}

{code}

--
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:6252337@discussion.autodesk.com...
Hi,

I wrote a simple program which selects some entities from a drawing. Is
there a way to zoom to the result programmatically?
Message 3 of 7
Anonymous
in reply to: Anonymous

Thanks a lot tony, that's awesome..the only problem is that selected entities are no more highlighted, any suggestion?
Message 4 of 7
Anonymous
in reply to: Anonymous

You have to reselect them because any command that's started
clears the current selection.

You can use this API to select them:

Autodesk.AutoCAD.Internal.Utils.SelectObjects();

You have to add the CommandFlags.Redraw flag to your command
method attribute for the selection to remain after the command ends.

--
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:6252627@discussion.autodesk.com...
Thanks a lot tony, that's awesome..the only problem is that selected
entities are no more highlighted, any suggestion?
Message 5 of 7
Anonymous
in reply to: Anonymous

I actually had tried it,

Autodesk.AutoCAD.Internal.Utils.SelectObjects(final_entities);
Autodesk.AutoCAD.Internal.Utils.ZoomObjects(false);
System.Windows.Forms.Application.UseWaitCursor = false;

and also added the CommandFlags.Redraw
The problem is that after zooming, it goes back to its original size, the zoom size does not persist. Edited by: apt42 on Sep 11, 2009 10:53 PM
Message 6 of 7
Anonymous
in reply to: Anonymous

Tony, how do you go about zooming and selecting in 2009 without internal.utils?

edited... I guess i just needed to add the internal dll to my references. Edited by: ViktorCad on Oct 30, 2009 10:26 PM
Message 7 of 7
Anonymous
in reply to: Anonymous

You can use Internal.Utils in 2009, you just need to add
a reference to AcMgdInternal.dll.

--
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:6281493@discussion.autodesk.com...
Tony, how do you go about zooming and selecting in 2009 without
internal.utils?

edited... I guess i just needed to add the internal dll to my references.

Edited by: ViktorCad on Oct 30, 2009 10:26 PM

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report