Switch Drawings?

Switch Drawings?

mark
Explorer Explorer
1,054 Views
8 Replies
Message 1 of 9

Switch Drawings?

mark
Explorer
Explorer
Hi everyone, I'm looking for some help switching the currently active drawing file.

I have 2 drawings for my example. Drawing A and Drawing B.

I have Drawing A currently open, i run my program and it opens the Drawing B, however once Drawing B is completely open, AutoCAD is switching back to Drawing A.

So I'm wondering if anyone knows how to force AutoCAD to switch back to Drawing B? Basically just like how you go to the window pulldown then pick another drawing and AutoCAD switches drawings.

Thanks for any help!!

Mark
0 Likes
1,055 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Can you post a code snippet that shows how you open the file?

If you're doing this from a registered command, the CommandFlags parameter
should include CommandFlags.Session, and you need to documents before you
modify anything in them.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message
news:6174144@discussion.autodesk.com...
Hi everyone, I'm looking for some help switching the currently active
drawing file. I have 2 drawings for my example. Drawing A and Drawing B. I
have Drawing A currently open, i run my program and it opens the Drawing B,
however once Drawing B is completely open, AutoCAD is switching back to
Drawing A. So I'm wondering if anyone knows how to force AutoCAD to switch
back to Drawing B? Basically just like how you go to the window pulldown
then pick another drawing and AutoCAD switches drawings. Thanks for any
help!! Mark
0 Likes
Message 3 of 9

mark
Explorer
Explorer
Like this (I'm open to suggestions to change of course)
X.Path is the path to the drawing file of course.


Dim MyApp As AcadApplication
MyApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication

MyApp.Application.Documents.Open(X.Path)

After this part, AutoCAD swaps back to the original Drawing A?

Thanks Tony for taking a look.

Mark
0 Likes
Message 4 of 9

Anonymous
Not applicable
mark@mkmassociates.com wrote:

> Like this (I'm open to suggestions to change of course)

This works for me.

Dim NewDoc As Document = Application.DocumentManager.Open(DwgNam, False)
If SetAct = True Then
Application.DocumentManager.MdiActiveDocument = NewDoc
End If

Warning, its highly likely that vile criticism will follow this post.

Terry
0 Likes
Message 5 of 9

Anonymous
Not applicable
Mark - The problem isn't the code you posted, but the context you're calling
it from.

As I mentioned before, are you calling this from a command that's registered
with the [CommandMethod] attribute? If not, where are you calling it from?

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message
news:6174227@discussion.autodesk.com...
Like this (I'm open to suggestions to change of course) X.Path is the path
to the drawing file of course. Dim MyApp As AcadApplication MyApp =
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
MyApp.Application.Documents.Open(X.Path) After this part, AutoCAD swaps back
to the original Drawing A? Thanks Tony for taking a look. Mark
0 Likes
Message 6 of 9

Anonymous
Not applicable
The criticism is warranted given that your post demonstrates that you don't
have the slightest clue that the code you posted is actually just another
way of calling the code that Mark shows in his post (the Open() method of
the DocumentCollection calls the Open() method of the AcadDocuments
COM object - the same method that Mark is calling).

Duh!

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


"Terry W. Dotson" wrote in message
news:6174536@discussion.autodesk.com...
mark@mkmassociates.com wrote:

> Like this (I'm open to suggestions to change of course)

This works for me.

Dim NewDoc As Document = Application.DocumentManager.Open(DwgNam, False)
If SetAct = True Then
Application.DocumentManager.MdiActiveDocument = NewDoc
End If

Warning, its highly likely that vile criticism will follow this post.

Terry
0 Likes
Message 7 of 9

Anonymous
Not applicable
Hi. You're the owner of this forum, Tony? I've seen a Tony reply on about every thread I've read here. 🙂

So, by using the CommandFlags.Session parameter in the attribute, the code are executed in the acad session context, not in the drawing?

[CommandMethod("SWITCH"), CommandFlags.Session]
public static void SwitchWindow()
{
Application.DocumentManager.Open("c:\\D1.dwg", false);
}

This worked neatly.

Curious about:
"and you need to documents before you modify anything in them."

I have to do what with the documents?
0 Likes
Message 8 of 9

Anonymous
Not applicable
"and you need to lock documents before you modify anything in them".

It was probably a phone call in the middle of typing the sentence.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6175809@discussion.autodesk.com...
Hi. You're the owner of this forum, Tony? I've seen a Tony reply on about
every thread I've read here. 🙂 So, by using the CommandFlags.Session
parameter in the attribute, the code are executed in the acad session
context, not in the drawing? [CommandMethod("SWITCH"), CommandFlags.Session]
public static void SwitchWindow() {
Application.DocumentManager.Open("c:\\D1.dwg", false); } This worked neatly.
Curious about: "and you need to documents before you modify anything in
them." I have to do what with the documents?
0 Likes
Message 9 of 9

Anonymous
Not applicable
Hello, I'm having a similar problem but when I try to include the CommandFlags.Session parameter like so:

[CommandMethod("JOpen"), CommandFlags.Session]

I get an error:
The type name 'SessionAttribute' does not exist in the type 'Autodesk.AutoCAD.Runtime.CommandFlags'

Any help would be appreciated, Thanks.
0 Likes