在块中插入公式
大家好,我是autocad新手。实际上,这是我第一次需要为autocad编写VBA程序。这就是我发布这个帖子的原因。
我有属性块。在其中一个属性中,我想插入一个计算多段线面积的表达式。
手动操作有效。表达式为:
“%%”)。面积>%”,其中213001176是特定多边形的ObjectID。
我试图用以下代码通过vba插入表达式:
attArr=oBlkRef。获取属性
附件(3)。TextString=“%%”)。面积>%”
它不起作用,并且不会计算值(对应于多边形区域)。只有“#####”显示为值。
知道如何通过VBA插入表达式吗? 我想你需要另外两条线
面积=“%%”)。面积>%”
附件(3)。TextString=面积
附件(3)。使现代化
找到了这个
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 modelspace
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
' Close the polyline and update display of it
plineObj.Closed = True
plineObj.Update
ZoomAll
' Get the area of the polyline
plineArea = plineObj.Area
MsgBox "The area of the new Polyline is: " & plineArea, vbInformation, "Area Example"
End Sub 找到了解决方案,谢谢。
属性。TextString=“%%”)。面积\f”&Chr(34)&“%lu2”&Chr(34)&“>%”
其中Cstr(id)是poly objectID
页:
[1]