<CATIA V5 BBS TIPS & USAGE TOP_PAGE > 記事閲覧
ProductツリーをEXCELに
日時: 2007/03/27 12:45
名前: emily

EXCELのSheet1のマクロとして、次のVBAを作っておきます。CATIAのアセンブリを立ち上げておき、次のVBAを実行したら仕様ツリーがセルにリストアップされます。
Partの下のボディと(あれば更に1つ下のレベルのボディまでが)取り出せます。
Dim now_row

Sub test_V5tree() 'Sheet1 macro. Main entry here.

MsgBox " macro now running.."
now_row = 2

Set CATIA = GetObject(, "CATIA.Application")
Set topprod1 = CATIA.ActiveDocument.Product
Call s_prod(topprod1, 1)
Set CATIA = Nothing
End Sub

Sub s_prod(prod1, ByVal depth1)
Cells(now_row, depth1) = prod1.PartNumber & ": " & prod1.Name
now_row = now_row + 1

If TypeName(prod1.ReferenceProduct.Parent) = "PartDocument" Then
Call s_part(prod1.ReferenceProduct.Parent.Part, depth1 + 1)
Else

For Each prod2 In prod1.products
Call s_prod(prod2, depth1 + 1)
Next

End If
End Sub

Sub s_part(part1, ByVal depth1)
For Each body1 In part1.bodies
If False = body1.InBooleanOperation Then
Cells(now_row, depth1) = body1.Name
now_row = now_row + 1
On Error GoTo thr2

For Each shp1 In body1.Shapes
Cells(now_row, depth1 + 1) = shp1.Name
now_row = now_row + 1
Cells(now_row, depth1 + 2) = shp1.body.Name
now_row = now_row + 1
Next

On Error GoTo 0
End If
thr2:
Next

'形状セットをListする
For Each hbdy1 In part1.HybridBodies
Cells(now_row, depth1) = hbdy1.Name
now_row = now_row + 1
Next

End Sub

メンテ(修正・削除)

Page: 1 |

題名 スレッドをトップへソート
名前  
E-Mail   ※URLとの併記不可
URL   ※Eメールとの併記不可
パスワード 記事メンテ時に使用(英数字で8文字以内)
投稿キー (投稿時 投稿キー を入力してください)
コメント
添付データ 添付可能ファイル GIF, JPEG, PNG, LHA, ZIP 最大投稿データ量 1000 KB (1.0 MB)
データ1
データ2

   クッキー保存