mjtppf 发表于 2005-11-3 16:54:00

[求助]由面域拉伸生成实体的疑问?

<P>想用以下代码拉伸生成实体,结果什么也没有得到,也没有报错?请大家看看!</P>
<P>'构造选择集<BR>&nbsp;&nbsp;&nbsp; Dim gear As AcadSelectionSet<BR>&nbsp;&nbsp;&nbsp; On Error Resume Next<BR>&nbsp;&nbsp;&nbsp; If Not IsNull(AcadApp.ActiveDocument.SelectionSets.Item("gear_set")) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set gear = AcadApp.ActiveDocument.SelectionSets.Add("gear_set")<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; gear.Select acSelectionSetAll<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '复制选择集里的对象<BR>&nbsp;&nbsp;&nbsp; Dim ents(11) As AcadEntity<BR>&nbsp;&nbsp;&nbsp; For i = 0 To gear.Count - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ents(i) = gear.Item(i).Copy<BR>&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '定义面域<BR>&nbsp;&nbsp;&nbsp; Dim reg As Variant<BR>&nbsp;&nbsp;&nbsp; Set reg = AcadApp.ActiveDocument.ModelSpace.AddRegion(ents)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; '拉伸实体<BR>&nbsp;&nbsp;&nbsp; Dim height As Double<BR>&nbsp;&nbsp;&nbsp; Dim taperAngle As Double<BR>&nbsp;&nbsp;&nbsp; height = 8<BR>&nbsp;&nbsp;&nbsp; taperAngle = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim rack As Acad3DSolid<BR>&nbsp;&nbsp;&nbsp; Set rack = AcadApp.ActiveDocument.ModelSpace.AddExtrudedSolid(reg, height, taperAngle)</P>

mjtppf 发表于 2005-11-3 17:00:00

<P>是不是定义面域部分就出错了?</P>
<P>面域的属性和方法都不能通过reg对象引用啊?</P>
<P>是怎么回事?</P>
<P>另外,我看到帮助文件里类似的例子在使用AddExtrudedSolid方法是第一个参数写成了数组形式,即写成:</P>
<P>Set rack = AcadApp.ActiveDocument.ModelSpace.AddExtrudedSolid(reg(0), height, taperAngle)</P>
<P>帮助中的实体可以拉伸生成,我的却不行,为什么?</P>
<P>帮助中的例子如下:</P><PRE class=Code>Sub Example_AddExtrudedSolid()
    ' This example extrudes a solid from a region.
    ' The region is created from an arc and a line.
   
    Dim curves(0 To 1) As AcadEntity

    ' Define the arc
    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)
   
    ' Define the line
    Set curves(1) = ThisDrawing.ModelSpace.AddLine(curves(0).startPoint, curves(0).endPoint)
      
    ' Create the region
    Dim regionObj As Variant
    regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
   
    ' Define the extrusion
    Dim height As Double
    Dim taperAngle As Double
    height = 3
    taperAngle = 0
   
    ' Create the solid
    Dim solidObj As Acad3DSolid
    Set solidObj = ThisDrawing.ModelSpace.AddExtrudedSolid(regionObj(0), height, taperAngle)
               
End Sub</PRE>
页: [1]
查看完整版本: [求助]由面域拉伸生成实体的疑问?