Jump to content

Change Sheet layer size based on viewport size


Recommended Posts

@Jayme McColgan I think this should be totally possible.  What you are looking for is SetDrawingRect.  You could theoretically pull the bounding box size of the Viewport with GetBBox and use that to set the side of the page.  The current page origin is stored as an application preference, so you'll want to get/set it using GetPrefReal(80) for the X value and GetPrefReal(81) for the y value.  Also keep in mind that you may have to compensate for the user origin (all of the above commands will pull relative to the internal origin, which I have found many draftspeople do not properly respect).  The user origin can be found with GetPrefReal(6702) for X and GetPrefReal(6703) for Y.

 

This is the code that I had some success with (keeping in mind that this is Vectorscript instead of Python, but it's simple enough to translate):

PROCEDURE SetPageToViewport;
	
VAR

	viewHd:HANDLE;
	A,B:POINT;
	width,height:REAL;
	
PROCEDURE GetSelectedVP(h:HANDLE);

	BEGIN
		viewHd:=h;
	END;
	
BEGIN
	ForEachObject(GetSelectedVP,((SEL=TRUE) & (T=VIEWPORT)));
	
	GetBBox(viewHd,A.x,A.y,B.x,B.y);
	
	width:=B.x-A.x;
	height:=A.y-B.y;
	
	SetPrefReal(80,A.x+(width*0.5));
	SetPrefReal(81,0-(A.y-(height*0.5)));
	
	SetDrawingRect(width,height);
END;

Run(SetPageToViewport);

 

Edited by Jesse Cogswell
  • Like 2
Link to comment

thanks @Jesse Cogswell heres the python version for anyone looking in the future.

 

import vs

width = 2
height = 3.4
sheet_num = "BM-1"
name = "Test Sheet Layer"

def make_custom_sheet_layer():
    curlayer = vs.CreateLayer(sheet_num, 2) ### Create Sheet Layer
    vs.SetObjectVariableString(curlayer, 159, name) ### Set Sheet Layer Name
    vs.SetDrawingRect(width*12, height) ### Set Sheet Layer Size
    return None

 

  • Like 1
Link to comment
13 hours ago, Jesse Cogswell said:

@Jayme McColgan I think this should be totally possible.  What you are looking for is SetDrawingRect.  You could theoretically pull the bounding box size of the Viewport with GetBBox and use that to set the side of the page.  The current page origin is stored as an application preference, so you'll want to get/set it using GetPrefReal(80) for the X value and GetPrefReal(81) for the y value.  Also keep in mind that you may have to compensate for the user origin (all of the above commands will pull relative to the internal origin, which I have found many draftspeople do not properly respect).  The user origin can be found with GetPrefReal(6702) for X and GetPrefReal(6703) for Y.

 

This is the code that I had some success with (keeping in mind that this is Vectorscript instead of Python, but it's simple enough to translate):

PROCEDURE SetPageToViewport;
	
VAR

	viewHd:HANDLE;
	A,B:POINT;
	width,height:REAL;
	
PROCEDURE GetSelectedVP(h:HANDLE);

	BEGIN
		viewHd:=h;
	END;
	
BEGIN
	ForEachObject(GetSelectedVP,((SEL=TRUE) & (T=VIEWPORT)));
	
	GetBBox(viewHd,A.x,A.y,B.x,B.y);
	
	width:=B.x-A.x;
	height:=A.y-B.y;
	
	SetPrefReal(80,A.x+(width*0.5));
	SetPrefReal(81,0-(A.y-(height*0.5)));
	
	SetDrawingRect(width,height);
END;

Run(SetPageToViewport);

 

 

so whats else can i change in the "Edit Sheet Layer" Dialog box? can i go as deep as getting into the printer setup and creating custom page sizes? or changing the horizontal and vertical page amount? 

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