.NET

.NET

Reply
Active Contributor
btmcad
Posts: 31
Registered: ‎05-09-2007
Message 1 of 5 (609 Views)

Changing the document window size with vb.net

609 Views, 4 Replies
09-20-2012 01:33 PM

I'm trying to change the active document window size with vb.net. This seems like it should be straightforward, but I'm having some trouble. Below is some code that I tried to use which I found on the AutoCAD DevBlog.. I thought I understood how this works, but I can't seem to import the correct references to make it work. Any help would be greatly appreciated.

  Dim doc As Document = Application.DocumentManager.MdiActiveDocument()

            Dim docWindow As Window = doc.Window

            Dim size As Size = docWindow.Size

            docWindow.WindowState = Window.State.Normal

            docWindow.Size = New Size(500, 500)

 

*Expert Elite*
arcticad
Posts: 1,286
Registered: ‎06-21-2004
Message 2 of 5 (604 Views)

Re: Changing the document window size with vb.net

09-20-2012 02:19 PM in reply to: btmcad

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Windows

 

and changed size to drawing,size and it worked fine. in 2010

 

What was the error?

---------------------------



(defun botsbuildbots() (botsbuildbots))
Valued Mentor
fieldguy
Posts: 382
Registered: ‎03-31-2005
Message 3 of 5 (596 Views)

Re: Changing the document window size with vb.net

09-20-2012 03:00 PM in reply to: btmcad

This works in Map 3D 2011.  References are attached.

 

<CommandMethod("testwindow")> _
    Public Sub testwindowsize()
        Dim doc As acapp.Document = acapp.Application.DocumentManager.MdiActiveDocument()
        Dim docWindow As Window = doc.Window
        Dim size As Drawing.Size = docWindow.Size
        docWindow.WindowState = Window.State.Normal
        docWindow.Size = New Drawing.Size(500, 500)
    End Sub

 

Active Contributor
btmcad
Posts: 31
Registered: ‎05-09-2007
Message 4 of 5 (569 Views)

Re: Changing the document window size with vb.net

09-21-2012 03:50 AM in reply to: fieldguy

Thanks for the help, but it won't build with 2013.

I checked, and I have all of the references that fieldguy has. With acad 2013, I know a number of items have changed in .net. I've tried a number of combinations of imported namespaces, but I get a message stating that 'Type Size is not defined".

I can get this to work in earlier versions, but unfortunately, I need it to work in 2013.

 

Thanks

btm

 

 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 5 of 5 (553 Views)

Re: Changing the document window size with vb.net

09-21-2012 11:47 AM in reply to: btmcad

There's a lot of changes in AutoCAD 2013 that break existing code.

 

See my response to your Swamp Post: 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.