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

nkgedadknr

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

    29
  • Đã tham gia

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

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


  1. Việc liên kết Excel và AutoCad đã có nhiều rồi. Thủ tục dưới đây sẽ lấy thông tin thuộc tính đối tượng Polyline:

     

    Sub Example_Area()
    ' This example creates a polyline object and
    ' then uses the area property to find the
    ' area of that polyline.
    
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 5) As Double
    Dim plineArea As Double
    
    ' Establish the points for the Polyline
    points(0) = 3: points(1) = 7
    points(2) = 9: points(3) = 2
    points(4) = 3: points(5) = 5
    
    ' Create the polyline in model space
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    
    ' Đóng polyline và cập nhật
    plineObj.Closed = True
    plineObj.Update
    ZoomAll
    
    ' Lấy diện tích của polyline
    plineArea = plineObj.Area
    
    MsgBox "The area of the new Polyline is: " & plineArea, vbInformation, "Area Example"
    End Sub

     

    Dạ nhờ bác thêm chút xíu, em có các text trong acad, làm thế nào duyệt qua tất cả các text này lấy nội dung của nó và gửi qua Excel ạ?


  2. Việc liên kết Excel và AutoCad đã có nhiều rồi. Thủ tục dưới đây sẽ lấy thông tin thuộc tính đối tượng Polyline:

     

    Sub Example_Area()
    ' This example creates a polyline object and
    ' then uses the area property to find the
    ' area of that polyline.
    
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 5) As Double
    Dim plineArea As Double
    
    ' Establish the points for the Polyline
    points(0) = 3: points(1) = 7
    points(2) = 9: points(3) = 2
    points(4) = 3: points(5) = 5
    
    ' Create the polyline in model space
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    
    ' Đóng polyline và cập nhật
    plineObj.Closed = True
    plineObj.Update
    ZoomAll
    
    ' Lấy diện tích của polyline
    plineArea = plineObj.Area
    
    MsgBox "The area of the new Polyline is: " & plineArea, vbInformation, "Area Example"
    End Sub

     

    Dạ nhờ bác thêm chút xíu, em có các text trong acad, làm thế nào duyệt qua tất cả các text này lấy nội dung của nó và gửi qua Excel ạ?


  3. Mình muốn viết 1 sub DrawLine dùng để vẽ 1 Line or 1 PolyLine kèm theo xuất chiều dài và gán lớp cho entity này. sau đó trong các Sub khác mình sẽ gọi lại sub DrawLine này.

    Đây là code:

    Private Sub DrawLine()
    Dim varStart, varEnd As Variant
    Dim objEnt As AcadLine
    
    On Error Resume Next
    
    
    If ThisDrawing.ActiveSpace = acModelSpace Then
    Set objEnt = ThisDrawing.ModelSpace.AddLine(varStart, varEnd)
    Else
    Set objEnt = ThisDrawing.PaperSpace.AddLine(varStart, varEnd)
    End If
    objEnt.Update
    End With
    
    End Sub

    Còn ở các Sub kia thì mình gọi DrawLine() như sau

    With ThisDrawing.Utility
    point1 = .GetPoint(, vbCr & "Pick Start point: ")
    point2 = .GetPoint(point1, vbCr & "Pick End point: ")
    [b]Call DrawLine()[/b]

    nhưng nó báo error ???

     

    Anh em check dùm mình? và chỉ mình cách viết 1 sub kiểu như thế có giống viết 1 hàm Function hay không?

    Mình programmer ABC lắm

    Thanks for help!

×