CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

浮动视区 (.NET)

2023-1-1 09:38| 发布者: admin| 查看: 408| 评论: 0|来自: AutoCAD

不能从图纸空间编辑模型。要访问视口对象中的模型,请使用编辑器对象的 andmember 方法从图纸空间切换到模型空间。因此,您可以在保持整体布局可见的同时使用模型。在视口对象中,编辑和视图更改功能几乎与对象相同。SwitchToModelSpaceSwitchToPaperSpaceViewportTableRecord

但是,您可以更好地控制各个视图。例如,您可以在某些视口中冻结或解冻图层,而不会影响其他视口。您可以打开或关闭视口中几何图形的显示。您还可以在视口之间对齐视图,并相对于整体布局缩放视图。

下图显示了如何在图纸空间中显示模型的不同视图。每个图纸空间图像表示具有不同视图的视口对象。在一个视图中,尺寸图层被冻结。请注意,在图纸空间中绘制的标题栏、边框和注释不会显示在“模型空间”视图中。此外,包含视口边框的图层已被冻结。

在视口对象中工作时,可以位于模型空间或图纸空间中。您可以通过检查 TILEMODE 和 CVPORT 系统变量的当前值来确定您是否在模型空间中工作。下表根据 TILEMODE 和 CVPORT 的当前值细分了您正在使用的空间和布局。为 0,CVPORT 是 2 以外的值,则您正在图纸空间中工作,如果 TILEMODE 为 0,CVPORT 为 2,则您在模型空间中工作。如果 TILEMODE 为 1,则表示您正在“模型”布局的“模型”空间中工作。

当前空间

平铺模式

CVPORT

地位

0

不等于 2

“模型”以外的布局处于活动状态,并且您正在“图纸”空间中工作。

0

2

“模型”以外的布局处于活动状态,并且您正在浮动视口中工作。

1

任何值

模型布局处于活动状态。

注意:在布局上切换到“打开模型空间”之前,应将布局上至少一个 Viewport 对象的属性设置为 。OnTRUE

在图纸空间中时,AutoCAD 会在图形区域的左下角显示图纸空间用户坐标系 (UCS) 图标。十字准线表示可以编辑图纸空间布局区域(而不是视口中的视图)。

在模型和图纸空间之间切换

此示例演示如何在模型和图纸空间之间切换。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
 
<CommandMethod("ToggleSpace")> _
Public Sub ToggleSpace()
  '' Get the current document
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
 
  '' Get the current values of CVPORT and TILEMODE
  Dim nCvports As Integer = Application.GetSystemVariable("CVPORT")
  Dim nTilemode As Integer = Application.GetSystemVariable("TILEMODE")
 
  '' Check to see if the Model layout is active, TILEMODE is 1 when
  '' the Model layout is active
  If nTilemode = 0 Then
      '' Check to see if Model space is active in a viewport,
      '' CVPORT is 2 if Model space is active 
      If nCvports = 2 Then
          acDoc.Editor.SwitchToPaperSpace()
      Else
          acDoc.Editor.SwitchToModelSpace()
      End If
  Else
      '' Switch to the previous Paper space layout
      Application.SetSystemVariable("TILEMODE", 0)
  End If
End Sub

C#

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
 
[CommandMethod("ToggleSpace")]
public static void ToggleSpace()
{
  // Get the current document
  Document acDoc = Application.DocumentManager.MdiActiveDocument;
 
  // Get the current values of CVPORT and TILEMODE
  object oCvports = Application.GetSystemVariable("CVPORT");
  object oTilemode = Application.GetSystemVariable("TILEMODE");
 
  // Check to see if the Model layout is active, TILEMODE is 1 when
  // the Model layout is active
  if (System.Convert.ToInt16(oTilemode) == 0)
  {
      // Check to see if Model space is active in a viewport,
      // CVPORT is 2 if Model space is active 
      if (System.Convert.ToInt16(oCvports) == 2)
      {
          acDoc.Editor.SwitchToPaperSpace();
      }
      else
      {
          acDoc.Editor.SwitchToModelSpace();
      }
  }
  else
  {
      // Switch to the previous Paper space layout
      Application.SetSystemVariable("TILEMODE", 0);
  }
}

VBA/ActiveX 代码参考

Public Sub ToggleSpace()
    ' Check to see if the Model layout is active
    If ThisDrawing.ActiveLayout.Name <> "Model" Then
        ' Check to see if Model space is active
        If ThisDrawing.MSpace = True Then
            ThisDrawing.MSpace = False
        Else
            ThisDrawing.MSpace = True
        End If
    Else
        ' Switch to the previous Paper space layout
        ThisDrawing.ActiveSpace = acPaperSpace
    End If
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-18 05:07

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部