Jump to content

Julian Carr

Distributor
  • Posts

    320
  • Joined

  • Last visited

Posts posted by Julian Carr

  1. Has anyone figured out how to create a resource folder (other than a symbol folder [type 92]), and if so, what are the Object Type numbers for the various types of resource folders?

     

    [Edit]: Actually all resource folders are type 92, and I have tried using SetParent(), but that doesn't work to put resources into resource folders.

     

    Thanks!

  2. Hi Markus,

     

    I don't know about your command but I do use DeselectAll in a lot of scripts and it continues to work there. Do you know you can also deselect all by holding the Spacebar down then double tapping the X key? The Spacebar preserves the current tool selection. If you don't need this, then just double tapping X will suffice.

     

    Julian

  3. Thanks guys.

    Nicolas: I am the admin user on both machines and if it works on a Mac then, should it not work on a PC? Still, maybe you are right.

    Pat:  Message(GetFolderPath(-1));  also returns the path to application folder on Mac and PC.

    Sam: If you run  Message(GetFolderPath(1));  you will see it does return a separator at the end of the path name.

  4. Anyone know why this code:

     

    Procedure T;

    VAR

    s1 : STRING;

    BEGIN

    s1 := Concat(GetFolderPath(1), 'Test.txt');

    ReWrite(s1);

    WriteLn('test');

    Close(s1);

    END;

    Run(T);

     

    works fine on a Mac but returns this error on a PC:

     

    Error on line=6: T S1 - File operation returned error.

    Error on line=8: T S1 - Bad file name. C:\Program Files\Vectorworks 2018\Test.txt

     

    Thanks!

  5. Thanks again Nicolas. Unfortunately I can't get it to work. A full path such as this will work:

     

        {$INCLUDE /Users/juliancarr3/Desktop/MessageScriptTesting/MessageScript.vss }

     

    but then something like this (or variations thereof), does not work:

     

        {$INCLUDE /MessageScriptTesting/MessageScript.vss }

     

    The Vectorworks file with the saved views is also in the MessageScriptTesting folder.

     

    The following also doesn't work on the Mac which is unusual because I normally use backslashes in include names:

     

        {$INCLUDE \Users\juliancarr3\Desktop\MessageScriptTesting\MessageScript.vss }

  6. We are using a lot of saved views in our training and have added a script to each saved view to open the message window with some instructions that pertain to each particular step. This allows users to be able to work in the file while still having the instructions visible and unaffected by view changes, panning or zooming. The notes for each of the message strings come from a worksheet within the file. There are two things that would make this process better.

     

    1. Being able to get the name of the current saved view that is running the script.

    2. Being able to access the script via an include file.

     

    Can anyone think of a way to do either of these things? Because we run training courses at a 3rd party training venue, we generally can only install the training files in a folder on the Desktop of each machine, so the potential path to any include file will be different on each machine.

     

    Thanks for any ideas.

     

    Julian

     

    PS. I discovered that you can get around the limitation of 256 characters in a message, by concatenating a series of sub 256 character strings together within the message call.

  7. Scale factor is only there to demonstrate the script. If you run the script with the default setting, it should make the page size 1.5 times larger.

     

    If you are the only one using your script then I agree units should not be an issue. If it is anyone else, then the values you are storing should have unit marks so they allow for it. People will always to the unexpected.

  8. It works for me Sam. Try this script as a test:

     

    Procedure T;
    VAR
        x1, y1, x2, y2, ScaleFactor : REAL;
    BEGIN
        ScaleFactor := RealDialog('Scale Factor:', '1.5');
        GetDrawingSizeRectN(ActLayer, x1, y1, x2, y2);
        SetDrawingRect((x2 - x1) * ScaleFactor, (y1 - y2) * ScaleFactor);
        Message((x2 - x1) * ScaleFactor, chr(13), (y1 - y2) * ScaleFactor);
    END;
    Run(T);

     

    Make sure you get the units right tool. Can't remember if it uses document units, mm or inches.

  9. Thanks Josh. I had a bit of a play with it but as you implied, it makes Vectorscript even more of a black box than it is already. Lots of unexplained crashes and mystery.  Two things I have built up immunity to over the years, but I still got the bug with this one.

  10. You will need something like this, which only counts object whose parent is a layer:

     

    PROCEDURE xxxxx;
    VAR
        gNumObjects : INTEGER;
        
        Procedure CountThem(h1 : HANDLE);
        BEGIN
            IF GetType(GetParent(h1)) = 31 THEN gNumObjects := gNumObjects + 1;
        END;
            
    BEGIN
        gNumObjects := 0;
        ForEachObject(CountThem, (Sel = True));
        Message(gNumObjects);
    END;
    RUN(xxxxx);

  11. Thanks Pat and Josh. I think Josh has nailed it with his last suggestion, which seems to work with any units. The script I am working on is for a worksheet and will populate a single cell with all the door IDs that match a particular door type (and optionally width), comma separated. A door type could be an internal door, an external door, the front door of an apartment, or a patio door of a particular style. Sometimes the doors can vary in size but are otherwise the same type. Something like this:

     

        TYPE                ID                   WIDTH     ETC

    |  Type A   |   D01, D04, D07   |   1000   |             |

    |  Type A   |   D02, D03, D05   |    900    |             |

    |  Type B   |   D06, D11, D12   |   1000   |             |

    |  Type B   |   D08, D09, D13   |    900    |             |

     

    The RunScript() function is so powerful it has prompted me to dip my toes into the python pit.

×
×
  • Create New...