SDK:Parametric General Info

From Vectorworks Developer
Jump to: navigation, search

.SDK|SDK ..SDK:Types|SDK Types ..SDK:Using the SDK|Using the SDK ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

Parametric Object Extension

This feature provides a way to deliver more powerful and easy to use objects. It will also make it possible for users to create their own custom objects. A Custom Parametric Object will behave like a built-in object, and will draw itself based on the current values of its parameters. Users can easily edit the parameter values using the Object Info palette as they do with all Vectorworks objects.

When developing a Custom Parametric Object, you will actually need to provide two extensions: a parametric and either a tool or a menu. The associated Tool or Menu will be used to provide a user interface for the creation of the Parametric Object. It may be as simple as a Tool which allows the user to click once in the drawing to place the Parametric Object, or it may be a Menu Command that displays a complex series of dialogs which allow the user to initialize the Parametric Object before it is created. The Parametric Object’s code will not present a user interface. It will simply draw the object based on the current parameter values. It will be called automatically by Vectorworks whenever the object needs to be regenerated. This may be in response to the user changing a parameter value on the Object Info palette for example.

Parametric Object Types

There are several different SDK:Parametric Object Types. Each type supports different creation and editing features.

The object types are:

Register Parametric Extension

Registering the extension is done in the module main function. See SDK:Plug-in Module#The Plug-in Module Environment.

This code registers a parametric extension implementation class 'CExtObjParametricObj' as such in the 'GROUPID_ExtensionParametric' VCOM grouping (groups are used to improve the performance of Vectorworks when enumerating the available extensions):

REGISTER_Extension<TesterModule::CExtObjParametricObj>( GROUPID_ExtensionParametric, action, pInfo, ioData, cbp, reply );

Extension Class Definition

Note Always keep your extension implementation classes in a namespace!

namespace TesterModule
    using namespace VWFC::PluginSupport;

Note #1, see after the code block.
    // ------------------------------------------------------------------------------------------------------
    class CObjParametricObj_EventSink : public VWParametric_EventSink
                    CObjParametricObj_EventSink(IVWUnknown* parent);
        virtual     ~CObjParametricObj_EventSink();

    // Parametric Object action/events constants 
        virtual EObjectEvent    OnInitXProperties(CodeRefID objectID);
        virtual EObjectEvent    Recalculate();

Note #2, see after the code block.
    // ------------------------------------------------------------------------------------------------------
    class CExtObjParametricObj : public VWExtensionParametric
                        CExtObjParametricObj(CallBackPtr cbp);
        virtual         ~CExtObjParametricObj();

Extension Class Implementation

using namespace TesterModule;

