Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

distance

Status
Not open for further replies.

mayrou

Electrical
Jan 8, 2014
55
Hello world


i have an issue, hope you can help me with this

in a CATIAProduct, i want to create a macro that gets the minimal distance between a point and a part!
How can I do that!
thx you
 
Replies continue below

Recommended for you

I created this macro! that measure distance between a point in part1 and a plane in part2!
but it give a wrong distance compared to the manual one!

Code:
Sub CATMain()

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As Document
Set partDocument1 = documents1.Item("part.CATPart")

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
'****
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Construction")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapePointCenter1 As HybridShape
Set hybridShapePointCenter1 = hybridShapes1.Item("Point.1")
'******

Dim partDocument2 As Document
Set partDocument2 = documents1.Item("part2.CATPart")

Dim part2 As Part
Set part2 = partDocument2.Part

Dim originelements1 As OriginElements
Set originelements1 = part2.OriginElements

Dim reference1 As Reference
Set reference1 = originelements1.PlaneXY

part1.Update

Dim TheSPAWorkbench As SPAWorkbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")

Dim Measurable1 As Measurable
Set Measurable1 = TheSPAWorkbench.GetMeasurable(hybridShapePointCenter1)
Dim Measurable2 As Measurable
Set Measurable2 = TheSPAWorkbench.GetMeasurable(reference1)

Dim distance As Variant
distance = Measurable2.GetMinimumDistance(hybridShapePointCenter1)
MsgBox "distance " & distance & " "

End Sub

so where the issue is???
thx :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor