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

Doubt Regarding IExtensionApplication

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

Doubt Regarding IExtensionApplication

Hi, I am having a Solution which Contains 3 Projects.

1. MyHelper - A C# project which contains a class called MyCircle which will have a static member called NoofCircles (integer). It contains a callback delegate for DocumentCreated and it is added to the newly created document within Initialize() (of IExtensionApplication). The instance for the class MyClass will be created in the callback method for DocumentCreated and the NoofCircles is initialized to 5.

2. MyConcentricCircle - ObjectDBX project which will get the count from the MyHelper::NoofCircles and draws Concentric Circle accordingly.

3. UI - Command to create a Concentric Circle. Now, when i load the dlls into autocad, first, the MyHelper's Initialize() is called so that, NoofCircles is initialized to 5.

Then, When i give the command to create a circle, it create 5 concentric circles by getting the Count from the MyHelper project's MyCircle::NoofCircles.

Then i save it. Closed the document and reopened the document again.


But at that time, WorldDraw gets called before the DocumentCreated callback of MyHelper Class, before where an instance of MyCircle will be created and NoofCircles Initialized to 5.

Could anyone kindly tell me why WorldDraw of the Custom Object is called before On_kLoadDwgMsg and DocumentCreated callback methods are called?


Thank You in Advance.

Regards,
Vignesh. S Edited by: Vignesh_CPT on Oct 20, 2008 5:38 PM
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

I can't tell you why that's happening, but it has never been
considered wise to have a custom object that has a dependence
on a managed wrapper or any UI code.

--
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:6054393@discussion.autodesk.com...
Hi, I am having a Solution which Contains 3 Projects.

1. MyHelper - A C# project which contains a class called MyCircle which will have a static member called NoofCircles (integer). It contains a callback delegate for DocumentCreated and it is added to the newly created document within Initialize() (of IExtensionApplication). The instance for the class MyClass will be created in the callback method for DocumentCreated and the NoofCircles is initialized to 5.

2. MyConcentricCircle - ObjectDBX project which will get the count from the MyHelper::NoofCircles and draws Concentric Circle accordingly.

3. UI - Command to create a Concentric Circle. Now, when i load the dlls into autocad, first, the MyHelper's Initialize() is called so that, NoofCircles is initialized to 5.

Then, When i give the command to create a circle, it create 5 concentric circles by getting the Count from the MyHelper project's MyCircle::NoofCircles.

Then i save it. Closed the document and reopened the document again.

But at that time, WorldDraw gets called before the DocumentCreated callback of MyHelper Class, before where an instance of MyCircle will be created and NoofCircles Initialized to 5.

Could anyone kindly tell me why WorldDraw of the Custom Object is called before On_kLoadDwgMsg and DocumentCreated callback methods are called?

Thank You in Advance.

Regards,
Vignesh. S Edited by: Vignesh_CPT on Oct 20, 2008 5:38 PM
Message 3 of 7
Anonymous
in reply to: Anonymous

{quote}
> Could anyone kindly tell me why WorldDraw of the Custom
> Object is called before On_kLoadDwgMsg and
> DocumentCreated callback methods are called?
{quote}

AutoCAD starts generating graphics while a drawing file is still being
opened. If you need your MyHelper class to be initialized before
worldDraw() is called, then your .dbx should explicitly load and initialize
it before any MyConcentricCircle objects are created. 🙂
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
Message 4 of 7
Anonymous
in reply to: Anonymous

{quote:title="Owen Wengerd"}

If you need your MyHelper class to be initialized before
worldDraw() is called, then your .dbx should explicitly load and initialize
it before any MyConcentricCircle objects are created. 🙂

{quote}

If he is trying to call a method or property of a managed type from native code in a mixed mode dll, the managed assembly containing the managed type he's calling must be referenced from the mixed mode assembly, and there should be no need to explicitly load it, because the CLR takes care of that transparently.

--
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

"Owen Wengerd" wrote in message news:6054740@discussion.autodesk.com...
{quote}
> Could anyone kindly tell me why WorldDraw of the Custom
> Object is called before On_kLoadDwgMsg and
> DocumentCreated callback methods are called?
{quote}

AutoCAD starts generating graphics while a drawing file is still being
opened. --
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
Message 5 of 7
Anonymous
in reply to: Anonymous

Owen told us why worldDraw() can be called before there is a Document object for the database being opened, but explicitly loading and initializing your managed code is not the problem.

The problem is that your managed code is dependent on the Document object representing the drawing file being opened, which is not available at the point when worldDraw() is first called.

You must change your approach, to eliminate that dependence (perhaps associating instances of your managed type with a Database rather than a Document), although I still don't like the idea of having that kind of dependence to start with.

--

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:6054393@discussion.autodesk.com...
Hi, I am having a Solution which Contains 3 Projects.

1. MyHelper - A C# project which contains a class called MyCircle which will have a static member called NoofCircles (integer). It contains a callback delegate for DocumentCreated and it is added to the newly created document within Initialize() (of IExtensionApplication). The instance for the class MyClass will be created in the callback method for DocumentCreated and the NoofCircles is initialized to 5.

2. MyConcentricCircle - ObjectDBX project which will get the count from the MyHelper::NoofCircles and draws Concentric Circle accordingly.

3. UI - Command to create a Concentric Circle. Now, when i load the dlls into autocad, first, the MyHelper's Initialize() is called so that, NoofCircles is initialized to 5.

Then, When i give the command to create a circle, it create 5 concentric circles by getting the Count from the MyHelper project's MyCircle::NoofCircles.

Then i save it. Closed the document and reopened the document again.

But at that time, WorldDraw gets called before the DocumentCreated callback of MyHelper Class, before where an instance of MyCircle will be created and NoofCircles Initialized to 5.

Could anyone kindly tell me why WorldDraw of the Custom Object is called before On_kLoadDwgMsg and DocumentCreated callback methods are called?

Thank You in Advance.

Regards,
Vignesh. S Edited by: Vignesh_CPT on Oct 20, 2008 5:38 PM
Message 6 of 7
Anonymous
in reply to: Anonymous

Hi,
Thank you for your suggesion. I was wondering why the worlddraw is called first. But now, you have given me the reason and suggesion.

Thank you For your Reply and Suggesions,

Regards,
Vignesh. S
Message 7 of 7
Anonymous
in reply to: Anonymous

Hi,
Thank you for your suggesion. I was wondering why the worlddraw is called first. But now, you have given me the reason and suggesion.

Thank you For your Reply and Suggesions,

Regards,
Vignesh. S

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost