Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'vba
Option Explicit
Sub CATMain()
Dim selMsg As String
selMsg = "select dimension"
Dim constraint_obj As constraint
Dim resultMsg As String
Do
' Select Constraint
Set constraint_obj = SelectItem(selMsg, Array("Constraint"))
If constraint_obj Is Nothing Then Exit Do
If isReferenced_HorV(constraint_obj) Then
resultMsg = "Yes"
Else
resultMsg = "No"
End If
MsgBox "referenced from H or V : " & resultMsg
Loop
End Sub
Private Function isReferenced_HorV( _
ByVal con As constraint) As Boolean
Dim i As Long, ref As Reference
Dim parenAxis2DCount As Long
parenAxis2DCount = 0
For i = 1 To 3
On Error Resume Next
Set ref = con.GetConstraintElement(i)
On Error GoTo 0
If ref Is Nothing Then GoTo continue
If typename(ref.Parent.Parent) = "Axis2D" Then
parenAxis2DCount = parenAxis2DCount + 1
End If
continue:
Next
isReferenced_HorV = IIf(parenAxis2DCount = 1, True, False)
End Function
Private Function SelectItem( _
ByVal msg$, _
ByVal filter As Variant) _
As AnyObject
Dim sel As Variant
Set sel = CATIA.ActiveDocument.selection
sel.Clear
Select Case sel.SelectElement2(filter, msg, False)
Case "Cancel", "Undo", "Redo"
Exit Function
End Select
Set SelectItem = sel.Item(1).Value
sel.Clear
End Function