Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Minimun Distance 1

Status
Not open for further replies.

lapek

Aerospace
Aug 26, 2013
37
MX
hi everybody

i have an issue, hope you can help me with this

well i have a product with abot 130 parts, and i need to know the distance between each part,

doing it manually is terrible, hope you can help me with this,

thank you
 
Replies continue below

Recommended for you

You can go in assembly design and use the clash analysis function.

As you are not looking off clash but distance, select the option with clearance and put the parameter to a large number. Also select option Between all components so it will check each part against all.

download.aspx



Eric N.
indocti discant et ament meminisse periti
 
hi itsmyjob, thats a great idea,

thank you so much for your answer

is there any way to do it in a macro?

 
Code:
Private Function MeasureClash(MaxClearance As Double) As Double

    Dim MyDoc As Document
    Set MyDoc = CATIA.ActiveDocument
    
    Dim MyProduct As Product
    Set MyProduct = MyDoc.Product
    
    Dim Product1 As Product
    Dim Product2 As Product
    
    Set Product1 = MyProduct.Products.Item("Part1.1")
    Set Product2 = MyProduct.Products.Item("Part2.1")
    
    Dim MySelection As Selection
    Set MySelection = MyDoc.Selection
    
    MySelection.Clear
    Call MySelection.Add(Product1)
    Call MySelection.Add(Product2)
    
    Dim cClashes As Clashes
    Set cClashes = MyProduct.GetTechnologicalObject("Clashes")
    
    Dim MyClash As Clash
    Set MyClash = cClashes.AddFromSel
    
    MyClash.ComputationType = catClashComputationTypeInsideOne
    
    If MaxClearance > 0 Then
    
        MyClash.InterferenceType = catClashInterferenceTypeClearance
        MyClash.Clearance = MaxClearance
        
    Else
    
       MyClash.InterferenceType = catClashInterferenceTypeContact
        
    End If
    
    MyClash.Compute
    
    MySelection.Clear
    
    Dim i As Integer
    
    If MyClash.Conflicts.Count <> 0 Then
        
        For i = 1 To MyClash.Conflicts.Count
            
            Dim MyConflict As Conflict
            Set MyConflict = MyClash.Conflicts.Item(i)
            
            If MyConflict.Type = catConflictTypeClash Then
            
                MeasureClash = MyConflict.Value
            
            End If
            
            If MyConflict.Type = catConflictTypeClearance Then
            
                MeasureClash = MyConflict.Value
                
            End If
            
            If MyConflict.Type = catConflictTypeContact Then
            
                MeasureClash = MyConflict.Value
                
            End If
            
        Next
    
    Else
    
        MsgBox "Clearance Value > " + CStr(MaxClearance)
        MeasureClash = 3333
        
    End If
    
End Function

Private Function MeasureDistance() As Double

    Dim MyDoc As Document
    Set MyDoc = CATIA.ActiveDocument
    
    Dim MyProduct As Product
    Set MyProduct = MyDoc.Product
    
    Dim Product1 As Product
    Dim Product2 As Product
    
    Set Product1 = MyProduct.Products.Item("Part1.1")
    Set Product2 = MyProduct.Products.Item("Part2.1")
    
    Dim MySelection As Selection
    Set MySelection = MyDoc.Selection
    
    MySelection.Clear
    Call MySelection.Add(Product1)
    Call MySelection.Add(Product2)
    
    Dim cDistances As Distances
    Set cDistances = MyProduct.GetTechnologicalObject("Distances")
    
    Dim MyDistance As Distance
    Set MyDistance = cDistances.AddFromSel
    
    MyDistance.ComputationType = catDistanceComputationTypeInsideOne
    MyDistance.MeasureType = catDistanceMeasureTypeMinimum
    
    MeasureDistance = MyDistance.Value
    
    MySelection.Clear
    
End Function
 
hi jagandeep sorry for the delay, i was out a while,

thank you so much for this code, it really help me a lot

i wonder if, this code just work for products? or it can be used also to mesure between partbodies within a part?

 
Unfortunately MeasureDistance and MeasureClash only works on Product Documents. And as per documentation we can't even use Measurable to measure minimum distance between two bodies in a single part.

V5 Automation Documentation said:
Measurable (Object)
System.IUnknown
System.IDispatch
System.CATBaseUnknown
System.CATBaseDispatch
System.AnyObject
Measurable
The interface to access a CATIAMeasurable Get measurements on the object.

Two types of measurement can be done:

itself : gives dimensions related to the object itself (ex the radius of a circle).
between : gives dimensions related to another object (ex the distance between two products). A restriction occurs for distance between: bodies (CATBody) cannot be measured.

This is a shame on Dessault's Part.
 
there is an option in the assembly workbench - distance and band analysis that you can use to measure the distance between two parts. i don't know if it's possible to access it through a macro though.
 
thank you so much for your answers

i will try different ways to find a solution for this.

thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top