Jump to content

AEChadwick

Member
  • Posts

    44
  • Joined

  • Last visited

Posts posted by AEChadwick

  1. Just to keep everyone up-to-date as I flail along. (This post live from behind Kitchen Stadium as we load in Series 11.)

    This script compiles but the pop-up is greyed out, useless! Why doesn?t it fill up? Just stubborn is my guess. I?m going to keep trying to comprehend Events as the kitchen comes together. (Note, if some of the lines are inscrutable, I'll admit, it's because copy-pasta... I just keep trying snippets and bits.)

    I appreciate all the help, and look forward to any more insights!

    PS. shout out to Mr Joshua, you've offered excellent advice in several threads.

    {Script includes PARAMETER... Type: POP-UP, Name: theHatchPopup, Number: 3}

    {Event Enable: Go Properties > Execution Options > check "Event Based," "Reset on Move," "Reset on Rotate"}

    PROCEDURE Plugin;

    CONST

    theResource = 105; {Hatches}

    thePlace = 0; {Current Document}

    displayString = ''; {Nothing}

    VAR

    theEvent, theMessage :LONGINT;

    HatchResourceListID : LONGINT;

    HatchNumResources : LONGINT;

    HatchNumResourcesDo : INTEGER;

    HatchCount : INTEGER;

    HatchResourceString : STRING;

    x, y, w, h, LineLength, BoxWidth : REAL;

    wLeft, wBottom, wRight, wTop : REAL;

    result : BOOLEAN;

    objname : STRING;

    oh,rh,wh : HANDLE;

    theSelectedHatch : STRING;

    itsBeenHatched : BOOLEAN;

    PROCEDURE MakeItClassy(theClass : STRING);

    BEGIN

    SetClass(LNewObj, theClass);

    SetFillColorByClass(LNewObj);

    SetPenColorByClass(LNewObj);

    SetFPatByClass(LNewObj);

    SetLWByClass(LNewObj);

    SetLSByClass(LNewObj);

    SetOpacityByClass(LNewObj);

    END;

    BEGIN {the main body}

    {Build Hatch Popup}

    vsoGetEventInfo(theEvent, theMessage);

    CASE theEvent OF

    41: {kObjOnWidgetPrep}

    BEGIN

    HatchResourceListID := BuildResourceList(theResource,thePlace, displayString,HatchNumResources);

    vsoWidgetPopupClear(3);

    If HatchNumResources > 0 then

    Begin

    For HatchCount := 1 to HatchNumResources Do

    Begin

    HatchResourceString := GetNameFromResourceList(HatchResourceListID,HatchCount);

    vsoWidgetPopupAdd(3,HatchResourceString,HatchResourceString);

    End;

    End;

    vsoSetEventResult(-8); {kObjectEventHandled}

    END;

    END; {of Case}

    {Build Shape}

    result:= GetCustomObjectInfo(objname,oh,rh,wh);

    IF result THEN BEGIN

    w := PLINELENGTH;

    h := PBOXWIDTH;

    wLeft:=x; wBottom:=y-(h/2); wRight:=x+w; wTop:=y+(h/2);

    Rect(wLeft,wBottom,wRight,wTop);

    MakeItClassy('SET-(5) thick (thick)');

    theSelectedHatch := PtheHatchPopup;

    itsBeenHatched := SetVectorFill(LNewObj, theSelectedHatch);

    END; {Build shape.}

    END; {the main body}

    RUN(Plugin);

  2. alright?I need to go get lunch (who spends the 4th of July scripting, anyway?!)

    Current non-functioning code below. (add a head-on-wall when I figured out "oh, right, Parameter Number...")

    Submitted for review:

    ***revised again, update below***

    {includes PARAMETER... Type: POP-UP, Name: theHatchPopup, Number: 3}

    {Event Enable: Go Properties > Execution Options > check "Event Based," "Reset on Move," "Reset on Rotate"}

    PROCEDURE BuildHatchPopup;

    CONST

    theResource = 105; {Hatches}

    thePlace = 0; {Current Document}

    VAR

    HatchResourceListID : LONGINT;

    HatchNumResources : LONGINT;

    HatchNumResourcesDo : INTEGER;

    HatchCount : INTEGER;

    HatchResourceString : STRING;

    x, y, w, h, LineLength, BoxWidth : REAL;

    wLeft, wBottom, wRight, wTop : REAL;

    result : BOOLEAN;

    objname : STRING;

    oh,rh,wh : HANDLE;

    theSelectedHatch : STRING;

    itsBeenHatched : BOOLEAN;

    41: {kObjOnWidgetPrep}

    BEGIN

    HatchResourceListID := BuildResourceList(theResource,thePlace,'',HatchNumResources);

    vsoWidgetPopupClear(3);

    If HatchNumResources > 0 then

    Begin

    For HatchCount := 1 to HatchNumResources Do

    Begin

    HatchResourceString := GetNameFromResourceList(HatchResourceListID,HatchCount);

    vsoWidgetPopupAdd(3,HatchResourceString,HatchResourceString);

    End;

    End;

    vsoSetEventResult(-8); {kObjectEventHandled}

    END;

    PROCEDURE MakeItClassy(theClass : STRING);

    BEGIN

    SetClass(LNewObj, theClass);

    SetFillColorByClass(LNewObj);

    SetPenColorByClass(LNewObj);

    SetFPatByClass(LNewObj);

    SetLWByClass(LNewObj);

    SetLSByClass(LNewObj);

    SetOpacityByClass(LNewObj);

    END;

    BEGIN

    {Build Shape}

    result:= GetCustomObjectInfo(objname,oh,rh,wh);

    IF result THEN BEGIN

    w := PLINELENGTH;

    h := PBOXWIDTH;

    wLeft:=x; wBottom:=y-(h/2); wRight:=x+w; wTop:=y+(h/2);

    Rect(wLeft,wBottom,wRight,wTop);

    MakeItClassy('SET-(5) thick (thick)');

    theSelectedHatch := PtheHatchPopup; {I just know this is wrong?}

    itsBeenHatched := SetVectorFill(LNewObj, theSelectedHatch);

    END;

    {Done building shape.}

    END;

    RUN(BuildHatchPopup);

  3. Here is a quick attempt to draw a box and fill it with a dynamically selected hatch. It does not work!

    I am confident an {Addict} can explain it to me {Greenhorn}. (I swear this is just my programming experiment, you're not doing my homework assignment for me.)

    ??

    ***several dummy mistakes in this, please ignore it, update below***

    {Script includes PARAMETER... Type: POP-UP, Name: 9999}

    PROCEDURE BoxHatcher;

    CONST

    theResource = 105; {Hatches}

    thePlace = 0; {Current Document}

    VAR

    HatchResourceListID : LONGINT;

    HatchNumResources : LONGINT;

    HatchNumResourcesDo : INTEGER;

    HatchCount : INTEGER;

    HatchResourceString : STRING;

    x, y, w, h, LineLength, BoxWidth : REAL;

    wLeft, wBottom, wRight, wTop : REAL;

    result : BOOLEAN;

    objname : STRING;

    oh,rh,wh : HANDLE;

    theSelectedHatch : STRING;

    itsBeenHatched : BOOLEAN;

    PROCEDURE MakeItClassy(theClass : STRING);

    BEGIN

    SetClass(LNewObj, theClass);

    SetFillColorByClass(LNewObj);

    SetPenColorByClass(LNewObj);

    SetFPatByClass(LNewObj);

    SetLWByClass(LNewObj);

    SetLSByClass(LNewObj);

    SetOpacityByClass(LNewObj);

    END;

    BEGIN

    HatchResourceListID := BuildResourceList(theResource,thePlace,'',HatchNumResources);

    vsoWidgetPopupClear(9999);

    If HatchNumResources > 0 then

    Begin

    For HatchCount := 1 to HatchNumResourcesDo

    Begin {<---- this line gets called out with [ Error: Expected DO ] }

    HatchResourceString := GetNameFromResourceList(HatchResourceListID,HatchCount);

    vsoWidgetPopupAdd(9999,HatchResourceString,HatchResourceString);

    End;

    End;

    {Build Shape}

    result:= GetCustomObjectInfo(objname,oh,rh,wh);

    IF result THEN BEGIN

    w := PLINELENGTH;

    h := PBOXWIDTH;

    wLeft:=x; wBottom:=y-(h/2); wRight:=x+w; wTop:=y+(h/2);

    Rect(wLeft,wBottom,wRight,wTop);

    MakeItClassy('SET-(5) thick (thick)'); {?forgive my class names}

    theSelectedHatch := P9999; {I just know this is NOT how to transfer that info?}

    itsBeenHatched := SetVectorFill(LNewObj, theSelectedHatch);

    END;

    {Done building shape.}

    END;

    RUN(BoxHatcher);

  4. Hello DWorks! Thank you for your assessment!

    I have implemented both of the "simple" ideas; entering a custom string is fine but problematic, and the hard-coded pop-up choices is very limiting, and a modal dialog box would be intrusive and defeat the intended ease of the tool. (As a certified Lazy Designer I am attempting to make my PIO do as much of the work for me as possible.)

    The most flexible and desirable solution would be populate the parameter's choices with a list of available hatches. (I can't imagine I'm the only person who has ever wanted a slick dynamic hatch popup...? whoever provides insight/code will be a hero, a hero I tell you!)

    I am not opposed to the work?I am simply overwhelmed by the obtuseness of the related texts. For example, despite numerous references to "PIO must be event-enabled," I have not actually found a single clear explanation of how to do that; mostly, I just encounter other poor bastards like myself.

  5. My PIO includes a pop-up to apply a background hatch.

    Currently, the selections are hard-coded into the Parameter's "choices" (each hatch, by name, really basic).

    It would be better to populate the info-palette Pop-Up button with a list of all hatches in the document?a dynamic list that shows available hatches (like, including new hatches as they are added).

    Has anyone achieved this? can you describe the code, or provide a snippet?

    My searches have been inconclusive, or maybe so far beyond my modest abilities I can't understand them... the most common result, Parametric Custom Shape Pane, is a little erudite for my interpretation. (if anyone could explain-it-like-I'm-5-years-old, I would be grateful!)

    ?

  6. Is there a simple way to determine if a number is odd or even? PASCAL math commands include ODD(x), but this appears missing from Vectorscript.

    I tried ODD anyway, and got this error.

    [font:Courier New] if ODD(wLights) then [do some stuff based on wLights];

    |

    { Error: Identifier not declared. }

    |

    { Error: Expected a string. }

    |

    { Error: Expected a Boolean. }

    |

    { Error: Did not expect this after end of statement - missing ;? }

    [/font]

    (wLights is declared, I think the error is asking about "ODD")

    Alternately, is there perhaps a way to determine factors? I could simply check if a number is divisible by 2 or 3...

    I might be missing something obvious, but I have honestly been scouring the language guide and the developer reference. I appreciate any ideas!

  7. Thank you, that is excellent. Just tested, it works exactly as you describe.

    (Honestly, I searched the Language Guide repeatedly, I clearly missed these instructions. I did find EncryptVSPluginFilePath as you mention http://developer.vectorworks.net/index.php?title=VCOM:VectorWorks:ISDK::EncryptVSPluginFilePath and was on the verge of attempting that process. I really appreciate you lending a different set of eyes to guide me along!)

    PS. looking forward to that automator workflow! :)

    ?

  8. I have been using VectorWorks for years, but I am a dreadful novice at Vectorscript.

    Here is my attempt to create a title block that auto-updates using information from its own filename.

    To explain? I always name files in the same format, with all files for a single show living in their own folder. ie., SHOW FOLDER : SET-EPISODE-Name.vwx

    So a complete string might be DexterS6 : 862-612-Int Modest House.vwx

    means "Dexter" Set #862 for Episode 612, "Interior Modest House."

    Sometimes the names vary slightly, like

    Torchwood : AMORT-ALL EPISODES-FBI Headquarters.vwx

    means "Torchwood" Permanent (amortized) Set, "FBI Headquarters."

    But it's always simply strings separated by hyphens. (ie., the set "numbers" are for reference?they are not part of any calculation, so they're not integers.)

    My title block is a dead simple line of text?really it?s little more than the most essential information, please see the attached file.

    Below is my attempt to script the named stamps? Needless to say, my work is little better than pseudocode, and does not compile cleanly!

    I hope some VectorScript genius can lend a hand! I will credit you & praise you in the final script, which will be handed down into posterity. :)

    ??

    { ////////////////////

    TitleBlock Stamper

    Modified from Scripts by Sakkinen & David LaBarbera

    and using 'Txt-Extract char separated' from www.vectorlab.info

    //////////////////// }

    FUNCTION StampIt(VAR textObjectName: STRING; stampString: STRING): STRING;

    BEGIN

    textH := GetObject(textObjectName);

    IF textH = NIL THEN

    BEGIN

    Sysbeep;

    AlrtDialog('You must have a text block named ' & textObjectName & ' for this command to work!');

    END;

    SetText(textH, stampString);

    { //////////////////// }

    FUNCTION ExtractCharSep(VAR str: STRING; ch: CHAR): STRING;

    VAR

    posStr?: INTEGER;

    BEGIN

    ExtractCharSep?:= '';

    { char sep at start deleted }

    WHILE (Len(str) > 1) & (Pos(ch, str) = 1) DO

    str?:= Copy(str, 2, Len(str));

    IF Len(str) > 0 THEN BEGIN

    posStr?:= Pos(ch, str);

    IF posStr > 0 THEN BEGIN

    ExtractCharSep?:= Copy(str, 1, posStr-1);

    Delete(str, 1, posStr);

    END ELSE

    ExtractCharSep?:= str;

    END;

    END;

    { //////////////////// }

    Procedure StampDL;

    VAR

    textH : HANDLE;

    stampString : STRING;

    dateValue, docName, setNumber, episodeNumber, setName : STRING;

    BEGIN

    docName := GetFName;

    setNumber := ExtractCharSep(docName, '-');

    episodeNumber := ExtractCharSep(docName, '-');

    setName := ExtractCharSep(docName, '.');

    dateValue := Date(1, 1);

    {Date ( [0=Full, 1=Abbrev, 2=Short], [0=Date, 1=Date & Time, 2=Time]) }

    stampIt('Set Stamp', setNumber)

    stampIt('Episode Stamp', episodeNumber)

    stampIt('Name Stamp', setName)

    stampIt('Date Stamp', dateValue)

    END;

    RUN (StampDL);

×
×
  • Create New...