Sample Script to Modify Color of Shape When Printing
Sample codes for a script to modify the color of the shape when printing are shown below. When executing printing, the script will be executed for each shape at print preview.
It is necessary to turn off "Color as black" in Print Settings beforehand.
- Create a new file with a text editor such as Notepad.
- Copy the following codes and paste them on a text editor.
- Create a folder with the name "Document.ShapePrinting" in the scripts folder, and save a file with the extension of .csx in the folder.
The scripts folder is the one to be opened by clicking in [Open Scripts Folder] on [Scripts] menu in RootPro CAD.
Any name can be used for a script file name.Supplemental ▪ Files must be saved using Unicode (UTF-8) as character codes. In Notepad, modify [Encoding] box on the left of [Save] button on [Save As] dialog box to "UTF-8". - Restart RootPro CAD.
- Turn off "Color as black" in Print Settings.
- Execute printing.
Shapes on the layer named "Auxiliary Line" will not be printed.
Dimension shapes and text shapes will be printed in red and blue, respectively.
// Retrieve current drawing.
var doc = Application.ActiveDocument;
// Retrieve ShapePrinting event parameter.
var e = (ShapePrintingEventArgs)EventArgs;
// Shapes on the auxiliary line layer will not be printed. Dimension shapes and text shapes will be printed in red and blue, respectively.
Shape shape = e.Shape;
if(doc.LayerTable.GetLayerByID(shape.LayerID).Name == "Auxiliary Line")
{
e.Cancel = true;
}
else if(shape is DimensionShape)
{
((DimensionShape)shape).ColorNumber = 2;
}
else if(shape is TextShape)
{
((TextShape)shape).ColorNumber = 4;
}
Supplemental | |
▪ | Script functions are only used in RootPro CAD Professional. RootPro CAD Free cannot use these functions. |
▪ | When modifying a code in an existing script file after starting up RootPro CAD, it will be immediately reflected without restarting RootPro CAD. |