我想画一条管道,看是否与其他管道冲突,想用AddExtrudedSolidAlongPath这个方法扫掠路径生成实体,结果看了帮助文件,老是提示创建失败。
我仔细阅读了帮助文件的示例,复制粘贴到CAD VBA编辑器中,运行还是提示创建失败。
提示如下:
示例如下:
- Sub Example_AddExtrudedSolidAlongPath()
- ' 该示例将面域沿样条曲线所定义的路径拉伸成实体。
- ' 面域是由圆弧和直线创建的。
-
- Dim curves(0 To 1) As AcadEntity
- ' 定义圆弧
- Dim centerPoint(0 To 2) As Double
- Dim radius As Double
- Dim startAngle As Double
- Dim endAngle As Double
- centerPoint(0) = 5#: centerPoint(1) = 3#: centerPoint(2) = 0#
- radius = 2#
- startAngle = 0
- endAngle = 3.141592
- Set curves(0) = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngle, endAngle)
-
- ' 定义线
- Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).startPoint, curves(0).endPoint)
-
- ' 创建面域
- Dim regionObj As Variant
- regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
-
- ' 定义拉伸路径(样条曲线对象)
- Dim splineObj As AcadSpline
- Dim startTan(0 To 2) As Double
- Dim endTan(0 To 2) As Double
- Dim fitPoints(0 To 8) As Double
-
- ' 定义样条曲线对象
- startTan(0) = 10: startTan(1) = 10: startTan(2) = 10
- endTan(0) = 10: endTan(1) = 10: endTan(2) = 10
- fitPoints(0) = 0: fitPoints(1) = 10: fitPoints(2) = 10
- fitPoints(0) = 10: fitPoints(1) = 10: fitPoints(2) = 10
- fitPoints(0) = 15: fitPoints(1) = 10: fitPoints(2) = 10
- Set splineObj = ThisDrawing.ModelSpace.AddSpline(fitPoints, startTan, endTan)
-
- ' 创建实体
- Dim solidObj As Acad3DSolid
- Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(regionObj(0), splineObj)
- ZoomAll
-
- End Sub
|