Jump to content
Developer Wiki and Function Reference Links ×

use oip with plugin tool


Recommended Posts

So,

 

I have built a plugin that makes a Title block that will fit my companies work flow, I have created it as various plug in types but haven't gotten exactly the behavior I want.  when I run the code as a command it doesn't create a high level object and permit me to edit it with the oip.  If I make it as a single point object it does, but I want the position and rotation to be locked.  when I run it as a tool rotation is locked, but position isn't and I cant access parameters in the OIP.  Is there a Container I need to build the objects inside of to keep the OIP functionality? I have tried group and symbol to no avail. 

 

Procedure TitleBlock;

const
    kUnit=1;


VAR
    H1, H2, H3, H4 : handle;
    p1, p2 : point;
    width, height, rMargin, rLayerScale, rU : real;
    rPageHeight:real;
    sShipDate, sOrderNum, sDocName, sStartDate :string;
    sShowDates, sDrawnBy, sCompanyName, sSheetTitle, sLayerName:string; 
    iDimg:handle;
    iCompanyNameLength, iTotalPages, iPageNum: integer;

{**************************Main Code Block*********}

BEGIN;

{Set parameteers}

sLayerName:=GetLName(ActLayer);
sSheetTitle:=sLayerName;
iCompanyNameLength:=PiCompanyNameLength;
sDrawnBy:=PsDrawnBy;
sShowDates:=PsShowDates;
sStartDate:=PsStartDate;
iPageNum:=PiPageNum;
iTotalPages:=PiTotalPages;
sShipDate:=PsShipDate;
{******************}
sDocName:=(GetFName);
sOrderNum:=Copy(sDocName,1,6);
sCompanyName:=Copy(sDocName,7,iCompanyNameLength);

rLayerScale := GetLScale(ActLayer);
rU:=kUnit*rLayerScale;

GetDrawingSizeRectN(ActLayer,p1.x,p1.y,p2.x,p2.y);
rPageHeight:=Distance(p2.x,p1.y,p2.x,p2.y);


rMargin :=PrMargin*rLayerScale;


{**********************Primary Rectangle container***********}
{RectangleN(orgin, direction, width, height)}

width:=1.72*rU;
height:=rPageHeight-(rMargin*2);
RectangleN(p2.x-width-rMargin,p2.y+rMargin, 1, 0, width, height);

{*********************Page Num Rect***********************************}

