×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*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.

# Distance between 2 parallel planes.

## Distance between 2 parallel planes.

(OP)
How can I get the distance between 2 parallel planes using VBA?
The planes are in a geometrical set in a part.

3D, 2D?

### RE: Distance between 2 parallel planes.

(OP)
1d - Parallel planes.

### RE: Distance between 2 parallel planes.

check v5automation.chm file for MeasurableBetween

Eric N.
indocti discant et ament meminisse periti

(OP)

### RE: Distance between 2 parallel planes.

Try this:

#### CODE -->

Func GetMinimumDistance( Reference  iMeasuredItem) As double

Compute the minimum distance between the CATIAMeasurable and another. Bodies (openbody, hybridbody..) cannot be measured between.
Parameters:
oCoordinates
The information of the axis system with respect to the product coordinate system:
oComponents(0) is the X coordinate of the origin of the axis system
oComponents(1) is the Y coordinate of the origin of the axis system
oComponents(2) is the Z coordinate of the origin of the axis system
oComponents(3) is the X coordinate of the first direction of the axis system
oComponents(4) is the Y coordinate of the first direction of the axis system
oComponents(5) is the Z coordinate of the first direction of the axis system
Example:
This example retrieves the distance between the reference1 and reference2.
Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromObject(object1)
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromObject(object1)
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) 

Tiago Figueiredo
Tooling Engineer

### RE: Distance between 2 parallel planes.

(OP)
Thank you Tiago,

It works in VBA.

How ever, in VB.net the line

MinimumDistance = TheMeasurable.GetMinimumDistance(reference2)

gives an error

"HRESULT E_FAIL has been returned from a call to a COM component"

Also how can we see properties and methods on CATIA COM components in VB.net?

### RE: Distance between 2 parallel planes.

(OP)
It is already imported. In rest of the program it is working.
I am creating two planes, moving them by some math and then measuring the final distance with them. Only at this line it gets stuck. That's why I am puzzled.

### RE: Distance between 2 parallel planes.

In the past I had problems with something similar. It was weird...

At that time I played a bit with target cpu, and it worked. If I remember well, I was having a problem with inserting a powercopy. Try that.

Tiago Figueiredo
Tooling Engineer

### RE: Distance between 2 parallel planes.

(OP)
I have VB 2017 community, but because of familiarity I am initially doing it in VB Express 2010. When I compile (build), I get the following out put.

------ Build started: Project: catBB10, Configuration: Release x86 ------
catBB10 -> F:\Users\0SanjayData\0Jobs\zzzDemos1901\CATIA\catBB10\catBB10\bin\Debug\catBB10.exe
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

So, I suppose my target CPU is already x86.

So where do we go next?

(OP)
Yes.

### RE: Distance between 2 parallel planes.

(OP)
OK! Give me some time.

### RE: Distance between 2 parallel planes.

(OP)
Solved!!

The problem was somewhere else and finally I could figure it out. Everything works fine now. I converted it into VB 2017 community dll and the dll works fine, at least for the trial part, in the calling program.

I was processing planes in different subs and in one of the subs they were passed ByVal instead of ByRef. So, for min. distance, deleted planes were passed as parameters.

I didn't get the required clue due to the cryptic message "Hresults ...". I checked if planes were 'not is nothing' and every time I found the result false. Instead, if I had got the error message something like "the object does not exist" or the "object is deleted" I would have located the error immediately.

Today, while preparing the code for posting, I did exhaustive debugging to make sure; and realized the error. It was 'Why didn't I do this the first time' moment.

Thanks for your time and efforts, Tiago Figueiredo.

My next task is to validate the code by testing it on multiple parts inside a loop.

#### 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.

#### Resources

eBook - Mastering Tolerances for Machined Parts
When making CNC machined parts, mastering tolerances can be challenging. Are general tolerances good enough? When does it make sense to call out for tighter tolerances? Do you need a better understanding of fits, datums, or GD&T? Learn about these topics and more in Xometry's new e-book. Download Now
eBook – How to Choose the Correct Corrosion Testing Method
When designing a metal component, engineers have to consider how susceptible certain alloys are to corrosion in the final product’s operating environment. In a recent study by NACE (National Association of Corrosion Engineers), it was estimated that the direct and indirect costs of corrosion in the United States is approximately 6.2% of the GDP. In 2016, that cost exceeded \$1 trillion dollars for the first time. Download Now

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!