×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Get Minimun Distance

Get Minimun Distance

Get Minimun Distance

(OP)
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

RE: Get Minimun Distance

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.


Eric N.
indocti discant et ament meminisse periti

RE: Get Minimun Distance

(OP)
hi itsmyjob, thats a great idea,

thank you so much for your answer

is there any way to do it in a macro?

RE: Get Minimun Distance

CODE --> VBA

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 

RE: Get Minimun Distance

(OP)
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?

RE: Get Minimun Distance

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.

Quote (V5 Automation Documentation)

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.

RE: Get Minimun Distance

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.

RE: Get Minimun Distance

(OP)
thank you so much for your answers

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

thank you

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources