'*************************************
很长时间没有研究这个了
递归可以实现,有些重复输出,缺一些控制手段
'*************************************
Sub CATMain()
Set oDocuments = CATIA.Documents
Set oPartDoc = oDocuments.Add("art")
Set oPart = oPartDoc.GetItem("art1")
' oPart.PartNumber = "2A"
' oPart.Definition = " "
' oPart.Revision = " "
' oPart.Nomenclature = " "
' oPart.DescriptionRef = " "
Set oParam = oPart.UserRefProperties
Set strName = oParam.CreateString(" ", "")
strName.Value = ""
Set intAmount = oParam.CreateInteger(" ", 0)
intAmount.Value = 0
Set strMaterial = oParam.CreateString(" ", "")
strMaterial.Value = ""
Set strMatSTD = oParam.CreateString(" ", "")
strMatSTD.Value = ""
Set massWeight = oParam.CreateDimension(" ", "MASS", 0)
massWeight.Value = 0
Set lenthThick = oParam.CreateDimension(" ", "LENGTH", 0#)
lenthThick.ValuateFromString "0mm"
Set strTolerance = oParam.CreateString(" ", "")
strTolerance.Value = ""
Set strMirror = oParam.CreateString(" ", "")
strMirror.Value = ""
Set strType = oParam.CreateString(" ", "")
strType.Value = ""
Set StrBuy = oParam.CreateString(" ", "")
StrBuy.Value = ""
End Sub
--------------------------------------------------------------------
'**************************************************************************************************************
' '
'**************************************************************************************************************
Sub CATMain()
Dim oProductDoc As ProductDocument
Set oProductDoc = CATIA.ActiveDocument
Dim oRootProduct As Product
Set oRootProduct = oProductDoc.Product
Call asmRetrieve(oRootProduct)
MsgBox "Root_Last " + CStr(oRootProduct.Name)
End Sub
'-----------------------------------------------------------------
Function asmRetrieve(myRootProduct As Product)
Set myRootChildren = myRootProduct.Products
Dim nCount As Integer
nCount = myRootChildren.Count
If nCount > 0 Then
For i = 1 To nCount
Call asmRetrieve(myRootChildren.Item(i))
If myRootChildren.Item(i).Products.Count > 0 Then
' MsgBox "Root+++++" + CStr(myRootChildren.Item(i).Name)
MsgBox "Root+++++" + CStr(myRootChildren.Item(i).PartNumber)
End If
Next i
Else
' MsgBox "Leaf*****" + CStr(myRootProduct.Parameters.Item(1).Value)
For j = 1 To myRootProduct.Parameters.Count
MsgBox "Leaf*****" + CStr(myRootProduct.Parameters.Item(j).Value)
Next j
End If
End Function
|