明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2423|回复: 1

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

[复制链接]
发表于 2005-11-3 16:54:00 | 显示全部楼层 |阅读模式

想用以下代码拉伸生成实体,结果什么也没有得到,也没有报错?请大家看看!

'构造选择集
    Dim gear As AcadSelectionSet
    On Error Resume Next
    If Not IsNull(AcadApp.ActiveDocument.SelectionSets.Item("gear_set")) Then
        Set gear = AcadApp.ActiveDocument.SelectionSets.Add("gear_set")
    End If
   
    gear.Select acSelectionSetAll
       
    '复制选择集里的对象
    Dim ents(11) As AcadEntity
    For i = 0 To gear.Count - 1
        Set ents(i) = gear.Item(i).Copy
    Next i
      
    '定义面域
    Dim reg As Variant
    Set reg = AcadApp.ActiveDocument.ModelSpace.AddRegion(ents)
                   
    '拉伸实体
    Dim height As Double
    Dim taperAngle As Double
    height = 8
    taperAngle = 0
       
    Dim rack As Acad3DSolid
    Set rack = AcadApp.ActiveDocument.ModelSpace.AddExtrudedSolid(reg, height, taperAngle)

 楼主| 发表于 2005-11-3 17:00:00 | 显示全部楼层

是不是定义面域部分就出错了?

面域的属性和方法都不能通过reg对象引用啊?

是怎么回事?

另外,我看到帮助文件里类似的例子在使用AddExtrudedSolid方法是第一个参数写成了数组形式,即写成:

Set rack = AcadApp.ActiveDocument.ModelSpace.AddExtrudedSolid(reg(0), height, taperAngle)

帮助中的实体可以拉伸生成,我的却不行,为什么?

帮助中的例子如下:

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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 08:22 , Processed in 0.175912 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表