Sam Jones Posted July 3, 2018 Share Posted July 3, 2018 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. Quote Link to comment
Pat Stanford Posted July 3, 2018 Share Posted July 3, 2018 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. Quote Link to comment
Julian Carr Posted July 3, 2018 Share Posted July 3, 2018 You can use GetDrawingSizeRect() to establish the current page size, and SetDrawingRect() to set a new page size. Quote Link to comment
Sam Jones Posted July 3, 2018 Author Share Posted July 3, 2018 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? Quote Link to comment
Sam Jones Posted July 4, 2018 Author Share Posted July 4, 2018 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 Quote Link to comment
Julian Carr Posted July 4, 2018 Share Posted July 4, 2018 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. Quote Link to comment
Sam Jones Posted July 4, 2018 Author Share Posted July 4, 2018 ScaleFactor ??? Needed for ??? Quote Link to comment
Sam Jones Posted July 4, 2018 Author Share Posted July 4, 2018 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? Quote Link to comment
Julian Carr Posted July 4, 2018 Share Posted July 4, 2018 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. Quote Link to comment
Sam Jones Posted July 4, 2018 Author Share Posted July 4, 2018 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); Quote Link to comment
Julian Carr Posted July 4, 2018 Share Posted July 4, 2018 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. Quote Link to comment
Sam Jones Posted July 4, 2018 Author Share Posted July 4, 2018 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. Quote Link to comment
Recommended Posts
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.