'*********************************************************************************************************** Public oRoot, oSelection, iMsg '*********************************************************************************************************** Sub CATMain() Set oRoot = Catia.ActiveDocument If TypeName(oRoot) <> "ProductDocument" Then MsgBox "Das Root muss ein CATProduct sein." & vbLf & "Das Makro wird abgebrochen!", 48, "Anwenderfehler" Exit Sub End If iMsg = MsgBox( "Alle Bgr-Constraints löschen und alle Parts/Products fixieren (JA)" & VbLf & "oder nur alle Bgr-Constraints löschen (NEIN)",4, "Was möchten Sie tun?") Set oProduct = oRoot.Product Set oProducts = oProduct.Products Set oSelection = Catia.ActiveDocument.Selection SUB_ProdScan oProducts, False End Sub '*********************************************************************************************************** Sub SUB_ProdScan(oProducts, bIsAComponent) If bIsAComponent = False Then Set oConnections = Catia.Documents.Item(oProducts.Parent.ReferenceProduct.Parent.Name).Product.Connections("CATIAConstraints") ElseIf bIsAComponent = True Then Set oConnections = oProducts.Parent.Connections("CATIAConstraints") End If iConnectionsCount = oConnections.Count oSelection.Clear For a = 1 To iConnectionsCount oSelection.Add (oConnections.Item(a)) Next If oSelection.Count > 0 Then oSelection.Delete End If oSelection.Clear For x = 1 To oProducts.Count If bIsAComponent = False Then 'it s a Product Set oProductOpen = Catia.Documents.Item(oProducts.Parent.PartNumber & ".CATProduct").Product If iMsg = 6 Then '-----------Fixieren Set oReference = oProductOpen.CreateReferenceFromName(oProductOpen.PartNumber & "/" & oProductOpen.Products.Item(x).Name & "/!" & oProductOpen.PartNumber & "/" & oProductOpen.Products.Item(x).Name & "/") Set oConstraint = oProductOpen.Connections("CATIAConstraints").AddMonoEltCst(catCstTypeReference, oReference) End if ElseIf bIsAComponent = True Then 'it s a Component If iMsg = 6 Then Set oReference = oProducts.Parent.CreateReferenceFromName(oProducts.Parent.PartNumber & "/" & oProducts.Parent.Products.Item(x).Name & "/!" & oProducts.Parent.PartNumber & "/" & oProducts.Parent.Products.Item(x).Name & "/") Set oConstraint = oProducts.Parent.Connections("CATIAConstraints").AddMonoEltCst(catCstTypeReference, oReference) End if End If If TypeName(oProducts.Item(x).ReferenceProduct.Parent) = "PartDocument" Then 'Check ob PartDoc ' passiert gar nix ElseIf TypeName(oProducts.Item(x).ReferenceProduct.Parent) = "ProductDocument" Then Err.Number = 0 On Error Resume Next Set oMasterShape = oProducts.Item(x).GetMasterShapeRepresentation(True) If Err.Number = 0 Then 'it s a V4 or something else ' passiert gar nix ElseIf oProducts.Item(x).ReferenceProduct.Parent.Name = oProducts.Item(x).Parent.Parent.ReferenceProduct.Parent.Name Then '---its a Component On Error GoTo 0 SUB_ProdScan Catia.Documents.Item(oProducts.Item(x).ReferenceProduct.Parent.Name).GetItem(oProducts.Item(x).PartNumber).Products, True ElseIf oProducts.Item(x).ReferenceProduct.Parent.Name <> oProducts.Item(x).Parent.Parent.ReferenceProduct.Parent.Name Then '---its a Product On Error GoTo 0 If oProducts.Item(x).Products.Count > 0 Then Set oProductsUebergabe = oProducts.Item(x).Products SUB_ProdScan oProductsUebergabe, False End If End If On Error GoTo 0 End If Next End Sub