Sub GetRootAppliedMaterial() On Error GoTo LineOfError01GetCoveringAndCoreMaterial Dim MatService As MATPLMService 'Covering And Core Material Dim MyCoveringMatRef As Material Dim MyCoreMatRef As Material Dim myLinkOnRootOcc As AnyObject ' - Retrieves the Material Service Set MatService = CATIA.GetSessionService("MATPLMService") ' - Retrieves the Product Service Dim MyProductService As PLMProductService Set MyProductService = CATIA.GetSessionService("PLMProductService") ' - Retrieves the Root Occurrence Dim MyVPMRootOcc As VPMRootOccurrence Set MyVPMRootOcc = MyProductService.RootOccurrence ' - Compose link Set myLinkOnRootOcc = MyProductService.ComposeLink(MyVPMRootOcc, Nothing, Nothing) ' - Applied Material for Core Material Dim MyCoreAppliedMat As AppliedMaterial ' - Materials and Applied Material for Covering Material Dim MyCoveringMatRefList As ListObject Dim MyCoveringAppliedMatList As AppliedMaterials ' - Retrieve Applied Material on Root Occurrence Dim bError1 As Boolean bError1 = True MatService.GetMaterialCore myLinkOnRootOcc, MyCoreMatRef, MyCoreAppliedMat Dim material_V_Name As String material_V_Name = MyCoreMatRef.GetAttributeValue("V_Name") 'MsgBox material_V_Name g_RootAppliedMaterial_3DE = material_V_Name '<<<<<<< bError1 = False LineOfError01GetCoveringAndCoreMaterial: If bError1 = True Then 'MsgBox "GetRootAppliedMaterial failed!" g_RootAppliedMaterial_3DE = "" End If End Sub
3DE 获取材料(材质)的代码VBA
于 2023-10-05 22:19:51 首次发布