Jump to content
Sam Jones

Page Size

Recommended Posts

You can use object variables:

ovLayerSheetPaperWidth		= 167;		//	double_gs - in inches; layer page/paper width
ovLayerSheetPaperHeight		= 168;		//	double_gs - in inches; layer page/paper height

Those would be the constants to pass to GetObjectVariableReal

Share this post


Link to post

Thank you !   Works great.   Now for ...drum roll...  Can you set a design layer's page size?

 

Using "SetObjectVariableReal(TheLayer, ovLayerSheetPaperHeight, LayerHt);"  Does not seem to work.  Also, setting the page height via the OS seems to set the page for all the design layers.   

Share this post


Link to post

I believe set should work, and if not, it's a bug. You may need to reset the layer. Also try get after set to see if the values are sticking.

I'm also guessing the values are in mm.

Share this post


Link to post

I'll do some more testing.  The "Get" returns values in inches, so it seems strange that the "Set" would use mm, but Ill check.  Thanks again.

 

Share this post


Link to post

This is what I use to get the page dimensions. Note it works on the active layer so you have to store the active layer name, switch to the layer you are querying, then back again on completion. Also note it is returning mm:

 

Procedure GetDrawingSizeRect2(VAR dx1, dy1, dx2, dy2 : REAL; VAR PageWdth, PageHght : INTEGER);
VAR
    s1, s2 : STRING;
    r1 : REAL;
