Continue to Site

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!

Macro measure distance between two points : wrong value

Status
Not open for further replies.

bastiensegond

Aerospace
Jul 5, 2011
21
FR
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
 
Replies continue below

Recommended for you

Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top