Post Process Scripting

<< Click to Display Table of Contents >>

Navigation:  WireCAD CMS Tools Manual > CMS Settings and Options >

Post Process Scripting

Previous pageReturn to chapter overviewNext page

Post Process Scripting of the output of the Visualizers in WireCAD allow you to customize the final appearance of the created document.

 

What follows are two example scripts, one for the Circuit output and the other for the Backbone output. The process is the same for both. Only the method signature is changed.

 

Circuits Export Script Example

 

//////////////////////////////////////////////////////////////////////////////////

using System;

using System.Data;

using System.Text;

using System.Windows.Forms;

using System.Diagnostics;

using System.Reflection;

using System.IO;

using WireCAD;

using WireCAD.Interfaces;

using VectorDraw.Professional.vdObjects;

using VectorDraw.Professional.vdFigures;

using VectorDraw.Professional.vdPrimaries;

using VectorDraw.Professional.vdCollections;

using WireCAD.ProjectFile.DAL;

using VectorDraw.Geometry;

 

/// <summary>

/// Fill your titleblock with your data

/// </summary>

//Your class name

public class TitleBlockFiller

{

 //the method signature is key so this next line must appear as shown

 public static void Run(Workspace ws, Circuits c, vdDocument doc)

 {

         string drawingName = Path.GetFileName(doc.FileName);

 

         //change this next line to be your titleblock name

         string BlockNameToUpdate = "ansi";

 

         //Get the layout by name that we want to update

         vdLayout layOut = doc.LayOuts.FindName("ANSI_B");

         

         //loop through the entities in the layout

         foreach (vdFigure figure in layOut.Entities)

         {

                 

                 //if we find a viewport let zoom it to the extents of our model

                 if(figure is vdViewport)

                 {

                         vdViewport vp = figure as vdViewport;

                         vp.ZoomExtents();

                         vp.Update();

                 }

                 

                 //now look for our titleblock

                 if (figure is vdInsert)

                 {

                         //cast our base figure into an insert object so we can access its properties

                         vdInsert insert = (vdInsert) figure;

                         //now we will test to see if the insert name is one that

                         //we know to be a titleblock

                         //Modify this to meet your needs

                         if (insert.Block.Name.ToLower().Contains(BlockNameToUpdate))

                         {

                                 //need to fix it.

                                 //this next bit makes it insert get the latest version from the blocks table

                                 insert.Update();

                                 insert.Invalidate();

 

                                 //we got one so let's set the attributes

                                 //we will use the safeSetAttribute function so that if the attribute doesn't exist it won't

                                 //fail

                                 //Modify this to meet your needs

                                 //Enter your Attribute names and the values you want to fill them with

                         

                                 

                                 ws.Utilities.SafeSetAttributeValue(insert, "SHEET", layOut.Name);

                                 ws.Utilities.SafeSetAttributeValue(insert, "Drawing_Name", Path.GetFileNameWithoutExtension(drawingName));

                                 ws.Utilities.SafeSetAttributeValue(insert, "DWG_Number", c.CktNO);

                                 ws.Utilities.SafeSetAttributeValue(insert, "COMPANY", "Slate Gravel Co");

                                 ws.Utilities.SafeSetAttributeValue(insert, "ADDRESS", "Number 1 Quary Way");

                                 ws.Utilities.SafeSetAttributeValue(insert, "ADDRESS2", "Bedrock - The World");

                                 ws.Utilities.SafeSetAttributeValue(insert, "DATE", DateTime.Now.ToShortDateString());

                                 ws.Utilities.SafeSetAttributeValue(insert, "Scale", "NTS");

                                 insert.Update();

                                 insert.Invalidate();

                                 doc.Redraw(true);

 

                         }

                 }

                 

         }

         

         //Now create a text item that displays our circuit number in the upper righthand corner

         vdText t = new        vdText(doc);

         t.TextString = string.Format("CKT - {0}\n{1}",c.CktNO, c.CktDescription);

         t.HorJustify = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorRight;

         Box bb = layOut.Entities.GetBoundingBox(true,true);

         t.Height = .25d;

         t.InsertionPoint = new gPoint(bb.Right-3,bb.Top-2);

         layOut.Entities.AddItem(t);

         

         doc.ActiveLayOut = layOut;

         

                   

 }

}

 

Backbones Export Script Example

The only difference in the two examples is the method signature. Use the code above replacing:

 public static void Run(Workspace ws, Circuits c, vdDocument doc)

 

With:

 public static void Run(Workspace ws, CMSSettings settings, vdDocument doc)