Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng 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
Joined
May 22, 2013
Messages
503
Location
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:
 
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:
 
There is always a good reason for something :)

But i don't have the need to export it. It's something that I need during a macro execution, Depending in the value of the measure it does some actions.

Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top