↑タイトル詐欺 主にCATIA V5 の VBA




Dim PartDoc As PartDocument
Dim oPart As Part
Dim HBody As HybridBody
Sub CATMain()
    Set PartDoc = CATIA.ActiveDocument
    Set oPart = PartDoc.Part
    Dim oSel 'As Selection
    Set oSel = PartDoc.Selection
    Dim FilterType(0)  As Variant
    FilterType(0) = "Edge"
    Dim Ref As Reference
    With oSel
        If .SelectElement2(FilterType, "Select", fulse) = "Cancel" Then End
        Set Ref = oPart.CreateReferenceFromBRepName( _
                    GetBrepName(.Item(1).Value.Name), .Item(1).Value.Parent)
    End With
    Set HBody = oPart.HybridBodies.Add()
    Call SweepCircle(Ref)
End Sub

Private Sub SweepCircle(Ref As Reference)

    Dim hybridShapeFactory1 As HybridShapeFactory
    Set hybridShapeFactory1 = oPart.HybridShapeFactory
    Dim hybridShapeSweepCircle1 As HybridShapeSweepCircle
    Set hybridShapeSweepCircle1 = hybridShapeFactory1.AddNewSweepCircle(Ref)
    With hybridShapeSweepCircle1
        .Mode = 6
        .SmoothActivity = False
        .GuideDeviationActivity = False
        .SetRadius 1, 2#
        .SetbackValue = 0.02
        .FillTwistedAreas = 1
        .C0VerticesMode = True
    End With
    HBody.AppendHybridShape hybridShapeSweepCircle1
End Sub

Private Function GetBrepName(MyBRepName As String) As String
    MyBRepName = Replace(MyBRepName, "Selection_", "")
    MyBRepName = Left(MyBRepName, InStrRev(MyBRepName, "));"))
    MyBRepName = MyBRepName + ");WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)"
    GetBrepName = MyBRepName
End Function