人在浆糊 发表于 2003-10-31 15:43:00

求教:用vba怎么画一个圆柱体,输入圆柱起点和终点坐标,圆柱半径?

efan2000 发表于 2003-10-31 18:48:00

Sub AddCylinder()
    ' 例子演示了在模型空间创建一个圆柱体
   
    Dim cylinderObj As Acad3DSolid
    Dim radius As Double
    Dim center(0 To 2) As Double
    Dim height As Double
   
    ' 定义圆柱体
    center(0) = 0#: center(1) = 0#: center(2) = 0#
    radius = 5#
    height = 20#
   
    ' 在模型空间创建一个圆柱体(三维实体)
    Set cylinderObj = ThisDrawing.ModelSpace.AddCylinder(center, radius, height)
   
    ' 更改视口的视角,以观看圆柱体
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
    ThisDrawing.ActiveViewport.Direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
End Sub
页: [1]
查看完整版本: 求教:用vba怎么画一个圆柱体,输入圆柱起点和终点坐标,圆柱半径?