您的位置:网站首页 > CAD新闻

VB编程编辑AutoCAD轻量多义线

时间:2012-01-18 10:37:43 来源:未知

创建一条轻量多义线并将第二段修改为圆弧。

Private Sub Command1_Click()
    Dim plineobj As AcadLWPolyline
    Dim points(0 To 9) As Double
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
    Set plineobj = acadapp.ActiveDocument.ModelSpace.AddLightWeightPolyline(points)
    plineobj.SetBulge 2, 1
    plineobj.Update
    ZoomExtents
End Sub

给轻量多义线添加新定点,设置线宽,封闭多义线,计算多义线围成的面积。

Private Sub Command1_Click()
    Dim plineobj As AcadLWPolyline
    Dim points(0 To 9) As Double
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
    Set plineobj = acadapp.ActiveDocument.ModelSpace.AddLightWeightPolyline(points)
    plineobj.SetBulge 2, 1
    plineobj.Update
    ZoomExtents
    Dim newvertex(0 To 1) As Double
    newvertex(0) = 4: newvertex(1) = 1
    plineobj.AddVertex 5, newvertex
    plineobj.SetWidth 4, 0.1, 0.5
    plineobj.Closed = True
    MsgBox "多义线围成的面积=" & plineobj.Area
    plineobj.Update
End Sub


相关文章