Chuyển đến nội dung
Diễn đàn CADViet

trandat19882010

Thành viên
  • Số lượng nội dung

    2
  • Đã tham gia

  • Lần ghé thăm cuối

Bài đăng được đăng bởi trandat19882010


  1. Em có một VBA vẽ Pline. Nhưng các Pline này không nối được với nhau. Các bác giúp em sửa VBA này để khi vẽ Pline thì nó sẽ nối các Pline riêng lẻ thành 1 Pline và khi nhập C thì nó nối với điểm đầu tiên tạo thành một Pline kín (như lệnh Pline trong AutoCAd thông thường).

    Xin cám ơn các bác.!

    Code VBA của e như sau:

    Public Sub Diem()

    Dim plineObj As AcadLWPolyline

    Dim StPnt As Variant

    Dim EdPnt As Variant

    Dim prompt1 As String

    Dim prompt2 As String

    Dim Point(0 To 3) As Double

    prompt1 = vbCrLf & " Enter a first point:"

    prompt2 = vbCrLf & " Enter a second point:"

    StPnt = ThisDrawing.Utility.GetPoint(, prompt1)

    EdPnt = ThisDrawing.Utility.GetPoint(StPnt, prompt2)

    Point(0) = StPnt(0): Point(1) = StPnt(1)

    Point(2) = EdPnt(0): Point(3) = EdPnt(1)

    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(Point)

    StPnt = EdPnt

    Retry:

    On Error Resume Next

    EdPnt = ThisDrawing.Utility.GetPoint(StPnt, vbCrLf & "Enter a next point: ")

    If Err = 0 Then

    Point(0) = StPnt(0): Point(1) = StPnt(1)

    Point(2) = EdPnt(0): Point(3) = EdPnt(1)

    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(Point)

    Else

    Err.Clear

    GoTo endP

    End If

    StPnt = EdPnt

    GoTo Retry

    endP:

    End Sub

    Bạn thêm vào dòng dưới: "Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(Point)"

    Bằng câu lệnh sau: plineObj.closed= true.

    Vậy là OK

×