×
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

Measure bodies distance

Measure bodies distance

Measure bodies distance

(OP)
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:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

RE: Measure bodies distance

(OP)
Found it.

CODE --> CATVBA

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:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

RE: Measure bodies distance

(OP)
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:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

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