Jump to content

MaxStudio

Member
  • Posts

    319
  • Joined

  • Last visited

Posts posted by MaxStudio

  1. Thats where I'm getting confused... do i create and define the parameters through the plugin editor before I encrypt the script? Lets say I do, do I copy anything into the "script" area?

    i did some screen shots to help explain:

    Image01: (the parameters defined)

    hNnJvPY.png

    Image02: (nothing pasted in script editor, should there be?)

    kJZjiws.png

    Image03: (this is the file name before encrypting)

    gwzxGzr.png

    Image04: (the file i choose to encrypt)

    HpYMftX.png

    Image05: (the encrypted file I save and the location, what extension should this file have, notice there is already a file in the folder named 'CreateRectangle.vso' because of the parameters I created in vectorworks, do i choose to overwrite that file or create a new one?)

    5kRMGMx.png

    What do you think?

  2. I'm sorry I'm confused and not having success. Do i need to set up the script in the vectorscript plugin editor with all my parameters before encrypting?

    Normally without encrypting I do the following:

    1. Create the script parameters in the VS Plugin Editor with the plugin name CreateRectangle.

    2. Paste my script in the script area and compile.

    3. Add it to my workspace.

    4. It works.

    This is the process i'm attempting to going through now:

    1. Create the script parameters in the VS Plugin Editor with the plugin name CreateRectangle.

    2. Encrypt the script by selecting the CreateRectangle.px file

    3. Save the new CreateRectangle plugin file to the Plugins folder. Should this have an extension? It doesn't seem to save with one.

    4. Then i shut down vectorworks and restart.

    I don't understand how the newly created encrypted plugin connects to the parameters in the VS Plugin Editor. I must be doing something wrong or out of order.

    also when you say to comment out the variable definitions is this what you mean?

    PROCEDURE plugin;
    VAR
    
    x, y, width, height:REAL;
    
    result		: BOOLEAN;
    objname		: STRING;
    oh,rh,wh		: HANDLE;
    
    BEGIN
    { retrieve custom object information }
    result:= GetCustomObjectInfo(objname,oh,rh,wh);
    
    { if object information was successfully retrieved }
    IF result THEN BEGIN
    	{ retrieve parameters }
    
    {  width	:= PWIDTH;
       height	:= pHEIGHT;  }
    
    
    {$INCLUDE Macintosh HD:Users:Library:Plugins:draw.px}
    
    END;
    
    END;
    
    RUN(plugin);

    I really appreciate your help. Thanks

  3. This is the .px that I select when encrypting

    PROCEDURE plugin;
    VAR
    
    x, y, width, height:REAL;
    
    result		: BOOLEAN;
    objname		: STRING;
    oh,rh,wh		: HANDLE;
    
    BEGIN
    { retrieve custom object information }
    result:= GetCustomObjectInfo(objname,oh,rh,wh);
    
    { if object information was successfully retrieved }
    IF result THEN BEGIN
    	{ retrieve parameters }
    
    	width	:= PWIDTH;
    	height	:= pHEIGHT;
    
    
    {$INCLUDE Macintosh HD:Users:Library:Plugins:draw.px}
    
    END;
    
    END;
    
    RUN(plugin);

    Then the draw.px file has the following:

     Rect(x, y, width, height);

    When I run the Encrypt on the first px file it tells me:

    width := PWIDTH; (identifier not declared)

    height := pHEIGHT; (identifier not declared)

    I'm not sure what is going on. How do the variables interact with the parameters in the VS Plugin Editor? How does the script know what the default parameters are? I'm guessing that disconnect has something to do with it.

  4. so if the plugin is stored in the plugin folder my px files need to be stored there as well? (only until encrypted... then i can remove them?)

    I know what you mean with the empty line. I've run into the problem many times where I didn't hit return after I pasted an IF THEN statement. I usually ended up being told that I'm missing an END; the fix is just going back to the include file and hitting return after the END; and it then compiles correctly.

  5. Is that as easy as saving them with a .px extension from my text editor?

    I'm also interested and best practices when it comes to the location of the include files.

    Currently, I have a central folder on my computer where I store all my plugin scripts. Each plugin has its own subfolder. Once the plugin is encrypted does it still need access to the files in this folder or does it become one all encompassing plugin file?

    I'll perform some tests in the days ahead.

  6. I believe a long while back I wrote a script that ended up being to many characters for the script editor. Since then, I've been using includes to break down my scripts into smaller pieces. I really like working this way, but is it possible to encrypt the script along with the referenced include files?

  7. but even if I remove click:=1; from the retrieve parameter section nothing seems to change; the object still does not rotate.

    if I change click:=1; to click:=2; it draws the rectangle then rotates it 15 degrees, but the button does not do anything. This leads me to believe something is wrong with the way I'm setting or getting the field, or something is coded incorrectly in the

    CASE theButton OF buttonID_1: section

    ...

  8. Ok, so in the last example i was able to get the rectangle to grow 12" everytime I clicked the button.

    In this next example I want the rectangle to rotate. Each time I click the button I want the rotation to be assigned a new value via the CASE OF.

    What I want to happen:

    1. rectangle is created (click is set to 1, rotation set to 0)

    2. button pressed (click does not = 4, becomes click + 1, click becomes 2, rotation set to 15)

    3. button pressed again (click does not = 4, becomes click + 1, click becomes 3, rotation set to 30)

    3. button pressed again (click does not = 4, becomes click + 1, click becomes 4, rotation set to 45)

    4. button pressed again (click does = 4, click becomes 1, rotation set to 0)

    It draws the rectangle, but it's not rotating. I know I'm doing something wrong any ideas on this one?

    PROCEDURE Example3;
    
    CONST
    
    kObjOnInitXProperties = 5;
    kResetEventID = 3;
    kObjXPropHasUIOverride = 8;
    kWidgetButton = 12;
    kObjOnObjectUIButtonHit = 35;
    buttonID_1 = 1234; {user-definable index}
    
    VAR
    
    theEvent, theButton :LONGINT;
    result :BOOLEAN;
    sourceFieldNumber :INTEGER;
    buttonEventID :INTEGER;
    displayString :STRING;
    thisDoesNothing :LONGINT;
    
    x,y,w,h,rotate:REAL;
    click:LONGINT;
    f:STRING;
    H1:HANDLE;
    
    
    result2		:BOOLEAN;
    objname		:STRING;
    oh,rh,wh	:HANDLE;
    
    BEGIN
    
    { retrieve custom object information }
    result2:= GetCustomObjectInfo(objname,oh,rh,wh);
    
    { if object information was successfully retrieved }
    	IF result2 THEN BEGIN
    		{ retrieve parameters }
    
    		w		:= Pw;
    		h		:= Ph;
    
    		click:=1;
    		f:=Num2Str(0,click);
    		SetRField(oh,objname,'click',f);
    
    		END;
    
    
    BEGIN
    
    vsoGetEventInfo(theEvent, theButton);
    
    CASE theEvent OF
    {User has single-clicked the objects icon.}
    
    	kObjOnInitXProperties:
    
    		BEGIN
    
    			{This tells VW to let the object decide what goes onto the Object Info palette.}
    
    			result := SetObjPropVS(kObjXPropHasUIOverride, TRUE);
    
    			{Now we manually add the "normal" parameters...}
    			{One way is to use this single call to add all of the existing parameters.}
    
    			result := vsoInsertAllParams;
    
    			{Finally, we add the button.}
    
    			displayString := 'My Great Button';
    
    			result := vsoAppendWidget(kWidgetButton, buttonID_1, displayString, thisDoesNothing);
    
    		END;
    
    
    
    {User has clicked a button in the Object Info palette.}
    
    kObjOnObjectUIButtonHit:
    
    BEGIN
    
    	CASE theButton OF buttonID_1:
    
    		BEGIN 
    
    			f:=GetRField(oh,'click',f);
    			click:=Str2Num(f);
    
    			IF (click=4) THEN BEGIN
    
    				click:=1;
    				f:=Num2Str(0,click);
    				SetRField(oh,objname,'click',f);
    
    			END
    			ELSE BEGIN
    
    				click:=click+1;
    
    				f:=Num2Str(0,click);
    				SetRField(oh,objname,'click',f);
    
    			END;
    
    			ResetObject(oh);
    
    			SysBeep;
    
    	END;
    
    END;
    
    END;
    
    
    {Object reset has been called.}
    
    kResetEventID:
    
    BEGIN
    
    	CASE click OF
    
    	1:	BEGIN
    
    			rotate:=0;
    
    		END;
    
    	2:	BEGIN
    
    			rotate:=15;
    
    		END;
    
    	3:	BEGIN
    
    			rotate:=30;
    
    		END;
    
    	4:	BEGIN
    
    			rotate:=45;
    
    	END;
    
    END;
    
    Rect(x, y, x+w, y+h);
    H1:=LNewObj;
    HRotate(H1,x,y,rotate);
    
    END;
    
    END;
    
    END;
    
    END;
    
    Run(Example3);

  9. Ok, so it draws the rectangle but when i click the button it changes the new width of the rectangle to 12 instead of adding the 12 to the original x. I know i'm doing something wrong just not sure what.

    PROCEDURE Example3;
    
    CONST
    
    kObjOnInitXProperties = 5;
    kResetEventID = 3;
    kObjXPropHasUIOverride = 8;
    kWidgetButton = 12;
    kObjOnObjectUIButtonHit = 35;
    buttonID_1 = 1234; {user-definable index}
    
    VAR
    
    theEvent, theButton :LONGINT;
    result :BOOLEAN;
    sourceFieldNumber :INTEGER;
    buttonEventID :INTEGER;
    displayString :STRING;
    thisDoesNothing :LONGINT;
    x,b,d:REAL;
    a,c:STRING;
    
    
    result2		:BOOLEAN;
    objname		:STRING;
    oh,rh,wh	:HANDLE;
    
    BEGIN
    
    { retrieve custom object information }
    result2:= GetCustomObjectInfo(objname,oh,rh,wh);
    
    { if object information was successfully retrieved }
    IF result2 THEN BEGIN
    { retrieve parameters }
    
    	x   := Px;
    
    	b:=0;
    
    	END;
    
    
    BEGIN
    
    vsoGetEventInfo(theEvent, theButton);
    
    CASE theEvent OF
    {User has single-clicked the objects icon.}
    
    kObjOnInitXProperties:
    
    	BEGIN
    
    	{This tells VW to let the object decide what goes onto the Object Info palette.}
    
    	result := SetObjPropVS(kObjXPropHasUIOverride, TRUE);
    
    	{Now we manually add the "normal" parameters...}
    	{One way is to use this single call to add all of the existing parameters.}
    
    	result := vsoInsertAllParams;
    
    	{Finally, we add the button.}
    
    	displayString := 'My Great Button';
    
    	result := vsoAppendWidget(kWidgetButton, buttonID_1, displayString, thisDoesNothing);
    
    END;
    
    
    
    {User has clicked a button in the Object Info palette.}
    
    kObjOnObjectUIButtonHit:
    
    	BEGIN
    
    		CASE theButton OF buttonID_1:
    
    			BEGIN 
    
    				AlrtDialog('Custom Button Dialog');
    
    				b:=b+12;
    
    				a:=Num2StrF(b);
    
    				SetRField(oh,objname,'x',a);
    
    				ResetObject(oh);
    
    
    			END;
    
    	END;
    
    END;
    
    
    {Object reset has been called.}
    
    kResetEventID:
    
    BEGIN
    
    x:=Px;
    
    c:=GetRField(oh,'x',a);
    
    b:=Str2Num(c);
    
    d:=b+x;
    
    Rect(0, 0, d, 1);
    
    END;
    
    END;
    
    END;
    
    END;
    
    Run(Example3);

  10. Using the link you provided and example 3 I was able to get the button to be created.

    I started doing a few test to see if I could get the square object to change size when the button is clicked. I changed the second x coordinate in the rect (0, 0, 1, 1) to an 'x' variable.

    x:=1;

    rect(0,0,x,1)

    when the button is clicked:

    x:=x+12;

    Unfortunately, I'm not having any luck. I'm not sure if i'm putting my variables in the right places. Below is the original code. Any ideas where I should insert the x:=x=12;?

    PROCEDURE Example3;
    
    CONST
    
    kObjOnInitXProperties = 5;
    kResetEventID = 3;
    kObjXPropHasUIOverride = 8;
    kWidgetButton = 12;
    kObjOnObjectUIButtonHit = 35;
    buttonID_1 = 1234; {user-definable index}
    
    VAR
    
    theEvent, theButton :LONGINT;
    result :BOOLEAN;
    sourceFieldNumber :INTEGER;
    buttonEventID :INTEGER;
    displayString :STRING;
    thisDoesNothing :LONGINT;
    x:REAL
    
    BEGIN
    
    { This is where I placed x:=1; }
    
    vsoGetEventInfo(theEvent, theButton);
    
    CASE theEvent OF
    {User has single-clicked the objects icon.}
    
    kObjOnInitXProperties:
    BEGIN
    
    {This tells VW to let the object decide what goes onto the Object Info palette.}
    
    result := SetObjPropVS(kObjXPropHasUIOverride, TRUE);
    
    {Now we manually add the "normal" parameters...}
    {One way is to use this single call to add all of the existing parameters.}
    
    result := vsoInsertAllParams;
    
    {Finally, we add the button.}
    
    displayString := 'My Great Button';
    
    result := vsoAppendWidget(kWidgetButton, buttonID_1, displayString, thisDoesNothing);
    
    END;
    
    {User has clicked a button in the Object Info palette.}
    
    kObjOnObjectUIButtonHit:
    
    BEGIN
    
    CASE theButton OF buttonID_1:
    
    BEGIN 
    
    AlrtDialog('Custom Button Dialog');
    
    { I thought I could place the x:=x+12; here, but it didn't seem to do anything}
    
    END;
    
    END;
    
    END;
    
    {Object reset has been called.}
    
    kResetEventID:
    
    BEGIN
    
    Rect(0, 0, 1, 1);
    
    END;
    
    END;
    
    END;
    
    Run(Example3);

    Any thoughts?

  11. Im creating a set of objects with the same plugin. The plugin has a user defined string parameter.

    Lets say the string parameter is "name"

    I create object1 and set the name parameter to "Red"

    I create object2 and attempt to set the name parameter to "Red". I would like it to alert me that "Red" is already in use, give me the option to set it to something else, or allow me to override and continue to use "Red".

    Is this possible?

  12. I've created a report for a plugin object and I'm using it to create a schedule. Is there a way to hide the database row which contains all the formulas?

    for example...

    A database row is created at row 5. each plugin gets a row 5.1, 5.2, I want to hide the original row 5 that has the running total and leave all other rows 5.1, 5.2 etc.

    Is this possible?

    thank you

    Derek

×
×
  • Create New...