BEGIN
    IF NOT IsNewCustomObject(gPIOName) THEN BEGIN
        s2 := GetLName(ActLayer);
        s1 := GetLName(GetLayer(ghParm));
        IF (s1 <> '') & (GetType(GetObject(s1)) = 31) THEN Layer(s1) { switch layers so that GDSR() measures active layer (for use with RIP command }
        ELSE s1 := '';
    END;
    GetDrawingSizeRect(dx1, dy1, dx2, dy2);
    r1 := GetLScale(ActLayer); { use this here instead of gLScale because GetDrawingSizeRect() is using the active layer, not the PIO layer }
    IF s2 <> '' THEN Layer(s2);
    PageWdth := Abs(dx2 - dx1) / r1 * 25.4 / gUPI; { page width in mm } { use gLScale here so that comparisons are in real world sizes, not scaled }
    PageHght := Abs(dy2 - dy1) / r1 * 25.4 / gUPI; { page height in mm }
END;

 

You can use SetDrawingRect() to set the page size, though you need to consider that the drawing size rectangle represents the printable area for the currently selected printer, not the actual page size. I have a routine that tries to match the drawing size rectangle to the metric or imperial page size. Here's part of it:

 

CONST

    kPS1m = 148; { ISO Sizes including Super A3 }
    kPS2m = 210;
    kPS3m = 297;
    kPS4m = 420;
    kPS5m = 594;
    kPS6m = 841;
    kPS7m = 1189;
    kPS8m = 707;
    kPS9m = 1000;
    kPS10m = 1414;
    kPS11m = 330; { 13" Super A3 }
    kPS12m = 483; { 19" Super A3 }

 

    kPS11i = 229; { 9" } { US Arch Sizes }
    kPS12i = 305; { 12" }
    kPS13i = 457; { 18" }
    kPS14i = 610; { 24" }
    kPS15i = 914; { 36" }
    kPS16i = 1219; { 48" }

 

    kPS17i = 216; { 8.5" } { ASME Sizes }
    kPS18i = 279; { 11" }
    kPS19i = 432; { 17" }
    kPS20i = 559; { 22" }
    kPS21i = 864; { 34" }
    kPS22i = 1118; { 44" }
 

    CASE gPageFormat OF { if possible, set page size string from found page dimensions }
        1: BEGIN { ISO }
            IF ((PageWdth = kPS2m) & (PageHght = kPS1m)) | ((PageWdth = kPS1m) & (PageHght = kPS2m)) THEN PageSize := 'A5'
            ELSE IF ((PageWdth = kPS3m) & (PageHght = kPS2m)) | ((PageWdth = kPS2m) & (PageHght = kPS3m)) THEN PageSize := 'A4'
            ELSE IF ((PageWdth = kPS4m) & (PageHght = kPS3m)) | ((PageWdth = kPS3m) & (PageHght = kPS4m)) THEN PageSize := 'A3'
            ELSE IF ((PageWdth = kPS5m) & (PageHght = kPS4m)) | ((PageWdth = kPS4m) & (PageHght = kPS5m)) THEN PageSize := 'A2'
            ELSE IF ((PageWdth = kPS6m) & (PageHght = kPS5m)) | ((PageWdth = kPS5m) & (PageHght = kPS6m)) THEN PageSize := 'A1'
            ELSE IF ((PageWdth = kPS7m) & (PageHght = kPS6m)) | ((PageWdth = kPS6m) & (PageHght = kPS7m)) THEN PageSize := 'A0'
            ELSE IF ((PageWdth = kPS9m) & (PageHght = kPS8m)) | ((PageWdth = kPS8m) & (PageHght = kPS9m)) THEN PageSize := 'B1'
            ELSE IF ((PageWdth = kPS10m) & (PageHght = kPS9m)) | ((PageWdth = kPS9m) & (PageHght = kPS10m)) THEN PageSize := 'B0'
            ELSE IF ((PageWdth = kPS12m) & (PageHght = kPS11m)) | ((PageWdth = kPS11m) & (PageHght = kPS12m)) THEN PageSize := 'Super A3'
            ELSE FlagCustom := True;
        END;
        2: BEGIN { US Arch }
            IF ((PageWdth = kPS12i) & (PageHght = kPS11i)) | ((PageWdth = kPS11i) & (PageHght = kPS12i)) THEN PageSize := 'US Arch A'
            ELSE IF ((PageWdth = kPS13i) & (PageHght = kPS12i)) | ((PageWdth = kPS12i) & (PageHght = kPS13i)) THEN PageSize := 'US Arch B'
            ELSE IF ((PageWdth = kPS14i) & (PageHght = kPS13i)) | ((PageWdth = kPS13i) & (PageHght = kPS14i)) THEN PageSize := 'US Arch C'
            ELSE IF ((PageWdth = kPS15i) & (PageHght = kPS14i)) | ((PageWdth = kPS14i) & (PageHght = kPS15i)) THEN PageSize := 'US Arch D'
            ELSE IF ((PageWdth = kPS16i) & (PageHght = kPS15i)) | ((PageWdth = kPS15i) & (PageHght = kPS16i)) THEN PageSize := 'US Arch E'
            ELSE FlagCustom := True;
        END;
        3: BEGIN { ASME }
            IF ((PageWdth = kPS18i) & (PageHght = kPS17i)) | ((PageWdth = kPS17i) & (PageHght = kPS19i)) THEN PageSize := 'ASME A'
            ELSE IF ((PageWdth = kPS19i) & (PageHght = kPS18i)) | ((PageWdth = kPS18i) & (PageHght = kPS19i)) THEN PageSize := 'ASME B'
            ELSE IF ((PageWdth = kPS20i) & (PageHght = kPS19i)) | ((PageWdth = kPS19i) & (PageHght = kPS20i)) THEN PageSize := 'ASME C'
            ELSE IF ((PageWdth = kPS21i) & (PageHght = kPS20i)) | ((PageWdth = kPS20i) & (PageHght = kPS21i)) THEN PageSize := 'ASME D'
            ELSE IF ((PageWdth = kPS22i) & (PageHght = kPS21i)) | ((PageWdth = kPS21i) & (PageHght = kPS22i)) THEN PageSize := 'ASME E'
            ELSE FlagCustom := True;
        END;
    END;
 

 

Share this post


Link to post

Once you set the variable "PageSize" to appropriate string, are you able to set the page size of the active layer (or any layer for that matter)?  I'm under the impression that setting the page size for the drawing is a call to the OS that is not available to VS.  Would love to be wrong.  I would like to set the page size to be 53mm wide by 18,288mm long using vectorscript.  Possible?

Share this post


Link to post

You cannot access the printer settings in Vectorscript. There may also be a physical limit on the page dimensions in the OS. At least that used to be the case.

Share this post


Link to post

It depends on how much you need this functionality Sam.  ;-)

 

This python library looks like it MIGHT do what you need.

 

https://wxpython.org/Phoenix/docs/html/printing_framework_overview.html

 

You can run Python inside a VS by using the following VS functions.

 

PythonBeginContext
PythonEndContext
PythonExecute

 

I have not used any of this, so I may be spitting into the wind.

 

It depends on how much you need this functionality Sam.

Share this post


Link to post

@Sam Jones I assume that you want to set the page area in the drawing — the equivalent of going to File>Page Setup and setting the printable area. This should NOT be a function of the OS print system, as the printer does not necessarily need to match the print area (VW will tile or crop as needed).

 

If you want to actually set a custom page size, the equivalent of pressing Printer Setup… in the Page Setup dialog, then you would need to work with OS settings. 

 

Untested, but there is access to set the print area to a single page:

const short ovLayerRepaginate			= 156;		// Public for VS
// ovLayerRepaginate (Boolean)
// Set() causes the pagination to be recalculated for the given Sheet Layer or Design Layer (useful after manipulating the PrintInfo).
// true = set drawing size to one page, false = divide drawing size into multiple pages;
// Get() determines how the drawing is currently paginated
// true = one page, false = multiple pages

 

Share this post


Link to post

Everything is going well.  I can't set the printer page size, but I can deal with that limitation.  Is it possible for VS to get the delta Y of a viewport.  It's in the OIP, but I'm not finding a hook.

 

Ever so grateful.

Share this post


Link to post

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.


 

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.

×
×
  • Create New...