namespace TesterModule
Note #1, see after the code block.
    // --------------------------------------------------------------------------------------------------------
    static SParametricDef gParametricDef = {
        /*LocalizedName*/           {11100, 1},
        /*SubType*/                 kParametricSubType_Point,
        /*ResetOnMove*/             false,
        /*ResetOnRotate*/           false,
        /*WallInsertOnEdge*/        false,
        /*WallInsertNoBreak*/       false,
        /*WallInsertHalfBreak*/     false,
        /*WallInsertHideCaps*/      false,

Note #2, see after the code block.
    static SParametricParamChc    gArrChoices[] = {
        { 128,    "Line",                {11002, 1} },
        { 128,    "Arc",                 {11002, 2} },
        { 128,    "Bezier",              {11002, 3} },
        { 128,    "None",                {11002, 4} },
        { 129,    "Default Legend",      {11002, 5} },
        // TERMINATE
        { NULL, NULL, {0,0} }

Note #3, see after the code block.
    static SParametricParamDef gArrParameters[] = {
        { "p1",            {11001, 1},        "False",        "False",        kFieldBoolean,      0 },
        { "p2",            {11001, 2},        "False",        "False",        kFieldBoolean,      0 },
        { "p3",            {11001, 3},        "\001@17913,7", "\001@17913,7", kFieldText,         0 },
        { "p4",            {11001, 4},        "",             "",             kFieldText,         0 },
        { "p5",            {11001, 5},        "2\"",          "2\"",          kFieldCoordDisp,    0 },
        { "p6",            {11001, 6},        "Auto",         "Auto",         kFieldPopUp,        128 },
        { "p7",            {11001, 7},        "Auto",         "Auto",         kFieldPopUp,        129 },
        // TERMINATE
        { NULL, {0,0}, NULL, NULL, EFieldStyle(0), 0 }

Note #4, see after the code block.
// --------------------------------------------------------------------------------------------------------
// {D475E572-AD8F-4C0F-A836-4952593664DB}
    /*Extension class*/   CExtObjParametricObj,
    /*Event sink*/        CObjParametricObj_EventSink,
    /*Universal name*/    "TestObjID",
    /*Version*/           1,
    /*UUID*/              0xd475e572, 0xad8f, 0x4c0f, 0xa8, 0x36, 0x49, 0x52, 0x59, 0x36, 0x64, 0xdb );

// Test with VectorScript:
// SetSelect(CreateCustomObject('TestObjID',0,0,0));

Note #5, see after the code block.
// --------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------
CExtObjParametricObj::CExtObjParametricObj(CallBackPtr cbp)
      : VWExtensionParametric( cbp, gParametricDef, gArrParameters )
//    : VWExtensionParametric( cbp, gParametricDef, gArrParameters, gArrChoices )


Note #6, see after the code block.
// --------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------
CObjParametricObj_EventSink::CObjParametricObj_EventSink(IVWUnknown* parent)
    : VWParametric_EventSink( parent )


EObjectEvent CObjParametricObj_EventSink::OnInitXProperties(CodeRefID objectID)
    // obtain the interfact for accessing the extended properties
    using namespace VectorWorks::Extension;
    VCOMPtr<IExtendedProps>    extProps( IID_ExtendedProps );

Note #7, see after the code block.

    return kObjectEventNoErr;

EObjectEvent CObjParametricObj_EventSink::Recalculate()
Note #8, see after the code block.
    VWPoint3D    offset( -500, 0, 0 );

    VWPolygon3DObj    poly;
    poly.AddVertex( offset + VWPoint3D(50, 100, 0) );
    poly.AddVertex( offset + VWPoint3D(1000, 0, 0) );
    poly.AddVertex( offset + VWPoint3D(1000, 1000, 0) );
    poly.AddVertex( offset + VWPoint3D(100, 800, 0) );
    poly.SetClosed( true );

    return kObjectEventNoErr;
  • Note #1 - Implementing VWFC:PluginSupport:VWExtensionParametric requires use of that structure to define the parametric extension. Note that that structure contains localizable strings, which are referenced by their resource IDs. Also it defines the Parametric Object type.
  • Note #2 - If there are choice popup parameters, the choices are defined using that structure. The ID value needs to be the same for consecutive values of the same popup. The universal names of the choices is specified as ANSI string, and the localized values as reference to a STR# resource.
  • Note #3 - This structure is used to define the parameters of the parametric object. These parameters are used to define the parametric's record format.The universal names of the parameters is specified as ANSI string, and the localized parameter names as reference to a STR# resource.
The parameter's default value can be hard coded but also taken from the STR# resources. Use the prefix "\001@" folowed by the list ID, a comma and the index of the resource.
The parameter types (FieldStyle) are defined in MiniCadCallBacks.h and summarized in the following table:
Parameter Type C++ Constant User Interface Description
1 kFieldLongInt Integer number edittext
2 kFieldBoolean Checkbox
3 kFieldReal Real number edittext
4 kFieldText Edittext
5 kFieldCalculation N/A
6 kFieldHandle N/A
7 kFieldCoordDisp Displacement dimension edittext
8 kFieldPopUp Popup menu
9 kFieldRadio Radio button group
10 kFieldCoordLocX X-axis Location dimension edittext
11 kFieldCoordLocY Y-axis Location dimension edittext
  • Note #4 - A macro that identifies the sink for the extension, the universal name, and the VCOM UUID.
  • Note #5 - Implementation of the parametric extension. Use appropriate constructor depending if there is a popup parameter choices or not.
  • Note #6 - Implementation of the custom menu event sink.
  • Note #7 - Define the Parametric Extended Properties.
  • Note #8 - The reset function. This function is called by Vectorworks when the Parametric Object needs to regenerate its visual appearance.

Parametric Object Tasks

  1. Defining Custom Object Info Palette (OIP)

See Also

Personal tools

Advanced Search
See Also