Inventor 2014 API 新功能 (5) 3D草图相交曲线

通过曲面和曲面获取相交曲线是产品已经有的功能,2014 API全面支持了! 一个很直接的方法:

Sketch3D.IntersectionCurves.Add( EntityOne As Object, EntityTwo As Object ) As IntersectionCurve

EntityOne: 参与相交的第一个对象,可以是SurfaceBody, Face, WorkPlane 或 2D 草图曲线。 

EntityTwo:参与相交的第二个对象,可以是SurfaceBody, Face, WorkPlane 或 2D 草图曲线。 但注意一些限制:
                   如果第一个对象是WorkPlane ,则第二个参数不能是WorkPlane; 如果是集合类型的,例如Faces或FaceCollection, 则这些Face必须属于同一SurfaceBody.;如果第一对象是2D 草图线,则第二对象必须是另外草图的2D草图线。 

以下例子基于前面创建的样条曲线以及方程曲线,分别创建了其曲面,最后做相交工作。

Public Sub Sketch3DIntersectCurves()
    ' 创建零件文档.
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
                  ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
    Dim partDef As PartComponentDefinition
    Set partDef = partDoc.ComponentDefinition
                  
    ' 基于X-Y创建草图.
    Dim sketch1 As PlanarSketch
    Set sketch1 = partDef.Sketches.Add(partDef.WorkPlanes.Item(3))
    
    Dim tg As TransientGeometry
    Set tg = ThisApplication.TransientGeometry
    
    ' 创建样条曲线
    Dim pnts As ObjectCollection
    Set pnts = ThisApplication.TransientObjects.CreateObjectCollection
    Call pnts.Add(tg.CreatePoint2d(2, 0))
    Call pnts.Add(tg.CreatePoint2d(4, 1))
    Call pnts.Add(tg.CreatePoint2d(4, 2))
    Call pnts.Add(tg.CreatePoint2d(6, 3))
    Call pnts.Add(tg.CreatePoint2d(8, 1))
    Dim controlPointSpline As SketchControlPointSpline
    Set controlPointSpline = sketch1.skeSketchControlPointSplines.Add(pnts)
    
    ' 基于Y-Z创建草图
    Dim sketch2 As PlanarSketch
    Set sketch2 = partDef.Sketches.Add(partDef.WorkPlanes.Item(1))
    
    ' 创建方程曲线
    Dim equationCurve As SketchEquationCurve
    Set equationCurve = sketch2.SketchEquationCurves.Add(kParametric, kCartesian, _
                                ".001*t * cos(t)", ".001*t * sin(t)", 0, 360 * 3)                                
     
                            
    ThisApplication.ActiveView.Fit
    
    '通过样条曲线做拉伸曲面
    Dim prof As Profile
    Set prof = sketch1.Profiles.AddForSurface(controlPointSpline)
    Dim extrudeDef As ExtrudeDefinition
    Set extrudeDef = partDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(prof, kSurfaceOperation)
    Call extrudeDef.SetDistanceExtent(6, kSymmetricExtentDirection)
    Dim extrude1 As ExtrudeFeature
    Set extrude1 = partDef.Features.ExtrudeFeatures.Add(extrudeDef)
    
    ' 设置曲面不透明
    Dim surf As WorkSurface
    Set surf = extrude1.SurfaceBodies.Item(1).Parent
    surf.Translucent = False
    
    '通过方程曲线做拉伸曲面
    Set prof = sketch2.Profiles.AddForSurface(equationCurve)
    Set extrudeDef = partDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(prof, kSurfaceOperation)
    Call extrudeDef.SetDistanceExtent(9, kPositiveExtentDirection)
    Dim extrude2 As ExtrudeFeature
    Set extrude2 = partDef.Features.ExtrudeFeatures.Add(extrudeDef)
    
    ' 获取相交的3D曲线
    Dim interSketch As sketch3D
    Set interSketch = partDef.Sketches3D.Add
    
    Call interSketch.IntersectionCurves.Add(extrude1.SurfaceBodies.Item(1), extrude2.SurfaceBodies.Item(1))
End Sub



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值