C#ATIA

↑タイトル詐欺 主にFusion360API 偶にCATIA V5 VBA(絶賛ネタ切れ中)

線幅の変更を行う

こちらでご質問頂いた件のサンプルです。
Drawingのラインの端点座標を取得 - C#ATIA

最初に線幅を入力する為のダイアログが出ますので、
1~63までの数値を入力。
その後、線をドンドン指定してください。
途中、線幅を変更したい場合には、一度ESCキーを押すことで
再度、線幅のダイアログが出現します。
又、途中で終了したい際には、ESCキーを2回入力することで
終了します。

'vba 線幅変更
Sub CatMain()
    'セレクション取得
    Dim Sel 'As Selection
    Set Sel = CATIA.ActiveDocument.Selection
    
    '線幅変更
    Dim WidthTxt As String
    Dim Width As Long
    Dim InputObjectType(0) As Variant
    InputObjectType(0) = "Edge"
    Do
        '線幅指定 - ESCキーで終了
        WidthTxt = InputBox("線幅を入力して下さい(1-63)")
        If Not IsNumeric(WidthTxt) Then Exit Do
        Width = CLng(WidthTxt)
        If Not (Width >= 1 And Width <= 63) Then Exit Do
        Do
        '線の選択 - ESCキーで線幅指定に戻る
            With Sel
                .Clear
                Result = .SelectElement2(InputObjectType, "線を選択して下さい", False)
                If Result = "Cancel" Then Exit Do
                .VisProperties.SetRealWidth Width, 1
                .Clear
            End With
        Loop
    Loop
End Sub