03-04 创建和编辑AutoCAD实体(四) 编辑二维命名对象 (5)

本文介绍如何使用AutoCAD通过编辑对象属性来实现对象的延伸和修剪,包括改变直线长度和圆弧角度的方法,并提供了详细的编程示例。
 

7、Extend and Trim Objects延伸和修剪对象

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 theAutoCAD User's Guide.

更多关于延伸和修剪对象的内容,见AutoCAD用户指南中的“修改对象的大小和形状”内容。

Lengthen a line延长一条直线

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

本例创建一条直线,然后修改其EndPoint属性来使直线变长。

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)

 

      '' 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))

 

      '' 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));

 

      // 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 Code Reference

Sub ExtendObject()

    ' Define and create the line

    Dim lineObj As AcadLine

    Dim startPoint(0 To 2) As Double

    Dim endPoint(0 To 2)  As Double

    startPoint(0) = 4

    startPoint(1) = 4

    startPoint(2) = 0

    endPoint(0) = 7

    endPoint(1) = 7

    endPoint(2) = 0

    Set lineObj = ThisDrawing.ModelSpace. _

                                AddLine(startPoint, endPoint)

    lineObj.Update

 

    ' Double the length of the line

    endPoint(0) = lineObj.endPoint(0) + lineObj.Delta(0)

    endPoint(1) = lineObj.endPoint(1) + lineObj.Delta(1)

    endPoint(2) = lineObj.endPoint(2) + lineObj.Delta(2)

    lineObj.endPoint = endPoint

    lineObj.Update

End Sub

 

基于可靠性评估序贯蒙特卡洛模拟法的配电网可靠性评估研究(Matlab代码实现)内容概要:本文围绕“基于可靠性评估序贯蒙特卡洛模拟法的配电网可靠性评估研究”,介绍了利用Matlab代码实现配电网可靠性的仿真分析方法。重点采用序贯蒙特卡洛模拟法对配电网进行长时间段的状态抽样与统计,通过模拟系统元件的故障与修复过程,评估配电网的关键可靠性指标,如系统停电频率、停电持续时间、负荷点可靠性等。该方法能够有效处理复杂网络结构与设备时序特性,提升评估精度,适用于含分布式电源、电动汽车等新型负荷接入的现代配电网。文中提供了完整的Matlab实现代码与案例分析,便于复现扩展应用。; 适合人群:具备电力系统基础知识Matlab编程能力的高校研究生、科研人员及电力行业技术人员,尤其适合从事配电网规划、运行与可靠性分析相关工作的人员; 使用场景及目标:①掌握序贯蒙特卡洛模拟法在电力系统可靠性评估中的基本原理与实现流程;②学习如何通过Matlab构建配电网仿真模型并进行状态转移模拟;③应用于含新能源接入的复杂配电网可靠性定量评估与优化设计; 阅读建议:建议结合文中提供的Matlab代码逐段调试运行,理解状态抽样、故障判断、修复逻辑及指标统计的具体实现方式,同时可扩展至不同网络结构或加入更多不确定性因素进行深化研究。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值