代码改变世界

随笔档案-2011年3月18日

AutoCAD VBA计算多段线的长度

2011-03-18 18:13 by 精诚所至 金石为开, 2393 阅读, 收藏,
摘要: 计算多段线的长度,代码如下。 Sub PolyLineLength() Dim Pnt As Variant Dim Ent As AcadEntity On Error Resume Next Do ThisDrawing.Utility.GetEntity Ent, Pnt, "选择多段线:" If Err Then... 阅读全文

AutoCAD VBA天圆地方的放样展开图

2011-03-18 18:13 by 精诚所至 金石为开, 953 阅读, 收藏,
摘要: 天圆地方展开图,代码如下。 Public Sub Main() Const PI As Double = 3.1415926 On Error Resume Next Dim pt0 As Variant, ptBase(2) As Double pt0 = ThisDrawing.Utility.GetPoint(, vbCrLf & "请输... 阅读全文

AutoCAD VBA 直线、圆、圆弧转化为多段线

2011-03-18 18:12 by 精诚所至 金石为开, 3403 阅读, 收藏,
摘要: 转化多段线,代码如下。 Private Function AddLWPlineSeg(ByVal ptSt As Variant, ByVal ptEn As Variant, ByVal width As Double) As AcadLWPolyline Dim objPline As AcadLWPolyline Dim ptArr(0 To 3) As Dou... 阅读全文

AutoCAD VAB使用SendCommand命令

2011-03-18 18:12 by 精诚所至 金石为开, 5943 阅读, 收藏,
摘要: 关于SendCommand命令的用法,代码如下。 Public Function axPoint2lspPoint(ByVal Pnt As Variant) As String axPoint2lspPoint = Pnt(0) & "," & Pnt(1) & "," & Pnt(2) End Function Public Function axEn... 阅读全文

AutoCAD VBA多段线操作

2011-03-18 18:11 by 精诚所至 金石为开, 3363 阅读, 收藏,
摘要: 多段线操作,代码如下。 Private Function GetVertexCount(ByVal objPline As AcadEntity) As Long If TypeOf objPline Is AcadLWPolyline Then GetVertexCount = (UBound(objPline.Coordinates) + 1) / 2 ... 阅读全文