PlannerRoad
Guest
su through the interface c# code is available for the compilation of a utility that allows you to simultaneously create two screeshots via autocad: one of its window and the other of its work area.
the code, reported qui, is the following:
in the code in red are the command of the utility that is css and the location and format of the image used as a screenshot save directory, i.e.c:\\main-window.png e c:\\doc-window.pngthe first related to the autocad window, the second related to its work area.
These 3 parameters (command and routes) can be changed at will.
how to fill out the code: in this debate visual c#: fill out the code for autocad I explained the procedure and indicated the software for compiling c#.
in this case, beyond ai due file acdbmgd.dll eacmgd.dll already mentioned in the discussion indicated, for this utility other references must be added.how and which other references add: always in the menu "project" -> option "Add reference" -> tab ".net" this time, add as reference system.drawing and in the case of autocad 2010 probably also presentation.core.
even if not mentioned in the article, for the operation of the code I had to add also the reference system.windows.forms, without which the utility during the compilation indicated an error.
for the rest of the compilation and loading of the utility in autocad continue to follow the procedure reported in the other discussion.
After uploading the compiled utility with the netload command giving the css command (or other command you edited) you will have the automatic creation of the two screenshots in the indicated directory.
the code, reported qui, is the following:
PHP:
using acapp = autodesk.autocad.applicationservices;
using autodesk.autocad.runtime;
using system.drawing.imaging;
using system.drawing;
namespace screenshottest
{
public class commands
{
[CommandMethod("CSS")]
static public void capturescreenshot()
{
screenshottofile(
acapp.application.mainwindow,
"c:\\main-window.png",
0, 0, 0, 0
);
screenshottofile(
acapp.application.documentmanager.mdiactivedocument.window,
"c:\\doc-window.png",
30, 26, 10, 10
);
}
private static void screenshottofile(
autodesk.autocad.windows.window wd,
string filename,
int top, int bottom, int left, int right
)
{
point pt = wd.location;
size sz = wd.size;
pt.x += left;
pt.y += top;
sz.height -= top + bottom;
sz.width -= left + right;
// set the bitmap object to the size of the screen
bitmap bmp =
new bitmap(
sz.width,
sz.height,
pixelformat.format32bppargb
);
using (bmp)
{
// create a graphics object from the bitmap
using (graphics gfx = graphics.fromimage(bmp))
{
// take a screenshot of our window
gfx.copyfromscreen(
pt.x, pt.y, 0,0, sz,
copypixeloperation.sourcecopy
);
// save the screenshot to the specified location
bmp.save(filename, imageformat.png);
}
}
}
}
}
These 3 parameters (command and routes) can be changed at will.
how to fill out the code: in this debate visual c#: fill out the code for autocad I explained the procedure and indicated the software for compiling c#.
in this case, beyond ai due file acdbmgd.dll eacmgd.dll already mentioned in the discussion indicated, for this utility other references must be added.how and which other references add: always in the menu "project" -> option "Add reference" -> tab ".net" this time, add as reference system.drawing and in the case of autocad 2010 probably also presentation.core.
even if not mentioned in the article, for the operation of the code I had to add also the reference system.windows.forms, without which the utility during the compilation indicated an error.
for the rest of the compilation and loading of the utility in autocad continue to follow the procedure reported in the other discussion.
After uploading the compiled utility with the netload command giving the css command (or other command you edited) you will have the automatic creation of the two screenshots in the indicated directory.
Last edited: