.NET

.NET

Reply
Contributor
17 Posts
0 Kudos
Registered: ‎09-30-2007
Post 11 of 15

Re: How to handle multiple open documents gracefully

10-03-2007 11:13 AM in reply to: jspark
I have already downloaded the SDK but have not read much of the documentation yet. Thank you all so much. I believe I have enough homework to keep me busy for a while.
Contributor
17 Posts
0 Kudos
Registered: ‎09-30-2007
Post 12 of 15

Re: How to handle multiple open documents gracefully

10-03-2007 04:21 PM in reply to: jspark
That was almost too easy. =)
Distinguished Contributor
1,691 Posts
3 Kudos
Registered: ‎12-15-2003
Post 13 of 15

Re: How to handle multiple open documents gracefully

10-03-2007 04:51 PM in reply to: jspark
You might find some of the info in this post useful.

http://discussion.autodesk.com/thread.jspa?messageID=5538160
*Tony Tanzillo
Post 14 of 15

Re: How to handle multiple open documents gracefully

10-04-2007 03:23 AM in reply to: jspark
"CADJunkie" wrote:

>> What a nice professional response.

No, that's simply how all 'non-charletans'
are treated.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
*Tony Tanzillo
Post 15 of 15

Re: How to handle multiple open documents gracefully

10-05-2007 06:26 PM in reply to: jspark
>> So I dont need to worry about multiple instances
>> of "MyApp" object being created.

Well, not quite.

The way it works is that if your command method is
non-static (not shared), as is the case in your code,
AutoCAD creates a seperate instance of your class,
for each open document. So, if there are 3 open
documents, there will be three instances of your
"MyApp" class.

That may be what is leading you to think that VB is
automatically switching the events every time you
assign a non-static/shared member variable that has
the 'WithEvents', to another document.

In fact, what you don't realize is that there is more
than one instance of your class, and each of them is
being used with a different document, so it gives the
illusion that the event handlers are automatically
added to the document assigned to the variable each
time the variable's value is changed, but that's not
what's going on at all.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5739332@discussion.autodesk.com...
Yes, I have been wondering, and am unclear on when exactly "MyApp" is created. I would guess that NETLOAD does not create an instance of "MyApp". In order to execute the command method, an instance of "MyApp" is created... If thats the case then I would assume a second instance of "MyApp" is NOT created when the command is ran for a second time. So I dont need to worry about multiple instances of "MyApp" object being created. What about resetting mThisDrawing each time a new document becomes the active document? Will that make the same event handler work for the new active doc? (I guess I could do some tests to figure that out, but it sounds logical...) Am I on the right track here?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!