如标题中所述。我使用excel VBA在CAD中绘制了折线我需要找到折线的质心坐标我不知道正确的代码。
Sub Drawline()
Dim point(0 To 7) As Double
Dim myapp As Object
Dim AcadDwg As AcadDocument
Dim B As Double
On Error GoTo ERRORHANDLER
Set myapp = GetObject(, "autocad.application")
ERRORHANDLER:
If Err.Description <> "" Then
Err.Clear
Set myapp = CreateObject("Autocad.Application")
End If
myapp.Visible = True
Set AcadDwg = myapp.ActiveDocument
'Now Excel VBA = CAD VBA with same coding
Dim line As AcadLWPolyline
point(0) = 0: point(1) = 0
point(2) = 1: point(3) = 1
point(4) = 2: point(5) = 0
point(6) = 0: point(7) = 0
Set line = AcadDwg.ModelSpace.AddLightWeightPolyline(point)
Dim t As AcadLayer
Set t = AcadDwg.Layers.Add("pline")
line.ConstantWidth = 0.1
B = line.Area
MsgBox B
End Sub