MoveTo(p2.x-width-rMargin+(.0625*rU),p2.y+rMargin+(.0625*rU)); { set pen position }
Rect(width-(.0625*2)*rU, #0, (.538*rU), #90); 
    {***********text Label*********}    
        Relative;
        MoveTo(.377*rU,(.43*rU));
        TextSize(10);        
        BeginText;
        concat('PAGE #:')
        EndText;
        Absolute;
MoveTo(p2.x-width-rMargin+(.0625*rU),p2.y+rMargin+(.0625*rU));

    {***********page numbering*********}    
        Relative;
        MoveTo(width/2-(.065*rU),(.165*rU));
        TextSize(12);        
        BeginText;
        concat(iPageNum,' OF ',iTotalPages)
        EndText;
        Absolute;

{*****************ship date Rect**********************}

MoveTo(p2.x-width-rMargin+(.0625*rU),p2.y+rMargin+(.0625*rU)+(.538+.0625)*rU); { set pen position }

Rect(width-(.0625*2)*rU, #0, (.538*rU), #90); 
    {***********text Label*********}    
        Relative;
        MoveTo((.5*rU),(.43*rU));
        TextSize(10);        
        BeginText;
        concat('SHIP DATE:')
        EndText;

    {***********SHIP DATE*********}    
        MoveTo((.353*rU),(-.265*rU));
        TextSize(12);        
        BeginText;
        concat(sShipDate)
        EndText;
        Absolute;

{*****************Order Number Rect**********************}

MoveTo(p2.x-width-rMargin+(.0625*rU),p2.y+rMargin+(.0625*rU)+((.538+.0625)*2)*rU); { set pen position }

Rect(width-(.0625*2)*rU, #0, (.538*rU), #90); 
    {***********text Label*********}    
        Relative;
        MoveTo((.445*rU),(.43*rU));
        TextSize(10);        
        BeginText;
        concat('ORDER #:')
        EndText;

    {***********Order Number*********}    
        MoveTo((.353*rU),(-.265*rU));
        TextSize(12);        
        BeginText;
        concat(sOrderNum)
        EndText;
        Absolute;

{*****************Downing Logo Rect**********************}

MoveTo(p2.x-width-rMargin+(.0625*rU),p2.y+rMargin+(.0625*rU)+((.538+.0625)*3)*rU); { set pen position }

Rect(width-(.0625*2)*rU, #0, (3.125*rU), #90);
iDimg:=ImportImageFile('C:\Users\jstewart\Desktop\Vectorworks scripting\downingjpg.jpg',(p2.x-((.86*rU)+rMargin)),(p2.y+(3.308*rU)+rMargin));
    
{*****************Start show drwn boxes**********************}

MoveTo(p2.x-width-rMargin+(.0625*rU),p2.y+rMargin+(.0625*rU)+((.538+.0625)*3+3.1875)*rU); { set pen position }
Rect(.49*rU, #0, (1.5*rU), #90);

Relative;
MoveTo((.49+.0625)*rU,0);
Rect(.49*rU, #0, (1.5*rU), #90);

MoveTo((.49+.0625)*rU,0);
Rect(.49*rU, #0, (1.5*rU), #90);
Absolute;

MoveTo(p2.x-width-rMargin+(.0625*rU),p2.y+rMargin+(.0625*rU)+((.538+.0625)*3+3.1875)*rU); { set pen position }
    
    {***********start date text Label*********}    
        Relative;
        MoveTo(.110833*rU,.75*rU);
        TextRotate(90);
        TextSize(8);        
        BeginText;
        concat('START DATE')
        EndText;
        H1:=LNewObj;
        SetTextStyle(H1,0,11, 4);

    {***********Start Date*********}    
        MoveTo(.24*rU,0);
        TextSize(12);        
        BeginText;
        concat(sStartDate)
        EndText;
    
    {***********Show Dates text Label*********}    
        Relative;
        MoveTo(.309861*rU,0);
        TextRotate(90);
        TextSize(8);        
        BeginText;
        concat('SHOW DATES')
        EndText;
        H1:=LNewObj;
        SetTextStyle(H1,0,11, 4);

    {***********Show Dates*********}    
        MoveTo(.24*rU,0);
        TextSize(12);        
        BeginText;
        concat(sShowDates)
        EndText;
        
{***********drawn by text Label*********}    
        Relative;
        MoveTo(.309861*rU,0);
        TextRotate(90);
        TextSize(8);        
        BeginText;
        concat('DRAWN BY')
        EndText;
        H1:=LNewObj;
        SetTextStyle(H1,0,11, 4);

    {***********Drawn By*********}    
        MoveTo(.24*rU,0);
        TextSize(12);        
        BeginText;
        concat(sDrawnBy)
        EndText;
        Absolute;

{****************revision block **************}
iDimg:=ImportImageFile('C:\Users\jstewart\Desktop\Vectorworks scripting\revisionbox.jpg',(p2.x-((.86*rU)+rMargin)),(p2.y+(16.196795*rU)+rMargin));


{*******************************Title Rect************************}
MoveTo((p2.x-width-rMargin+(.0625*rU)),p2.y+rMargin+6.614705*rU);
Rect(1.6074*rU, #0, 8.045186*rU, #90);

{***********Company name and LayerName text Label*********}    
        Relative;
        MoveTo(.602033*rU,4.022593*rU);
        TextRotate(90);
        TextSize(24);        
        BeginText;
        concat(sCompanyName,' / ',sSheetTitle)
        EndText;
        H1:=LNewObj;
        SetTextStyle(H1,0,50, 5);

{***************scale  ************************}

        MoveTo(.445261*rU,-1.784770*rU);
        TextRotate(90);
        TextSize(18);        
        BeginText;
        concat('SCALE 1:300')
        EndText;
        H1:=LNewObj;
        SetTextStyle(H1,0,50, 1);

{message(concat(rPageheight,' ',width,' ',height,' ',rlayerscale,' ',rU));}
END;


Run(TitleBlock);

 

Link to comment

If I follow you correctly... you should be able to do what you want.     From the menu command you'll need to tell the PIO what to do...  something like...  

 

             { Your Plugin Object for Title Block } 
             MyTitleBlockHhandle := CreateCustomObject('Your title Block Plugin Object',0,0,0);
             SetRField(MyTitleBlockHhandle,'Show date', TheDate,'x/xx/xxxx');
             SetRField(MyTitleBlockHhandle,'Start date', ThestartDate,'x/xx/xxxx');
             
             HMove(MyTitleBlockHhandle, xOffset, yOffset );
             HRotate(MyTitleBlockHhandle, centerX,centerY,rotationAngle );

 

 

Link to comment

If you want to place it from the Menu Command you will still need a Plug-in Object so the parameter fields show in the OIP.

 

I think you are best making it as a PIO or a Tool.  Take a look at the built in Title Block Border object. It has a parameter names something like Lock to Page Center.

 

So when you place the Title Block you have it move itself to the place you want no mater where the user clicks.

Link to comment

I have made it by choosing the "command" radio button after clicking "new" in the plug in manager, it uses the default values of the parameters and creates 22 independent objects in the correct location and rotation. I can select any of them and interact with them the same as if I had drawn them individually, not through the OIP

 

I have also made it  by choosing the "tool" radio button after clicking "new" in the plug in manager, If you double click the tool on the palette you can edit all to parameters before the script gets executed, but then it draws 22 independent objects in the correct location and rotation. I can select any of them and interact with them the same as if I had drawn them individually, not through the OIP

 

I have also made it by choosing the "point object" radio button after clicking new in the plug in manager, If you double click the tool on the palette you can edit all to parameters before the script gets executed, when you click in the drawing area it shows a silhouette of the geometry that will be created and permits you to set a rotation. When yo select the object created you can edit the parameters from the object info palette. 

 

What "container" does a single point plug in object put my code in that permits it to be viewed by vw as a single object with parameters? 

 

Can I add this "Container" to the code I used for the plugin in object "command" or "tool"?

 

  

Link to comment

There is not "container" and you can not add it to the other two options.

 

They are three completely separate object types.  

 

Menu commands have no default user interface and just create a script that can be added to a workspace as a menu command.

 

Tools allow access to Modes in the Mode bar and are really designed to allow you to either interact with objects already in the drawing or to create basic geometry that is then used to configure a Plug-in Object

 

The Plug-In Object (Point, Line, Rectangle) are designed so that any parameters you set up are accessible from the OIP. If you add a PIO to a tool palette then you get basic interaction with the drawing to place and rotate the object.

 

If you don't want the user to be able to do that, then just ignore those inputs and have the object draw where you want it to be.  They will probably get the "preview" before they make the second click, but if you don't use that information it does not matter.

 

Or use a menu command to place the Plug-In Object where you want it. I believe the function for this is CreateCustomObjectN.

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...