 | DrawingCreatorExtension Class |
Inheritance Hierarchy Namespace: CTExtensions.InterfacesAssembly: CTInterface (in CTInterface.dll) Version: 25.0
Syntaxpublic abstract class DrawingCreatorExtension : IExtensionInterface
Public MustInherit Class DrawingCreatorExtension
Implements IExtensionInterface
The DrawingCreatorExtension type exposes the following members.
Constructors
Methods | Name | Description |
---|
 | AddViews |
Called after PreAddViews. If you return true, you are responsible of creating all the views using
SW API. Dimensions are imported for all views after this if defined in Drawing Creation Rule settings.
|
 | GetParent |
Must implement. Return parent CTExtension of this Drawing Creator Extension.
|
 | OverrideCustomSheetName |
If the automation rule uses Custom Sheet name, you can override it here.
Called when the drawing rule is selected for a component, after OverrideDrawingFilename.
|
 | OverrideDrawingFilename |
Called when the drawing rule is selected for a component at Batch Operations.
You can override drawing name (full path). If overriden to empty, then drawing creation is ignored.
If you need licensed Document Manager to inspect the source model, you can obtain it with static call CTInterface.GetSWDocManager().
SldWorks instance can be obtained and cached at MyExtension.Hook.
|
 | PostAddViews |
Post Process the sheet. E.g. add BOM for assembly drawings.
|
 | PreAddViews |
Called when rules are executing. When this is called, the drawing is created but not saved,
source model is open and has the configuration to be used as reference activated.
Allows doing custom preparations for the sheet before views are added.
|
Top
Example
This example shows how to create a Script Extension for a Drawing Creation Rule.
Language: C#
Class name: MyExtension
using ATR.CT.CTInterface;
using CTExtensions;
using CTExtensions.Interfaces;
using CTEngineLib;
using SolidWorks.Interop.sldworks;
using System.Runtime.InteropServices;
namespace Example
{
public class MyExtension : CTExtension
{
private DrawingCreatorExtension moMyDrawingCreator = null;
public override string FriendlyName()
{
return "Single View Creator";
}
public override bool Hook(CTInterface oCTInterface)
{
return false;
}
public override void UnHook(CTInterface oCTInterface)
{
}
public override IExtensionInterface[] GetInterface2(ctExtensionInterface eInterface)
{
if (eInterface == ctExtensionInterface.ctExtensionInterfaceDrawingCreator)
{
if (moMyDrawingCreator == null)
moMyDrawingCreator = new MyDrawingCreator(this);
return new[] { moMyDrawingCreator };
}
return null;
}
}
public class MyDrawingCreator : DrawingCreatorExtension
{
MyExtension moParent;
public MyDrawingCreator(MyExtension parent)
{
moParent = parent;
}
public override ICTExtension GetParent()
{
return moParent;
}
public override bool OverrideDrawingFilename(CTDrawingAutomation oAutomation, string bsModelFilename, string bsModelConfiguration, string bsDrwFilename, out string bsDrwFilenameOverride)
{
bsDrwFilenameOverride = "";
return false;
}
public override bool OverrideCustomSheetName(CTDrawingAutomation oAutomation, string bsModelFilename, string bsModelConfiguration, string bsSheetName, out string bsSheetNameOverride)
{
bsSheetNameOverride = "";
return false;
}
public override void PreAddViews(object oDrwDoc, object oSheet, object oSourceModel, string oSourceConfiguration)
{
IDrawingDoc oDrw = (IDrawingDoc)oDrwDoc;
IModelDoc2 oModel = (IModelDoc2)oSourceModel;
ISheet oDrwSheet = (ISheet)oSheet;
}
public override bool AddViews(object oDrwDoc, object oSheet, object oSourceModel, string oSourceConfiguration)
{
IDrawingDoc oDrw = (IDrawingDoc)oDrwDoc;
IModelDoc2 oModel = (IModelDoc2)oSourceModel;
ISheet oDrwSheet = (ISheet)oSheet;
double dWidth = 0, dHeight = 0;
oDrwSheet.GetSize(ref dWidth, ref dHeight);
oDrw.CreateDrawViewFromModelView3(oModel.GetPathName(), "*Top", dWidth / 2, dHeight / 2, 0);
return true;
}
public override void PostAddViews(object oDrwDoc, object oSheet, object oSourceModel, string oSourceConfiguration)
{
IDrawingDoc oDrw = (IDrawingDoc)oDrwDoc;
IModelDoc2 oModel = (IModelDoc2)oSourceModel;
ISheet oDrwSheet = (ISheet)oSheet;
}
}
}
Revision HistoryDate | Version | Description |
---|
- | 2023 SP0 | First Release |
See Also