×
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

Macro measure distance between two points : wrong value

Macro measure distance between two points : wrong value

Macro measure distance between two points : wrong value

(OP)
Hi,

I've problems with my code. I want to measure with a macro the distance between two points. So I use GetMinimumDistance, and the function return me the value "0".

I don't understand because my 2 points aren't coincident at all.

This is my code:

Sub DistancePoint()

Dim TheSPAWorkbench As Workbench
Dim reference1 As Reference
Dim reference2 As Reference
Dim TheMeasurable As Measurable
Dim MinimumDistance As Double


Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
Set visPropertySet1 = selection1.VisProperties
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item(1)
Set hybridShapes1 = hybridBody1.HybridShapes


Set hybridShapePointCoord1 = hybridShapes1.Item(6)
Set hybridShapes1 = hybridShapePointCoord1.Parent

Set hybridShapePointCoord2 = hybridShapes1.Item(7)
Set hybridShapes2 = hybridShapePointCoord2.Parent

Set reference1 = part1.CreateReferenceFromObject(hybridShapes1)
Set reference2 = part1.CreateReferenceFromObject(hybridShapes2)


Set TheMeasurable = TheSPAWorkbench.GetMeasurable(reference1)
MinimumDistance = TheMeasurable.GetMinimumDistance(reference2)


MsgBox (MinimumDistance)


End Sub




Thank you. Bastien

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