こちらで教えて頂いた、Computeメソッド
UpdateとUpdateObject - C#ATIA
こちらで試した際は気が付かなかったのですが、
スピードテスト5 - C#ATIA
PartクラスのUpdateObjectメソッドは各HybridShapeクラスのComputeメソッドを
呼び出しているだけなのかな? と思っていたのですが、
ちょっと違うようなのでご紹介。
こちらの画像のようなデータで、交差コマンドを実行します。
手動であれば、もちろん失敗します。
そこで、こちらのコードを実行します。
'vba Test_Update_errer Sub CATMain() '準備 Dim Pt As Part: Set Pt = CATIA.ActiveDocument.Part Dim Fact As HybridShapeFactory: Set Fact = Pt.HybridShapeFactory Dim Hb As HybridBody: Set Hb = Pt.HybridBodies.Item(1) '二つの面のリファレンス Dim Ref1 As Reference: Set Ref1 = Pt.CreateReferenceFromGeometry(Hb.HybridShapes.Item(1)) Dim Ref2 As Reference: Set Ref2 = Pt.CreateReferenceFromGeometry(Hb.HybridShapes.Item(2)) '交差 未アップデート状態 Dim Intersect As HybridShapeIntersection Set Intersect = Fact.AddNewIntersection(Ref1, Ref2) Intersect.PointType = 0 '更新テスト Dim Msg$: Msg = "" On Error GoTo ExitUpdeteTest 'Compute Msg = "Computeでエラー" 'Hb.AppendHybridShape Intersect Call Intersect.Compute 'UpdateObject Msg = "UpdateObjectでエラー" Call Pt.UpdateObject(Intersect) On Error GoTo 0 Msg = "エラーなし" ExitUpdeteTest: MsgBox Msg End Sub
実行結果はこちら
Computeメソッドは、失敗していてもエラーを吐き出さないんです。
コメント化している部分を外し、形状セットに挿入後でも同様です。
確実に処理が成功しない場合は、ちょっと危険か香りがします。