Jump to content
Developer Wiki and Function Reference Links ×

Building Plug in Objects


Recommended Posts

I am having trouble finding a guide on creating plug in objects. I have built 20ish scripts that all work fine and would like to build a plug in object similar to the built in Reference Marker tool with custom parameters and layout.  Can someone point me at a step by step guide or supply sample code I can look at?

 

Thanks so Much 

Edited by JoshRula
GRAMMER
Link to comment
1 hour ago, JoshRula said:

I am having trouble finding a guide on creating plug in objects...

 

See https://www.vectorworks.net/en-US/support/custom/vscript/example for examples of commands and objects.

 

See "ScriptFunctionReference.html," found in "...Vectorworks 2024\VWHelp\Script Reference" for basic call information.

 

See https://developer.vectorworks.net/index.php/Main_Page for more in-depth info on calls and other details.

 

Ask questions here as other developers can be a wealth of information and tend to be more than willing to share.

 

Link to comment

I did a write up a while back that might help you.

 

If you have a decent grasp of Vectorscript, building PIOs is very simple.  The biggest changes are working through the Plug-in Manager (if you've primarily written document scripts) and dealing with parameters.  You basically have to define all of your parameters at the outset, then access the parameters by putting an uppercase "P" in front of the variable name (something like width:=Pwidth).

  • Like 1
Link to comment

Hi!

A very simple trick.

 

Draw a rectangle, just one, with simple measure...

400x300 for example

 

then

menu file -> export script

 

Now you have the vs script for create a rectangle.

Here is it:

 

Procedure LoadFile;
VAR
    hatchName, gradientName, tileName, materialName, objectName:STRING;
    result, index, segmentIndex:INTEGER;
    colorIndex:LONGINT;
    boolResult:BOOLEAN;
    top, left, bottom, right:REAL;
    tileRepPoint, tileOffPoint:POINT;
    tempHandle, tempHandle1, tempHandle2, tempHandle3, tempHandle4, tempHandle5, tempHandle6, gradientHandle, objectHandle, layerHandle, classHandle, viewportHandle, tileHandle, tileGroupHandle, materialHandle, textHandle:HANDLE;
   dynCharArray, tempDescriptionText:DYNARRAY [] OF CHAR;

BEGIN
{VectorWorks Version 26.0.5(6227681)}

{Global Characteristics}

DrwSize(1,1);
SetUnits(0,1,0,2.54,'cm','cmq');
PrimaryUnits(0,1,1,2,6,TRUE,FALSE);
SecondaryUnits(1,3,1,TRUE,TRUE);
SetPrefLongInt(162,1);
SetPrefLongInt(169,1);
SetPrefLongInt(171,3);
SetPrefLongInt(172,3);
SetPrefLongInt(212,3);
SetPrefLongInt(219,3);
SetPrefLongInt(221,3);
SetPrefLongInt(222,3);
SetPrefInt(174,0);
SetPrefInt(224,0);
SetPref(167,FALSE);
SetPref(173,TRUE);
SetPref(223,FALSE);
SetPref(175,FALSE);
SetPref(225,TRUE);
GridLines(1);
PenGrid(0.1);
SetPrefReal(73,0);
SetOriginAbsolute(0,0);
SetPref(37,TRUE);
SetPref(38,TRUE);
SetPref(5,FALSE);
OpenPoly;
SetPrefInt(121,0);
SetPrefReal(68,0);
SetPrefReal(69,0);
SetPrefReal(70,1);

{End of Global Characteristics}

SetDocDrpShadowData(FALSE,0,0.01,0.005,#315.0000000000d,75,0,0,0);

{Record Format Entries}

{Begin Visible Record Format Entries}

{End of Visible Record Format Entries}

{Begin Hidden Record Format Entries}
NewField('NNA__MassAndForceUnits','Mass Unit','2',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Mass Precision','2',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Show Mass Mark','True',2,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Mass Unit Name','Kilogrammi',4,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Mass Unit Mark','kg',4,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Mass Unit Scale','1000',3,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Mass Unit Link','2',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Mass Unit Type','-1',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Mass Distr Unit','1',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Mass Distr Precision','2',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Show Mass Distr Mark','True',2,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom MassDistr Unit Name','',4,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom MassDistr Unit Mark','kg/m',4,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom MassDistr Unit Scale','1',3,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom MassDistr Mass Unit','2',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom MassDistr Lenght Unit','9',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Force Unit','1',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Force Precision','2',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Show Force Mark','True',2,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Force Unit Name','Kilonewton',4,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Force Unit Mark','kN',4,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Force Unit Scale','1000',3,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Force Unit Link','1',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('NNA__MassAndForceUnits','Custom Force Unit Type','-1',1,0);
SetObjectVariableBoolean(GetObject('NNA__MassAndForceUnits'),900,FALSE);
NewField('Setup Record_10','Version','26.0.1',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Active Class Std','1-VWArch',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Active Layer Std','1-VWArch',4,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Active Sheet Std','1-VWArch',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Num Basements','1',1,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Num Floors','2',1,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Use Zero','False',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Basement Prefix','B',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Floor Plan Scale','50.000000',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Site Plan Scale','200.000000',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Aux View Scale','50.000000',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Note Sheet Scale','1.000000',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Units','Centimetri',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Border Type','',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Title Block Type','',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Use Title Block Border','False',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Title Block Width','0,000000',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Title Block Height','0,000000',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Border Option','1',4,0);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','First Time-Setup','False',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','First Time-Model','True',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','First Time-Layers','True',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','First Time-Sheets','True',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Default Floor Height','106.299213',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Default Slab Thk','11.811024',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Default Bsmt Hgt','106.299213',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Default Fdn Thk','3.937080',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Default Ceiling Hgt','96.062992',3,6);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Has Roof','True',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Has Foundation','True',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Create Slab Layers','True',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);
NewField('Setup Record_10','Use Auto-classing','False',2,2);
SetObjectVariableBoolean(GetObject('Setup Record_10'),900,FALSE);

{End of Hidden Record Format Entries}

{End of Record Format Entries}

{LineType Definition Entries}

{End of LineTypeDefinition Entries}

{Worksheet Entries}

{End of Worksheet Entries}

{Gradient Definition Entries}

{End of GradientDefinition Entries}

{Tile Definition Entries}

{End of TileDefinition Entries}

{LayerLevelType Entries}

tempHandle := GetObject('Piano');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Piano');
tempHandle := GetObject('Pavimentazione grezza');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Pavimentazione grezza');
tempHandle := GetObject('Ambiente');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Ambiente');
tempHandle := GetObject('Solaio');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Solaio');
tempHandle := GetObject('Tetto');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Tetto');
tempHandle := GetObject('Fondazione');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Fondazione');
tempHandle := GetObject('Piano di calpestio');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Piano di calpestio');
tempHandle := GetObject('Pavimento');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Pavimento');
tempHandle := GetObject('Finitura pavimento');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Finitura pavimento');
tempHandle := GetObject('Controsoffitto');
IF tempHandle = nil THEN
    boolResult := CreateLayerLevelType('Controsoffitto');
{End of LayerLevelType Entries}

{Story Entries}

{End of Story Entries}

{Hatch Definition Entries}

{End of Hatch Definition Entries}

{-- Begin Simple Material Entries --}
{-- End Simple Material Entries --}

{-- Begin Compound Material Entries --}
{-- End Compound Material Entries --}

{Symbol Library Entries}

{End of Symbol Library Entries}

{Layer Characteristics}

layerHandle := CreateLayer('Lucido design-1', 1);
SetScale(50);
ShowLayer;
CopyMode(8);
LFillFore(0,0,0);
LFillBack(65535,65535,65535);
LPenFore(0,0,0);
LPenBack(65535,65535,65535);

Projection(6,0,1239.519999999999754,-13.809133333333332,13.809133333333332,13.809133333333332,-13.809133333333332);

{End of Layer Characteristics}

{Object Creation Code}

NameClass('Nessuna');
PenSize(2);
PenPatN(2);
FillPat(1);
PenFore(0,0,0);
PenBack(65535,65535,65535);
FillFore(0,0,0);
FillBack(65535,65535,65535);
RectangleN(-214,-147,0.1,0,400,300);
objectHandle := LNewObj;
SetDropShadowData(objectHandle, 0,0.01,0.005,#315.0000000000d,75,0,0,0);
EnableDropShadow(objectHandle, FALSE);

objectHandle := LNewObj;
SetObjectVariableBoolean(objectHandle, 1160, FALSE);

SetZVals(0,0);

OpacityN(100,100);

{End of Creation Code}

{Classes}

NameClass('Nessuna');
SetClFillFore('Nessuna',0,0,0);
SetClFillBack('Nessuna',65535,65535,65535);
SetClPenFore('Nessuna',0,0,0);
SetClPenBack('Nessuna',65535,65535,65535);
boolResult := SetClassBeginningMarker('Nessuna',0,15,0.125,0,34,0.05);
boolResult := SetClassEndMarker('Nessuna',0,15,0.125,0,34,0.05);
SetClFPat('Nessuna',1);
SetClLSN('Nessuna',2);
SetClLW('Nessuna',2);
SetCLDrpShadowData('Nessuna',0,0.01,0.005,#315.0000000000d,75,0,0,0);
EnableCLDropShadow('Nessuna',FALSE);

SetClUseGraphic('Nessuna',FALSE);
classHandle := GetObject('Nessuna');
NameClass('Quote');
SetClFillFore('Quote',0,0,0);
SetClFillBack('Quote',65535,65535,65535);
SetClPenFore('Quote',0,0,0);
SetClPenBack('Quote',65535,65535,65535);
boolResult := SetClassBeginningMarker('Quote',0,15,0.125,0,34,0.05);
boolResult := SetClassEndMarker('Quote',0,15,0.125,0,34,0.05);
SetClFPat('Quote',1);
SetClLSN('Quote',2);
SetClLW('Quote',2);
SetCLDrpShadowData('Quote',0,0.01,0.005,#315.0000000000d,75,0,0,0);
EnableCLDropShadow('Quote',FALSE);

SetClUseGraphic('Quote',FALSE);
classHandle := GetObject('Quote');

{End of Class Entries}

{Default Attributes}

PenSize(2);
PenPatN(2);
FillPat(1);
boolResult := SetDefaultBeginningMarker(0,15,0.125,0,34,0.05,FALSE);
boolResult := SetDefaultEndMarker(0,15,0.125,0,34,0.05,FALSE);
PenFore(0,0,0);
PenBack(65535,65535,65535);
FillFore(0,0,0);
FillBack(65535,65535,65535);
SetDocDrpShadwByCls(True);

{End of Default Attributes}


END;

Run(LoadFile);

 

But it has a lot of setting you don't need at the moment. It could simplified as below:

 

Procedure LoadFile;
VAR
    top, left, bottom, right:REAL;

BEGIN
{VectorWorks Version 26.0.5(6227681)}

{Global Characteristics}

DrwSize(1,1);
SetUnits(0,1,0,2.54,'cm','cmq');

{End of Global Characteristics}


{Object Creation Code}

NameClass('None');
RectangleN(-214,-147,0.1,0,400,300);
objectHandle := LNewObj;

{End of Creation Code}


END;

Run(LoadFile);

 

Pay attention that the 

Procedure " LOAD FILE " at the very top must to match to the

RUN(LOAD FILE);

 

That's all to start!

Have fun

 

L.

Link to comment

Thanks to all, this has indeed gotten me started. Jesse I had previously read your tutorial but lost track of it, thanks so much. I have created the point pio I wanted and it pulls in the file name and has the fields as I planned.  Right now I am writing code to get the layer scale and make it scale correctly with some math, is there a more elegant solution?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...