Jump to content
Developer Wiki and Function Reference Links ×

Page Setup (Size) for Sheet Layers


Recommended Posts

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?
 

Link to comment

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

 

Link to comment

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.

Link to comment

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.

Link to comment

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);
 

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