图纸空间视口是使用该方法创建的。AddPViewport 该方法需要一个中心点以及新视口的宽度和高度。在创建视口之前,请使用该属性将图纸空间设置为当前空间(通常通过将 TILEMODE 设置为 0 来完成)。AddPViewportActiveSpace 创建对象后,可以设置视图本身的属性,例如查看方向(属性)、透视视图的镜头长度(属性)和网格显示(属性)。您还可以控制视口本身的属性,例如图层 ( 属性)、线型 ( 属性) 和线型缩放 ( 属性)。PViewportDirectionLensLengthGridOnLayerLinetypeLinetypeScale 创建并启用浮动视口本示例将 AutoCAD 切换到图纸空间,创建浮动视口,设置视图并启用视口。 Sub Ch9_SwitchToPaperSpace() ' Set the active space to paper space ThisDrawing.ActiveSpace = acPaperSpace ' Create the paperspace viewport Dim newVport As AcadPViewport Dim center(0 To 2) As Double center(0) = 3.25 center(1) = 3 center(2) = 0 Set newVport = ThisDrawing.PaperSpace. _ AddPViewport(center, 6, 5) ' Change the view direction for the viewport Dim viewDir(0 To 2) As Double viewDir(0) = 1 viewDir(1) = 1 viewDir(2) = 1 newVport.Direction = viewDir ' Enable the viewport newVport.Display True ' Switch to model space ThisDrawing.MSpace = True ' Set newVport current ' (not always necessary but a good idea) ThisDrawing.ActivePViewport = newVport ' Zoom Extents in model space ZoomExtents ' Turn model space editing off ThisDrawing.MSpace = False ' ZoomExtents in paperspace ZoomExtents End Sub 上述代码中的步骤顺序很重要。通常,必须按照在AutoCAD命令行中完成的顺序执行操作。唯一意外的操作涉及定义视图和启用视口。 注意:若要设置或修改视图的各个方面(视图方向、镜头长度等),必须将对象的方法设置为关闭 (FALSE),并且在设置视口电流之前,必须将该方法设置为打开 (TRUE)。ViewportDisplayDisplay
创建四个浮动视口此示例以“创建和启用浮动视口”中的示例为例,通过创建四个浮动视口并将每个视口的视图分别设置为顶部、前视图、右侧视图和等距视图来继续执行此示例。每个视图都缩放到图纸空间比例的一半。为了确保在这些视口中可以看到一些东西,您可能希望在尝试此示例之前创建一个 3D 实体球体。 Sub Ch9_FourPViewports() Dim topVport, frontVport As AcadPViewport Dim rightVport, isoVport As AcadPViewport Dim pt(0 To 2) As Double Dim viewDir(0 To 2) As Double ThisDrawing.ActiveSpace = acPaperSpace ThisDrawing.MSpace = True ' Take the existing PViewport and make it the topVport pt(0) = 2.5: pt(1) = 5.5: pt(2) = 0 Set topVport = ThisDrawing.ActivePViewport 'No need to set Direction for top view topVport.center = pt topVport.width = 2.5 topVport.height = 2.5 topVport.Display True ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = topVport ZoomExtents ZoomScaled 0.5, acZoomScaledRelativePSpace 'Create and setup frontVport pt(0) = 2.5: pt(1) = 2.5: pt(2) = 0 Set frontVport = ThisDrawing.PaperSpace. _ AddPViewport(pt, 2.5, 2.5) viewDir(0) = 0: viewDir(1) = 1: viewDir(2) = 0 frontVport.direction = viewDir frontVport.Display acOn ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = frontVport ZoomExtents ZoomScaled 0.5, acZoomScaledRelativePSpace 'Create and setup rightVport pt(0) = 5.5: pt(1) = 5.5: pt(2) = 0 Set rightVport = ThisDrawing.PaperSpace. _ AddPViewport(pt, 2.5, 2.5) viewDir(0) = 1: viewDir(1) = 0: viewDir(2) = 0 rightVport.direction = viewDir rightVport.Display acOn ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = rightVport ZoomExtents ZoomScaled 0.5, acZoomScaledRelativePSpace 'Create and set up isoVport pt(0) = 5.5: pt(1) = 2.5: pt(2) = 0 Set isoVport = ThisDrawing.PaperSpace. _ AddPViewport(pt, 2.5, 2.5) viewDir(0) = 1: viewDir(1) = 1: viewDir(2) = 1 isoVport.direction = viewDir isoVport.Display acOn ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = isoVport ZoomExtents ZoomScaled 0.5, acZoomScaledRelativePSpace 'Finish: Perform a regen in all viewports ThisDrawing.Regen True End Sub 相关概念父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:39
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.