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!

Measure bodies distance 1

Status
Not open for further replies.

TiagoFigueiredo

Industrial
May 22, 2013
494
PT
I need a macro to do the following. I have two bodies located in 2 different parts, that I need to measure the distance between both.

How can I do it? I only have four days examples for parts.

I'm doing in vb.net, but you can help me in the other languages.

Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Replies continue below

Recommended for you

Found it.

Code:
Sub CATMain()

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

'Two bodies are already selected

Set selection1 = partDocument1.Selection


Dim a As Body
Dim b As Body

Set a = selection1.Item(1).Value
Set b = selection1.Item(2).Value


Dim reference1 As Reference
    Set reference1 = part1.CreateReferenceFromObject(a)
    Dim reference2 As Reference
    Set reference2 = part1.CreateReferenceFromObject(b)


'get the SPAworkbench
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
 
Dim TheMeasurable As Measurable
Set TheMeasurable = TheSPAWorkbench.GetMeasurable(reference1)
 
Dim MinimumDistance As Double
MinimumDistance = TheMeasurable.GetMinimumDistance(reference2)


End Sub

Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top