I'm currently attempting to develop a script to open an unknown filename .dxf, autozoom (part will not always be drawn near the origin) print it as a pdf, and the tricky bit is I'm also attempting to print it to a printer calibration - we've yet to buy QCad Pro (4 copies will need purchased), but plan to if the script in question can be successfully executed.
For our application, the end goal is launching QCad via command line with -autostart; obviously, my current code isn't there yet. We need to apply a printer calibration because we do indeed need to print it, however, our printers are networked - adobe reader has functionality to print to the default printer, whereas I don't believe QCad does. If I'm mistaken, that's great though. If successful, this will be deployed at 4 locations, hence printer IP and name vary.
Things I still need to modify the script for are: open generic file name in location folder (instead of scripting the file name in), integrate printer calibration, integrate autozoom for drawings away from the origin
I am not competent in javascript, so what I have so far is stitched together from various examples and search results from these forums. My current script is as follows:
Code: Select all
// include class Print and OpenFile:
include("scripts/EAction.js");
include("scripts/File/OpenFile/OpenFile.js");
include("scripts/File/Print/Print.js");
//! [init]
// init application name:
//qApp.applicationName = "ScalePrint";
//! [document]
var document = new RDocument(new RMemoryStorage(), new RSpatialIndexNavel());
// create document interface (needed for file export functionality):
var di = new RDocumentInterface(document);
di.importFile('C:/Users/BML/Desktop/Test/1-1.dxf');
//! [document]
//! [view]
var scene = new RGraphicsSceneQt(di);
var view = new RGraphicsViewImage();
view.setScene(scene,false);
//! [view]
//! [settings]
// set up page and paper settings as document variables:
var pageWidth = 8.5;
var pageHeight = 11;
var bb = document.getBoundingBox(true, true);
var scale = 1.0;
// paper unit:
document.setVariable("PageSettings/PaperUnit", RS.Inch);
// paper width:
document.setVariable("PageSettings/PaperWidth", pageWidth);
// paper height:
document.setVariable("PageSettings/PaperHeight", pageHeight);
// page orientation ("Portrait" | "Landscape"):
document.setVariable("PageSettings/PageOrientation", "Landscape");
// color mode ("FullColor" | "GrayScale" | "BlackWhite"):
document.setVariable("ColorSettings/ColorMode", "BlackWhite");
// background color:
document.setVariable("ColorSettings/BackgroundColor", new RColor("white"));
// drawing scale as string:
document.setVariable("PageSettings/Scale", "1:1");
// offset of drawing origin to lower left corner in drawing units:
document.setVariable("PageSettings/OffsetY", -(pageWidth/scale - bb.getWidth()) / 2);
document.setVariable("PageSettings/OffsetX", -(pageHeight/scale - bb.getHeight()) / 2);
// number of pages (rows / columns):
document.setVariable("MultiPageSettings/Rows", 1);
document.setVariable("MultiPageSettings/Columns", 1);
// switch on / off crop marks:
document.setVariable("MultiPageSettings/PrintCropMarks", false);
// switch on / off page tags:
document.setVariable("PageTagSettings/EnablePageTags", false);
//! [settings]
//! [export]
var print = new Print(undefined, document, view);
print.print("C:/Users/BML/Desktop/Test/example.pdf");
//! [export]
Attached are the .dxf currently used, and the output example.pdf.
Any assistance would be greatly appreciated.
Also, I'm sorry if this is in the wrong section - it's a How Do I, yet its Pre-Sales if successful.