Search code examples
vbacatia

Is it possible to move a part with repect to constraints in Product using Catia vba?


I have to move a probe like sphere between two parts such that the probe is in contact with both the parts. And I have to find the point of contact of the parts, measure their distance and make a fillet on the parts based on this distance. I have achieved in moving the sphere between the parts but the sphere is moving through the parts. So trying to move with respect to constraints

I am trying to automate the manipulate tool in Catia Product. Is there any command or method exist to move a part with respect to contraints in Catia using vba ?

Or

Is there any way to find the clash between two parts using vba ?

Looking Forward for a solution.

Thank you!!!


Solution

  • Here is a link where you can find a solution for clash.

    OK, I got the idea, you want to see the code here :-)

    To compute clash in a 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