Design Review

Design Review

Active Member
Posts: 7
Registered: ‎06-22-2011
Message 1 of 6 (1,308 Views)
Accepted Solution

API - ADR 2011/2012 only as Renderer and source of data .NET c#

1308 Views, 5 Replies
06-23-2011 03:43 AM



I would like a special functionality of UI interface displaing DWF file which is not avaliable with ADR.

I was wondering if there is an API that alows to specify area and magnification to render objects in this specified area to Bitmap/Visual


This ability would allow me to implement my own user interface and display.


I searched through new API guide however cannot find any reference to this feature or ability to pass parameters to PAN,ZOOM,ZOOMRECT commands (not by mouse or keyboard)

Thank you kindly



VS 2008 C#

.NET 3.5

ADR 2011

WPF interface

Posts: 338
Registered: ‎03-05-2008
Message 2 of 6 (1,284 Views)

Re: API - ADR 2011/2012 only as Renderer and source of data .NET c#

06-28-2011 02:27 AM in reply to: aka.kamyk

Thank you for your question.


ADR does not support to pass parameters to PAN,ZOOM,ZOOMRECT commands.


However, you can implement you special functionality following the steps:

    1. Use property Content2.Extents to get the boundaries of specified object(s).


  For 2D objects:

    2. Calculate your specify area and magnification (specify view) base on the boundaries (IAdRect).

    3. Set your specify 2D view to render obejcts via EPlotSection.SetView method.


  For 3D bojects:

    2. Define your specify EModelCamera object base on the boundaries (IAdCube).

    3. Set you specify 3D view to render objects via EModelSection.Camera property.


Hope that helps.


Herbert He
SW Engineer
Autodesk, Inc.
Active Member
Posts: 7
Registered: ‎06-22-2011
Message 3 of 6 (1,223 Views)

Re: API - ADR 2011/2012 only as Renderer and source of data .NET c#

07-22-2011 01:07 AM in reply to: herbert.he

Thank you herbert for precise answer.


I have done as you suggested and I am fairly happy with the results BUT, there is a huge problem with mine solution. When I use AxCExpressViewerControl directly it paints on the screen very fast, but when i use mine own control (which uses DrawToDC method) i is approximately 20-30 times slower. It is not a big deal for small drawings but for large ones time to render one frame is around 300ms (for my test large drawing)  and my app is pretty laggy and unusable.


So my next question is:


Is there some way to "extract" AxCExpressViewerControl Graphics directly from control to achieve equal speed, or maybe force ActiveX control to paint on injected Device Context ?


I have tried workaround:


offscreen control + API BitBlt - very fast (10-20ms for my test large drawing) works for Windows 7/Vista but doesn't for Windows XP. (Windows XP paints only Desktop area and blank for offscreen)

SendMessage + WM_PRINT, - no success

API OleDraw - works but it is same slow speed as DrawToDC


have you got any suggestions ?





Active Member
Posts: 7
Registered: ‎06-22-2011
Message 4 of 6 (1,220 Views)

Re: API - ADR 2011/2012 only as Renderer and source of data .NET c#

07-22-2011 04:37 AM in reply to: herbert.he

Ok cancel that I did it just now.

I've got the solution. I managet to render whole map offscreen using API PrintWindow on W7 Vista and XP :smileyhappy:

PrintWindow using client area is not working correctly on XP but there is work around using SetWorldTranstorm to move Graphics area to the right position.


If some one else will search solution for this, here is how I did it.


1. Create Static Render manager class, which starts STA thread and in this thread creates Form wich contains ADR ActiveX Control. STA thread is required for ActiveX controls.

2. Move created window offscreen and use it to load DWF file

3. SetView to chanche viewing area (as herbert said)

4. use API "PrintWindow" to get ActiveX control graphic inside hosting form




/// method inside scope of Panel user Coontrol that contains AxCExpressViewerControl

// ensure thant ParentForm Handle is Created befor invoke this method by refering to ParentForm.Handle

// in other case InvokeRequired will fail


public void PrintWindow(Bitmap bitmap)



            if (ParentForm.InvokeRequired)
            {  // invoke from parent form thred to avoid cross thread exception
                ParentForm.Invoke(new MethodInvoker(delegate() { PrintWindow(bitmap); }));


           IntPtr hWnd = this.ParentForm.Handle;

            // get this panel offset inside Form
            Point pointToClient = this.PointToClient(this.ParentForm.Location);

            using (Graphics tmp = Graphics.FromImage(bitmap))
                IntPtr gHDC = tmp.GetHdc();


                // GDI32 & User32 are imported from C# definitions
                GDI32.SetGraphicsMode(gHDC, 2);
                GDI32.XFORM F =
                    new GDI32.XFORM(1,0,0,1,pointToClient.X,pointToClient.Y);

// set wold transform to get only client area - beacause CM_CLIENTFLAG for PrintWindow method is shifting graphics wrong way in Windows XP

                GDI32.SetWorldTransform(gHDC, ref F);

// Print whole window to graphics whit world transform

                User32.PrintWindow(hWnd,gHDC , 0);               





Posts: 4
Registered: ‎08-27-2012
Message 5 of 6 (919 Views)

Re: API - ADR 2011/2012 only as Renderer and source of data .NET c#

08-27-2012 11:36 AM in reply to: aka.kamyk

Does anyone knows how to reset the commands as they are totally strange.

now i need first to select erase then to click on the object..

also I cannot fin draw order when I select and object??

Please help



Active Member
Posts: 7
Registered: ‎09-19-2012
Message 6 of 6 (807 Views)

Re: API - ADR 2011/2012 only as Renderer and source of data .NET c#

09-20-2012 07:33 AM in reply to: herbert.he

How do you "specify EModelCamera object base on the boundaries" in Javascript? 


I have the extents of the object I want to zoom in on. How do I use these to set the camera boundaries?

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.