中国汽车工程师之家--聚集了汽车行业80%专业人士 

论坛口号:知无不言,言无不尽!QQ:542334618 

本站手机访问:直接在浏览器中输入本站域名即可 

  • 2471查看
  • 5回复

【求助】catia用vb用点生成球的代码

[复制链接]

  • TA的每日心情

    3-12-2017 21:57
  • 签到天数: 8 天

    [LV.3]偶尔看看II

    发表于 2-9-2012 11:22:23 | 显示全部楼层 |阅读模式

    汽车零部件采购、销售通信录       填写你的培训需求,我们帮你找      招募汽车专业培训老师


    catia里车身焊点比较多,画完点有时候要生成球。
    以前用过这样的代码,现在没有了。
    希望有人能将该代码发一下,万分感谢!
    
  • TA的每日心情
    无聊
    29-12-2017 07:59
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 12-10-2012 15:58:16 | 显示全部楼层
    期待高手!!!
    回复 支持 反对

    使用道具 举报

    
  • TA的每日心情
    奋斗
    20-7-2015 20:39
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 10-6-2013 17:28:57 | 显示全部楼层
    Sub CATMain()

    dim aaa as document
    set aaa = catia activedocument

    Dim partDocument1 As PartDocument
    Set partDocument1 = CATIA.ActiveDocument

    Dim part1 As Part
    Set part1 = partDocument1.Part

    Dim hybridShapeFactory1 As HybridShapeFactory
    Set hybridShapeFactory1 = part1 HybridShapeFactory

    Dim hybridBodies1 As HybridBodies
    Set hybridBodies1 = part1 Hybridbodies

    Dim hybridShapes1 As HybridShapes
    Set hybridShapes1 = HybridBody1 HybridShapes

    Dim selection As selection
    Set oSel = partDocument1 Selection

    Dim InputObjectType(0)

    InputObjectType(0) = "Point"


         Status = oSel.SelectElement3(InputObjectType,"框选焊点",True,1,True)
         If (Status = "Cancel")Then
             oSel Clear Exit Sub
         End If

    for i=1 to oSel count

    Dim hybridShapePointExplicit1 As Parameter
    Set hybridShapePointExplicit1 = oSel Item(i)

    Dim reference1 As Reference
    Set reference1 =oSel Item(i) value


    Dim hybridShapeSphere1 As HybridShapeSphere
    Set hybridShapeSphere1 = hybridShapeFactory1 AddNewSphere(referencel,Nothing,6.000000,-45.000000,45.000000,0.000000,180.000000)

    hybridShapeSphere1 limitation = 1

    hybridBody1 AppendHybridShape hybridShapeSphere1

    part1 InWorkObject = hybridShapeSphere1

    next

    part1 Update

    End Sub
    回复 支持 反对

    使用道具 举报

    
  • TA的每日心情
    难过
    31-7-2016 06:17
  • 签到天数: 8 天

    [LV.3]偶尔看看II

    发表于 23-8-2013 01:15:34 | 显示全部楼层
    类似二次开发了啊
    回复 支持 反对

    使用道具 举报

    
  • 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

    =====================
    首先要选取点
    回复 支持 反对

    使用道具 举报

    

    该用户从未签到

    发表于 23-5-2015 18:19:23 | 显示全部楼层
    Siren666 发表于 23-4-2014 21:31
    3楼的代码比较繁琐,而且运行不了。第二行就出现错误。

    今天编辑多次,运行多次,终于成功了

    立马去试试
    回复 支持 反对

    使用道具 举报

    快速发帖

    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    QQ|手机版|小黑屋|Archiver|汽车工程师之家 ( 渝ICP备18012993号-1 )

    GMT+8, 23-2-2025 11:53 , Processed in 0.676658 second(s), 43 queries .

    Powered by Discuz! X3.5

    © 2001-2013 Comsenz Inc.