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!

Catia Macro: Measure Minimum Distance Between Two Parts in a Product

Status
Not open for further replies.

jagandeep

Automotive
May 27, 2013
82
IN
Hello

I want to measure minimum distance between two parts in a product. But I am not able to get it work. Below is my code.

Code:
Sub CATMain()

    Dim MyDoc As Document
    Set MyDoc = CATIA.ActiveDocument
    
    Dim MainProduct As Product
    Set MainProduct = MyDoc.Product
    
    Dim product1 As Product
    Dim product2 As Product
    
    Set product1 = MainProduct.Products.Item("Housing.1")
    Set product2 = MainProduct.Products.Item("Part1.2_Manual")
    
    Dim SPAWorkbench1 As SPAWorkbench
    Set SPAWorkbench1 = MyDoc.GetWorkbench("SPAWorkbench")
    
    Dim reference1 As Reference
    Dim reference2 As Reference
    
    Set reference1 = MainProduct.CreateReferenceFromName("Product1/Housing.1/")
    Set reference2 = MainProduct.CreateReferenceFromName("Product1/Part1.2_Manual/")
    
    Dim measurable1 As Measurable
    Set measurable1 = SPAWorkbench1.GetMeasurable(reference1)
    
    MsgBox measurable1.GetMinimumDistance(reference2)
    
End Sub

Please help me
 
Replies continue below

Recommended for you

My Problem is still not solved. Anyone please help
 
Measure Between allows you to select different children(instances) of a product and give minimum distance between two products. But somehow the same thing is not exposed through automation. One can't create reference from product instance.
Yes it is necessary to get it as I am working on something really complex where clearance calculation takes around 30 sec per iteration and I have to do it around 1500 times.

Right now I am using Distance and Clash Object to calculate clearance and interference but its very time consuming. Want to test the same with measurable if I get some speed advantage.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top