Jump to content
Sam Jones

Page Setup (Size) for Sheet Layers

Recommended Posts

Is there a way to access the stored page size of a sheet Layer, and is there a way to set the page size of a sheet layer.  I have been able to get the sheet titles from the description GetObjectVariableString(theLayer,159), but can't find access to the page size.

Share this post


Link to post

Try SetDrawingRect and see if that will do what you want/need.

 

If not, I think you will be stuck with opening the dialog box using DoMenuTextByName.

Share this post


Link to post

You can use GetDrawingSizeRect() to establish the current page size, and SetDrawingRect() to set a new page size.

Share this post


Link to post

Unfortunately, they don't work.  GetDrawingSizeRectN() yields a rect(x1, y1, x2, y2).  When applied to a sheet layers every sheet layer yields 

x1 = -5.5
y1 = 4.25
x2 = 5.5
y2 = -4.25

 

Essentially an 8.5" x 11" sheet, no matter what the page setup is for the sheet layer.  The GetDrawingSizeRectN() is querying empty sheet layers that have different page setups. 

 

Anything else I should try?
 

Share this post


Link to post

Just for background.

I am writing 2 scripts: "WriteLayerStructure" and "GetLayerStructure".  The object is to write layer to a file and to read it back into another file.  Everything works great, except sheet layers don't get their page set up written and read.  I don't care about design layers.  Don't bother bringing up templates.  The scripts are used to bring a layer structure into drawings sent to me by other people.  Actually, the script is for others who are anxiously waiting.

 

Thanks,

S

 

Share this post


Link to post

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.

Share this post


Link to post

Also, I would assume that GetDrawingSizeRectN would use the same units.  As long as I want the same units, would I need to care what they are?

Share this post


Link to post

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.

Share this post


Link to post

Then I don't know what's happening.  The script below writes 8.5 x 11 dimensions for all the sheet layers.  Those sheet layers have different page setups between 8.5 x 11 and 36 x 48.

 

PROCEDURE WriteLayerStructure;
{DEBUG}

 

 

TYPE
    DrawSizeInfo = STRUCTURE
        x1 : REAL;
        y1 : REAL;
        x2 : REAL;
        y2 : REAL;
    END;
    
VAR

    CurrFileName : STRING;
    LayerNum : INTEGER;
    LayerArray : ARRAY[1..100] OF STRING;
    LyrDescrArray : ARRAY[1..100] OF STRING;
    ScaleArray : ARRAY[1..100] OF REAL;
    LTypeArray : ARRAY[1..100] OF INTEGER;
    LDrawSize : ARRAY[1..100] OF DrawSizeInfo;
    

{==============================================================}

 

    PROCEDURE CollectLayerInfo;
    
    VAR
        theLayer : HANDLE;
        layerName : STRING;
        layerDescrip : STRING;
        theScale : REAL;
        theType : INTEGER;
        lyrNum : REAL;
        x1, y1, x2, y2 : REAL;
        
    BEGIN
        layerNum := 1;
        theLayer := FLayer;
        layerName := GetLName(theLayer);
        IF layerName = '0' THEN
            layerName := '000';
        theScale := GetLScale(theLayer);
        theType := GetObjectVariableInt(theLayer,154);
        layerDescrip := 'zz';
        IF theType = 2 THEN
            layerDescrip := GetObjectVariableString(theLayer,159);
        IF (layerDescrip = '') THEN
            layerDescrip := 'zz';
        GetDrawingSizeRectN(theLayer, x1, y1, x2, y2);
    
        LayerArray[layerNum] := layerName;
        LyrDescrArray[layerNum] := layerDescrip;
        ScaleArray[layerNum] := theScale;
        LTypeArray[layerNum] := theType;
        LDrawSize[layerNum].x1 := x1;
        LDrawSize[layerNum].y1 := y1;
        LDrawSize[layerNum].x2 := x2;
        LDrawSize[layerNum].y2 := y2;
        
        theLayer := NextLayer(theLayer);
        WHILE theLayer <> NIL DO
        BEGIN
            layerNum := layerNum + 1;
            
            layerName := GetLName(theLayer);
            IF ValidNumStr(layerName,lyrNum) THEN
                layerName := CONCAT('zz',layerName);
            theScale := GetLScale(theLayer);
            theType := GetObjectVariableInt(theLayer,154);
            {layerDescrip := GetObjectVariableSTRING(theLayer,159);}
            IF theType = 2 THEN
                layerDescrip := GetObjectVariableString(theLayer,159);
            IF (layerDescrip = '') THEN
                layerDescrip := ' ';
            GetDrawingSizeRectN(theLayer, x1, y1, x2, y2);
            
            LayerArray[layerNum] := layerName;
            LyrDescrArray[layerNum] := layerDescrip;
            ScaleArray[layerNum] := theScale;
            LTypeArray[layerNum] := theType;
            LDrawSize[layerNum].x1 := x1;
            LDrawSize[layerNum].y1 := y1;
            LDrawSize[layerNum].x2 := x2;
            LDrawSize[layerNum].y2 := y2;
            
            theLayer := NextLayer(theLayer);
        END; {WHILE theLayer <> NIL}
    END; {PROCEDURE CollectLayerInfo}
    
{==============================================================}

 

BEGIN
            CurrFileName := GetFName;
            CurrFileName := CONCAT(CurrFileName,' ','Layer List');
    
            CollectLayerInfo;
    
            PutFile('Name and Save the Layer List File',CurrFileName,FileName);
            IF NOT DidCancel THEN
                BEGIN
                    WriteLn(LayerNum);
                    FOR Index := 1 TO LayerNum DO
                        BEGIN
                            WriteLn(LayerArray[Index]);
                            WriteLn(LyrDescrArray[Index]);
                            WriteLn(ScaleArray[Index]);
                            WriteLn(LTypeArray[Index]);
                            WriteLn(LDrawSize[layerNum].x1);
                            WriteLn(LDrawSize[layerNum].y1);
                            WriteLn(LDrawSize[layerNum].x2);
                            WriteLn(LDrawSize[layerNum].y2);
                        END; {FOR Index := 1 TO LayerNum}
                    CLOSE(FileName);
                END; {IF NOT DidCancel}
            AlrtDialog('Done Writing Layer List');
END;
RUN(WriteLayerStructure);
 

Share this post


Link to post

Dunno Sam. Maybe is it working of the active layer and not the layer you specify. Try making each layer active before getting the layer into. If you do this, then you only need to use GetDrawingSizeRect() which returns info from the active layer.

Share this post


Link to post

I thought I sent a note late last night.  I found the problem; I was using the wrong index in LDrawSize[ ]  variable.  Never code after dinner, if wine is served.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

  • 7150 Riverwood Drive
  • Columbia, Maryland 21046, USA
  • Contact Us | 410.290.5114

 

  • © 2018 Vectorworks, Inc. All rights reserved.
  • Vectorworks, Inc. is part of the Nemetschek Group.
  • ×