- 积分
- 1044
- 明经币
- 个
- 注册时间
- 2003-4-1
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2004-4-21 11:47:00
|
显示全部楼层
问题是这样的:
在用VBA编程时,需要建立自己的工作平面或者轴,例如需要建立一个与xy 、yz平面均成45度角的工作平面用VBA 程序怎么实现?
跟确切,就是我在进行阵列时,想通过建立一个自己的工作轴进行阵列(如图所画),该怎么建立呢?
代码如下:
PI = 4 * Atn(1)
Dim myDocPart As PartDocument Dim myComDef As PartComponentDefinition Dim mySketch As PLanarSketch Dim myRect As SketchEntitiesEnumerator ' Dim myTrGm As TransientGeometry Dim myProfile As Profile Dim myPt1 As Point2d Dim myPt2 As Point2d
Dim myExtrude As ExtrudeFeature
Set myDocPart = ThisApplication.Documents.Add(kPartDocumentObject, , True) Set myComDef = myDocPart.ComponentDefinition Set mySketch = myComDef.Sketches.Add(myComDef.WorkPlanes(3))
Set myTrGm = ThisApplication.TransientGeometry
Set myPt1 = myTrGm.CreatePoint2d(0, 0) Set myPt2 = myTrGm.CreatePoint2d(10, 10) Set myRect = mySketch.SketchLines.AddAsTwoPointRectangle(myPt1, myPt2)
Set myProfile = mySketch.Profiles.AddForSolid
Set myExtrude = myComDef.Features.ExtrudeFeatures.AddByDistanceExtent(myProfile, 1, kNegativeExtentDirection, kJoinOperation) 'Set myExtrude = myComDef.Features.ExtrudeFeatures.AddByDistanceExtent(myProfile, 1, kNegativeExtentDirection, kJoinOperation)
'在得到的拉伸实体的顶面建立草图 Dim myFace As Face Set myFace = myExtrude.StartFaces.Item(1) Set mySketch = myComDef.Sketches.Add(myFace)
Set myPt1 = myTrGm.CreatePoint2d(1, 1) Set myPt2 = myTrGm.CreatePoint2d(2.5, 2.5)
Set myRect = mySketch.SketchLines.AddAsTwoPointRectangle(myPt1, myPt2)
'拉通小槽 Set myProfile = mySketch.Profiles.AddForSolid Dim myExtruct1 As ExtrudeFeature Set myExtruct1 = myComDef.Features.ExtrudeFeatures.AddByThroughAllExtent(myProfile, kNegativeExtentDirection, kCutOperation)
'阵列 圆形阵列
dim myFeatColl As ObjectCollection Set myFeatColl = ThisApplication.TransientObjects.CreateObjectCollection myFeatColl.Add myExtruct1
Dim myXaxis As WorkAxis Set myXaxis = myComDef.WorkAxes.Item(1) 'X Dim myYaxis As WorkAxis Set myYaxis = myComDef.WorkAxes.Item(2) 'Y Dim myZaxis As WorkAxis Set myZaxis = myComDef.WorkAxes.Item(3) 'Z
myZaxis.Visible = True
Dim myCircPattern As CircularPatternFeature Dim myStartPt As SketchPoint Set myStartPt = mySketch.SketchPoints.Add(myPt2) Set myCircPattern = myComDef.Features.CircularPatternFeatures.Add(myFeatColl, myZaxis, True, 8, 2 * PI, True, True)
'问题在于我想建立 自己的旋转轴(图中所画)取代上一行代码中的 myZaxis(图中的z轴,黄色)
|
|