1

現在 CATIA V5 で作業しており、マクロ (VBA) を使用したいのですが、いくつか問題があります。

私の質問は: カット ビューのテキストを変更する方法は? (写真を参照)

ここに画像の説明を入力

この「テキスト」にアクセスするために myView.Texts.item(1) を使用しようとしましたが、CATIA はそれをテキストと見なさないと思います...

ユーザーの介入なしに (選択なしで) このテキストを変更したいのですが、変更できますか?

4

3 に答える 3

1

Drafting Workbench での IME、VBA スクリプト作成は、最初はかなりトリッキーです... "MyTexts" は DrawingText オブジェクトのコレクションです。

MyDrawingText.Text = "MyNewTextValue"

主な問題は、変更したい特定のテキスト オブジェクトのハンドルを取得することです。これを回避する最善の方法は、DrawingView 内の DrawingTexts コレクション全体をスキャンして一意の名前を適用するDrawingText.Name="UniqueObjectName"か、スクリプトから描画テキストを作成し、DrawingText オブジェクトのハンドルをより簡単に取得して配置することであることがわかりました。あなたがそこに望むどんな値でも。一意の名前を作成すると、将来のスクリプト作成のために図面がより堅牢になります

MyView.Texts.Count最後に作成された DrawingText オブジェクトの場合、アイテム番号を取得するのにも役立ちます。

必要に応じてさらに説明していただければ幸いです。幸運を!

更新/編集: 前述のように、ドラフティング ワークベンチを使用したスクリプト作成は必ずしも簡単ではありません。吹き出しテキストは のDrawingTextsコレクションに正確に存在するわけではありませDrawingViewんが、図面ビュー内のどこかに存在することがわかりました...この場合、断面図の「ID」を編集しようとしています..プロパティも VBA を通じて公開されません。

親ビューでテキストの描画を検索し、いくつかのロジックを考え出す必要があるハック/回避策Selectionがあり、変更したいテキストをスキャンします。名前を変更している間に名前を変更する必要があります。これにより、元に戻って再度見つけやすくなります。

以下は、正面図 (断面図の親ビュー) のオブジェクト解像度から始まる例です。

Sub ChangeCallout()

'---- Begin resolution script for object : Front View

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")

Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views

Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.Item("Front view") 'this is the parent view of the section view

'---- End resolution script

Dim sel As Selection
Set sel = drawingDocument1.Selection
Dim CalloutText As drawingText

sel.Clear 'clear the selection / good practice
sel.Add drawingView1 'add the parent view to the selection
sel.Search "Drafting.Text,sel" 'this will search the current selection for all drawing texts and add them to the selection

Dim thing As Variant
Dim i As Integer
For i = 1 To sel.Count
    Set thing = sel.Item2(i)
    Set CalloutText = thing.Value
    'do some things/logic here to determine if this is a callout with some Ifs or Case statements
    'CalloutText.Name = "Useful Unique Name"
    'CalloutText.Text = "New Callout Label" 'whatever you want to rename it to
Next

End Sub
于 2014-04-08T14:50:36.033 に答える
1

切り取りビューのテキストはビュー名によって定義されます。これを変更するには、次のようにビュー名を変更する必要があります。

Sub CATMain()

    Dim oDraw As DrawingDocument
    Set oDraw = CATIA.ActiveDocument

    Dim oSectionView As DrawingView
    Set oSectionView = oDraw.Sheets.ActiveSheet.Views.ActiveView

    oSectionView.SetViewName "Prefix ", "B", " Suffix"

End Sub
于 2015-01-09T16:50:02.300 に答える