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 |
|
|