TiagoFigueiredo
Industrial
I everyone,
Once again i need some help in a macro to measure the lenght of some lines.
I have found a macro that almost suits what i need, is located in the following thread:
I was trying to reply in the thread, but i don't know why, it wasn't allowed.
My problem is the following. Using the macro located in that thread, i have writed this macro:
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Coordenadas")
Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes
Dim hybridShapePolyline1 As HybridShapePolyline
Set hybridShapePolyline1 = hybridShapes1.Item(6)
Dim hybridShapePolyline2 As HybridShapePolyline
Set hybridShapePolyline2 = hybridShapes1.Item(7)
'---- End resolution script
Dim referenceObject1 As Reference
Set referenceObject1= hybridShapePolyline1
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Dim TheMeasurable1 As Measurable
Set TheMeasurable1 = TheSPAWorkbench.GetMeasurable(referenceObject1)
Dim referenceObject2 As Reference
Set referenceObject2= hybridShapePolyline2
Dim TheMeasurable2 As Measurable
Set TheMeasurable2 = TheSPAWorkbench.GetMeasurable(referenceObject2)
MsgBox TheMeasurable1.Length
MsgBox TheMeasurable2.Length
TheMeasurable1.Clear
End Sub
The macro works, but it's strange how it works. The first time that i use it (when I start computer), it works, but the second time doesn't, and in some times it works. i have no way to explain this.
When the macro doesn't work it makes a error on the follwing line:
MsgBox TheMeasurable2.Length
Can you try to help me?
The CATIA is in attachment.
Best regards
Once again i need some help in a macro to measure the lenght of some lines.
I have found a macro that almost suits what i need, is located in the following thread:
I was trying to reply in the thread, but i don't know why, it wasn't allowed.
My problem is the following. Using the macro located in that thread, i have writed this macro:
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Coordenadas")
Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes
Dim hybridShapePolyline1 As HybridShapePolyline
Set hybridShapePolyline1 = hybridShapes1.Item(6)
Dim hybridShapePolyline2 As HybridShapePolyline
Set hybridShapePolyline2 = hybridShapes1.Item(7)
'---- End resolution script
Dim referenceObject1 As Reference
Set referenceObject1= hybridShapePolyline1
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Dim TheMeasurable1 As Measurable
Set TheMeasurable1 = TheSPAWorkbench.GetMeasurable(referenceObject1)
Dim referenceObject2 As Reference
Set referenceObject2= hybridShapePolyline2
Dim TheMeasurable2 As Measurable
Set TheMeasurable2 = TheSPAWorkbench.GetMeasurable(referenceObject2)
MsgBox TheMeasurable1.Length
MsgBox TheMeasurable2.Length
TheMeasurable1.Clear
End Sub
The macro works, but it's strange how it works. The first time that i use it (when I start computer), it works, but the second time doesn't, and in some times it works. i have no way to explain this.
When the macro doesn't work it makes a error on the follwing line:
MsgBox TheMeasurable2.Length
Can you try to help me?
The CATIA is in attachment.
Best regards