0

I'm trying to write code which can measure geometry coordinates in Catia active document, probably in CATProduct?! this is my code and the result is nothing. MsgBox doesn't show anything.

Sub CatMain()
Dim varFilter(1) As Variant
Dim objSel As Selection
Dim objSelLB As Object   ' <--- notice declared as object
Dim strReturn As String
Dim strMsg As String

    varFilter(0) = "Body"            'Body represents a solid body
    varFilter(1) = "HybridBody"      'HybridBody represents a geometrical set
Set objSel = CATIA.ActiveDocument.Selection
Set objSelLB = objSel
strMsg = "Select a body or geometrical set…"
objSel.Clear
strReturn = objSelLB.SelectElement2(varFilter, strMsg, False)
If strReturn = "Normal" Then
If objSel.Count2 > 0 Then
Set bb = objSel.Item(1).Value
Set cc = bb.HybridShapes
For s = 1 To cc.Count
 
Set cc = cc.Item(s)
  
        cc.GetCoordinates arrXYZ
MsgBox ((cc.Parent.Name) & Separator & (cc.Name) & Separator & _
                              arrXYZ(0) & Separator & _
                              arrXYZ(1) & Separator & _
                              arrXYZ(2) & vbLf)
 Next s
End If
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
Salome
  • 1
  • 2
  • From what element do you want to get Coordinates? – Shrotter Oct 22 '22 at 18:09
  • in this example, I choose a rectangular prism. this is the selected object for me. – Salome Oct 22 '22 at 18:23
  • In your example you can only select bodies and hybridbodies. Be aware you use the variable _cc_ for two different objects. _GetCoordinates_ is only working on points. Please check the _Measurable_ object for measuring area, volume, cog, ... – Shrotter Oct 22 '22 at 18:27

0 Answers0