首页 文章

是否有可能使用Catia vba移动一个部件而不是产品中的约束?

提问于
浏览
-2

我必须在两个部件之间移动类似球体的探头,使探头与两个部件接触 . 我必须找到零件的接触点,测量它们的距离,并根据这个距离在零件上做一个圆角 . 我已经实现了在部件之间移动球体,但球体正在穿过部件 . 所以试图在约束条件下移动

我试图在Catia产品中自动化操作工具 . 是否存在任何命令或方法来使用vba在Catia中移动关于约束的部分?

要么

有没有办法找到使用vba的两个部分之间的冲突?

期待解决方案 .

谢谢!!!

1 回答

  • 0

    Here是一个链接,您可以在其中找到冲突的解决方案 .

    好的,我明白了,你想在这里看到代码:-)

    要计算CATScript中的冲突:

    Sub CATMain()
    
        ' get root product of document
        Dim RootProd As Product
        Set RootProd = CATIA.ActiveDocument.Product
    
        ' retrieve selection object of active document
        Dim objSelection As Selection
        Set objSelection = CATIA.ActiveDocument.Selection
    
        ' get two selected objects
        If (objSelection.Count2 <> 2) Then
        MsgBox "Before running the script you must select two products to compute clash for", vbOKOnly, "No products selected"
        Exit Sub
        End If
    
        Dim FirstProd As Product
        Dim SecondProd As Product
    
        Set FirstProd = objSelection.Item2(1).Value
        Set SecondProd = objSelection.Item2(2).Value
    
        ' create groups for clash computation
        Dim objGroups As Groups
        Set objGroups = RootProd.GetTechnologicalObject("Groups")
    
        Dim grpFirst As Group
        Dim grpSecond As Group
    
        Set grpFirst = objGroups.Add()
        Set grpSecond = objGroups.Add()
    
        ' add selected products to groups
        grpFirst.AddExplicit FirstProd
        grpSecond.AddExplicit SecondProd
    
    
        ' get access to Clashes collection
        Dim objClashes As Clashes
        Set objClashes = RootProd.GetTechnologicalObject("Clashes")
    
        ' create new clash
        Dim newClash As Clash
        Set newClash = objClashes.Add()
    
        ' set new clash to be computed between two groups (two selected products)
        newClash.FirstGroup = grpFirst
        newClash.SecondGroup = grpSecond
    
        newClash.ComputationType = catClashComputationTypeBetweenTwo
    
        ' compute clash
        newClash.Compute
    
        End Sub
    

相关问题