延伸和修剪对象
 
 

You can change the angle of arcs and you can change the length of lines, open polylines, elliptical arcs, and open splines. The results are similar to both extending and trimming objects.

用户可以更改圆弧的角度,也可以改变直线、开放多段线、椭圆弧和开放样条曲线的长度。结果类似于延伸和修剪对象。

You can extend or trim an object by editing its properties. For example, to lengthen a line, simply change the coordinates of the StartPoint or EndPoint properties. To change the angle of an arc, change the StartAngle or EndAngle property of the arc. Once you have altered an object's property or properties, you might need to regenerate the display to see the changes in the drawing window.

用户可以通过编辑对象的特性来延伸或修剪对象。例如,若要拉长直线,只需修改 StartPoint 或 EndPoint 属性的坐标即可。要改变圆弧的角度,请更改圆弧的 StartAngle 或 EndAngle 属性。改变对象的一个和多个特性后,就必须重生成以查看图形窗口中的变化。

For more information about extending and trimming objects, see “Resize or Reshape Objects” in the AutoCAD User's Guide.

更多关于延伸和修剪对象的详细信息,请参见《AutoCAD 用户手册》中的“调整对象的大小和形状”。

延长直线

This example creates a line and then changes the endpoint of that line, resulting in a longer line.

本例创建一条直线,然后修改其端点拉长该直线。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("ExtendObject")> _
Public Sub ExtendObject()
  '' 获得当前文档和数据库   Get the current document and database
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  Dim acCurDb As Database = acDoc.Database
 
  ''启动一个事务   Start a transaction
  Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
 
      '' 以只读方式打开块表   Open the Block table for read
      Dim acBlkTbl As BlockTable
      acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _
                                   OpenMode.ForRead)
 
      '' 以写方式打开模型空间块表记录   Open the Block table record Model space for write
      Dim acBlkTblRec As BlockTableRecord
      acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                      OpenMode.ForWrite)
 
      '' 创建一条起点为(4,4,0)终点为(7,7,0)的直线   Create a line that starts at (4,4,0) and ends at (7,7,0)
      Dim acLine As Line = New Line(New Point3d(4, 4, 0), _
                                    New Point3d(7, 7, 0))
 
      acLine.SetDatabaseDefaults()
 
      '' 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(acLine)
      acTrans.AddNewlyCreatedDBObject(acLine, True)
 
      '' 更新显示并显示一个消息框   Update the display and diaplay a message box
      acDoc.Editor.Regen()
      Application.ShowAlertDialog("Before extend")
 
      ''将直线的长度增加到原来的双倍长   Double the length of the line
      acLine.EndPoint = acLine.EndPoint + acLine.Delta
 
      '' 保存新对象到数据库中   Save the new object to the database
      acTrans.Commit()
  End Using
End Sub

C#

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
 
[CommandMethod("ExtendObject")]
public static void ExtendObject()
{
  // 获得当前文档和数据库   Get the current document and database
  Document acDoc = Application.DocumentManager.MdiActiveDocument;
  Database acCurDb = acDoc.Database;
 
  // 启动一个事务  Start a transaction
  using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
  {
      // 以只读方式打开块表   Open the Block table for read
      BlockTable acBlkTbl;
      acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                   OpenMode.ForRead) as BlockTable;
 
      // 以写方式打开模型空间块表记录   Open the Block table record Model space for write
      BlockTableRecord acBlkTblRec;
      acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                      OpenMode.ForWrite) as BlockTableRecord;
 
      // Create a line that starts at (4,4,0) and ends at (7,7,0)
      Line acLine = new Line(new Point3d(4, 4, 0),
                             new Point3d(7, 7, 0));
 
      acLine.SetDatabaseDefaults();
 
      // 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(acLine);
      acTrans.AddNewlyCreatedDBObject(acLine, true);
 
      // Update the display and diaplay a message box
      acDoc.Editor.Regen();
      Application.ShowAlertDialog("Before extend");
 
      // Double the length of the line
      acLine.EndPoint = acLine.EndPoint + acLine.Delta;
 
      // 保存新对象到数据库中   Save the new object to the database
      acTrans.Commit();
  }
}
VBA/ActiveX 代码参考