×
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

distance

distance

distance

(OP)
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

RE: distance

(OP)
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 --> vbs

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 :)

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