|
applyMaterials includes three steps:
- Open the CATMaterial document and retrieve
materials
- Open a CATProduct document and
apply/retrieve a material
- Open a CATPart document and apply/retrieve a
material on the Part and the PartBody
Open the material library and retrieve 3
existing materials
'
' -----------------------------------------------------------
' Open the material library (.CATMaterial file)
' -----------------------------------------------------------
'
Dim sFilePath
sFilePath = CATIA.FileSystem.ConcatenatePaths(sDocPath, _
"\online\CAAScdMatUseCases\samples\MyCatalog.CATMaterial")
Dim oMaterial_document As Document
Set oMaterial_document = CATIA.Documents.Open(sFilePath)
Set oMaterial_document = CATIA.ActiveDocument
'
' -----------------------------------------------------------
' Read materials in this catalog (which contains 3 families and 5 materials in each family)
' First retrieve the families of the library
' -----------------------------------------------------------
'
Dim cFamilies_list As MaterialFamilies
Set cFamilies_list = oMaterial_document.Families
Dim iNb_families As Integer
iNb_families = cFamilies_list.Count
Dim sFamiliesName As String
sFamiliesName = cFamilies_list.Name
'
' -----------------------------------------------------------
' Retrieve the first family of the library
' -----------------------------------------------------------
'
Dim oFirst_family As MaterialFamily
Dim ifamily_no As Integer
ifamily_no = 1
Set oFirst_family = cFamilies_list.Item(iFamily_no)
Dim sFamilyName As String
sFamilyName = oFirst_family.Name
'
' -----------------------------------------------------------
' Retrieve the material number 1,2 and 3 of the family
' -----------------------------------------------------------
'
Dim cMaterials_list As Materials
Set cMaterials_list = oFirst_family.Materials
Dim iNb_materials As Integer
iNb_materials = cMaterials_list.Count
Dim imaterial_no As Integer
imaterial_no = 1
Dim oMaterial1 As Material
Set oMaterial1 = cMaterials_list.Item(imaterial_no)
imaterial_no = 2
Dim oMaterial2 As Material
Set oMaterial2 = cMaterials_list.Item(imaterial_no)
imaterial_no = 3
Dim oMaterial3 As Material
Set oMaterial3 = cMaterials_list.Item(imaterial_no)
...
|
[Top]
Open a CATProduct document. Apply a
material on the root product and retrieve it
...
'
' -----------------------------------------------------------
' Read product file
' -----------------------------------------------------------
'
Dim oProductDocument As Document
sFilePath = CATIA.FileSystem.ConcatenatePaths(sDocPath, _
"\online\CAAScdMatUseCases\samples\Product1.CATProduct")
Set oProductDocument = CATIA.Documents.Open(sFilePath)
Set oProductDocument = CATIA.ActiveDocument
'
' -----------------------------------------------------------
' Access on material manager on root product document
' -----------------------------------------------------------
'
Dim oRootProduct As Product
Set oRootProduct = oProductDocument.Product
Dim oManager As MaterialManager
Set oManager = oRootProduct.GetItem("CATMatManagerVBExt")
'
' -----------------------------------------------------------
' Apply the material on the Product (as a link)
' -----------------------------------------------------------
'
Dim linkMode As Integer
linkMode = 1
oManager.ApplyMaterialOnProduct oRootProduct,oMaterial1,linkMode
'
' -----------------------------------------------------------
' Retrieve the material applied on the Product
' -----------------------------------------------------------
'
Dim oAppliedMaterial As Material
oManager.GetMaterialOnProduct oRootProduct,oAppliedMaterial
oProductDocument.Close
...
|
[Top]
Open a CATPart document. Apply a material
on the part and its partbody and retrieve them
...
'
' -----------------------------------------------------------
' Open the Part document
' -----------------------------------------------------------
'
sFilePath = CATIA.FileSystem.ConcatenatePaths(sDocPath, _
"\online\CAAScdMatUseCases\samples\Part1.CATPart")
Dim oPartDocument As Document
Set oPartDocument = CATIA.Documents.Open(sFilePath)
Set oPartDocument = CATIA.ActiveDocument
'
' -----------------------------------------------------------
' Access on material manager on root part document
' -----------------------------------------------------------
'
Dim oRootPart As Part
Set oRootPart = oPartDocument.Part
' Retrieve the extension object associated to Y under the key "MyCATIVBExtensionImpl"
Set oManager = oRootPart.GetItem("CATMatManagerVBExt")
'
' -----------------------------------------------------------
' Apply the material on the Part
' -----------------------------------------------------------
'
linkMode = 0
oManager.ApplyMaterialOnPart oRootPart,oMaterial2,linkMode
'
' -----------------------------------------------------------
' Retrieve the material on the Part
' -----------------------------------------------------------
'
oManager.GetMaterialOnPart oRootPart,oAppliedMaterial
'
' -----------------------------------------------------------
' Retrieve the Part Body
' -----------------------------------------------------------
'
Dim oMainBody As Body
Set oMainBody = oRootPart.MainBody
'
' -----------------------------------------------------------
' Apply the material on the Part Body (as a link)
' -----------------------------------------------------------
'
linkMode = 1
oManager.ApplyMaterialOnBody oMainBody,oMaterial3,linkMode
'
' -----------------------------------------------------------
' Retrieve the material on the Part Body
' -----------------------------------------------------------
'
oManager.GetMaterialOnBody oMainBody,oAppliedMaterial
...
|
[Top]
|