# 这段代码好像只能在Default的Model运行！这是有什么逻辑上的错误吗？烦请诸位老师指点

Option Explicit

Function ChangeToSolid(shapePoints() As Point3d, forwardLen As Double, backwardLen As Double) As SmartSolidElement
Dim base As ShapeElement

Set base = Application.CreateShapeElement1(Nothing, shapePoints)
Dim ConeSurface1 As SmartSolidElement
Dim ConeSurface2 As SmartSolidElement
Dim tempE As ElementEnumerator

Set ConeSurface1 = SmartSolid.ExtrudeClosedPlanarCurve(base, forwardLen, 0, True)

Set ConeSurface2 = SmartSolid.ExtrudeClosedPlanarCurve(base, 0, -backwardLen, True)

Set ChangeToSolid = SmartSolid.SolidUnion(ConeSurface1, ConeSurface2)

End Function
Function FinallSolid(CenterPoint As Point3d, ByVal BottomLen As Double, ByVal BottomWid As Double, ByVal HeightLen As Double, ByVal TopLen As Double, ByVal TopWidth As Double) As SmartSolidElement
Dim PointList(4) As Point3d
Dim upNum As SmartSolidElement
Dim rightNum As SmartSolidElement

PointList(0) = Point3dFromXYZ(CenterPoint.x + BottomLen / 2, CenterPoint.Y, CenterPoint.Z)
PointList(1) = Point3dFromXYZ(CenterPoint.x - BottomLen / 2, CenterPoint.Y, CenterPoint.Z)
PointList(2) = Point3dFromXYZ(CenterPoint.x - TopLen / 2, CenterPoint.Y, CenterPoint.Z + HeightLen)
PointList(3) = Point3dFromXYZ(CenterPoint.x + TopLen / 2, CenterPoint.Y, CenterPoint.Z + HeightLen)
PointList(4) = Point3dFromXYZ(CenterPoint.x + BottomLen / 2, CenterPoint.Y, CenterPoint.Z)
If TopWidth > BottomWid Then
Set upNum = ChangeToSolid(PointList, TopWidth / 2 + 1, (TopWidth / 2))
Else
Set upNum = ChangeToSolid(PointList, BottomWid / 2 + 1, (BottomWid / 2))
End If
PointList(0) = Point3dFromXYZ(CenterPoint.x, CenterPoint.Y + BottomWid / 2, CenterPoint.Z)
PointList(1) = Point3dFromXYZ(CenterPoint.x, CenterPoint.Y - BottomWid / 2, CenterPoint.Z)
PointList(2) = Point3dFromXYZ(CenterPoint.x, CenterPoint.Y - TopWidth / 2, CenterPoint.Z + HeightLen)
PointList(3) = Point3dFromXYZ(CenterPoint.x, CenterPoint.Y + TopWidth / 2, CenterPoint.Z + HeightLen)
PointList(4) = Point3dFromXYZ(CenterPoint.x, CenterPoint.Y + BottomWid / 2, CenterPoint.Z)
If TopLen > BottomLen Then
Set rightNum = ChangeToSolid(PointList, (TopLen / 2 + 1), (TopLen / 2))
Else
Set rightNum = ChangeToSolid(PointList, (BottomLen / 2 + 1), (BottomLen / 2))
End If

Set FinallSolid = SmartSolid.SolidIntersect(upNum, rightNum)