SDK:Parametric Object Default Tool

From Vectorworks Developer
Jump to navigation Jump to 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

Object Creation Tool Plug-in

When creating a new object you may create another plug-in that will handle creation of that new object. This is the case when you make additional plug-ins that will go along with your object's plug-ins. For more information on tool plug-ins see SDK:Tool Plug-in

The new tool main function should respond to the kToolHandleComplete action. During this action it should call the ISDK::CreateCustomObject function to create instance of the custom parametric object.

If this is the first object of this type to be created in a drawing, a dialog is presented so the user can set default values for the parameters. Then a parametric object is created in the drawing at the location specified.

If a preferences button is supported by the tool, then it should respond to the kToolDoModeEvent event by calling the ISDK::DefineCustomObject function.

This will present a dialog for the user to set preferred default values for the parameters. This dialog will be automatically created by VectorWorks or the parametric object will provide it (kParametricPreference event). These default values will be stored in the drawing file but no object is created.

To support the double-click creation feature, respond to the kToolDoDoubleClick action by calling ISDK::CreateCustomObjectDoubleClick.

Default Tool

A parametric object plug-in can make VectorWorks create a default tool for it. This way you will not have to create additional plug-ins.

With default tool you will not have ability to get messages regarding the tool. That is why this is used for simple objects that doesn't need complex creation tool behavior.

Define

In addition to the normal object plug-in resources you should add one TDef resource.

That tool definition resource should have id 128 and name exactly the output file name (without extension).

Also the "Title String" should be the name of the parametric object defined in PDEf resource's 'Display name'.

Example

resource 'PDEf' (128, "The Object") {
  /* Universal name */ "ObjectWithDefaultToolSample",
  /* Display name */   "Object With Default Tool",
  /* Version */        1
};

...
... define other object plug-in resources ...
...

resource 'TDef' (128, "PluginOutputFile") {
  /* pickAndUpdate, disablePickUpdate */           pickAndUpdate,
  /* doesntNeedPlan, needsPlan */                  needsPlan,
  /* doesntNeed3DProjection, needs3DProjection */  doesntNeed3DProjection,
  /* use2DCursor, use3DCursor */                   use2DCursor,
  /* constrainCursor, screenBasedCursor */         constrainCursor,
  /* doesntNeedPerspective, needsPerspective */    doesntNeedPerspective,
  /* showScreenHints, dontShowScreenHints */       showScreenHints,
  /* reservedFalse, reservedTrue */                reservedFalse,
  /* rest of tool flags */                         0,
  /* Icon ID */                                    11001,
  /* Default Cursor ID */                          kSmallCrossCurs,
  /* messageStr */                                 "VWPluginWiz1",
  /* WaitMove distance */                          0,
  /* Constraint flags */                           159,
  /* barDisplay mode */                            kXYClLaZo,
  /* Minimum compatible version */                 500,
  /* Title String */                               "ObjectWithDefaultToolSample:Sample",
  /* mode flags */                                 0,
  /* product flags */                              0,
  /* version created */                            0,
  /* version modified */                           0,
  /* version retired */                            0
};

read 'PNG ' (11001, "Icon") "ToolImage.png";

Things to note about the sample:

  1. The name of 'TDef' resource is the name of the output file. In the sample on windows the file is 'PluginOutputFile.sdo' and on Mac: 'PluginOutputFile.vwobject'
  2. 'Title String' of 'TDef' resource is the name of the object defined in 'PDEf' resource 'Display name'.
  3. A 'PNG ' resource defines icon for the default tool.

See Also

SDK:Tool with Default Behavior