I have created a script that will draw plan and profile viewports on new layouts. The main issue that I am running into is that I can’t move the viewport in paper space without moving the view in model space. If I create a viewport manually and use the move command, the paper space view will move and the view of model space will stay the same within that viewport. Is there a way to make it so my viewports will do this? The viewports are being defined by a polyline (NonRectClipEntityId). This seems to be a part of the issue, but I need to do this to accurately define my viewport to match a key plan. Any help is appreciated.
Draw Plan and Profile Viewports and Matchlines.dyn (152.1 KB)
This is the specific part of the code that defines the viewport I am having issues with.
plan_viewport = Viewport()
plan_viewport.Height = plan_height * 1000 # Set large to include adequate background
plan_viewport.Width = plan_width * 1000 # Set viewport width
plan_viewport.TwistAngle = angle
plan_viewport.NonRectClipEntityId = polyline.ObjectId
plan_viewport.NonRectClipOn = True
plan_viewport.CenterPoint = plan_ps_center # Set viewport position
plan_viewport.ViewHeight = plan_height * drawing_scale * 1000 # The height of the view in model space
# Add the viewport to the paper space layout
paper_space.AppendEntity(plan_viewport)
t.AddNewlyCreatedDBObject(plan_viewport, True)
#plan_viewport.Height = plan_ps_height # Set viewport height
plan_viewport.ViewDirection = Vector3d.ZAxis # Set the view direction to look from the top
# Now set the model space view to match key plan
plan_viewport.ViewTarget = plan_ms_center
# Allow the viewport to be interactive and "clicked into"
plan_viewport.On = True # Ensure the viewport is enabled
plan_viewport.Locked = True
world_ucs = Matrix3d.Identity.CoordinateSystem3d
plan_viewport.Ucs = world_ucs
plan_viewport.UcsFollowModeOn = False