TA的每日心情 | 衰 3-12-2017 21:57 |
---|
签到天数: 8 天 [LV.3]偶尔看看II
|

楼主 |
发表于 23-4-2014 21:31:20
|
显示全部楼层
本帖最后由 Siren666 于 23-4-2014 22:30 编辑
3楼的代码比较繁琐,而且运行不了。第二行就出现错误。
今天编辑多次,运行多次,终于成功了
代码如下:
Sub CATMain()
Dim odoc, opart, ohbodies, ohbody, ohybridshapefactory, oshere, oselection, status, pointreference
Dim i, inputtype(0)
CATIA.Visible = True
Set odoc = CATIA.ActiveDocument
Set opart = odoc.Part
Set ohbodies = opart.HybridBodies
Set ohbody = ohbodies.Add()
ohbody.Name = ohbody.Name & "(sphere)"
Set oselection = odoc.Selection
Set ohybridshapefactory = opart.HybridShapeFactory
For i = 1 To oselection.Count
Set pointreference = opart.CreateReferenceFromObject(oselection.Item(i).Value)
Set osphere = ohybridshapefactory.AddNewSphere(pointreference,Nothing,3,-45,45,-180,180)
osphere.Limitation = 1
ohbody.AppendHybridShape osphere
Next
opart.Update
End Sub
=====================
首先要选取点 |
|