'---------------------------------------------------------------------------------------------------------------------------
'COPYRIGHT DASSAULT SYSTEMES 2009
'---------------------------------------------------------------------------------------------------------------------------
'Scanning the Root Parameter Set (3DExperience CATIA)
'
'Mission: This use case scans the hidden Boolean Parameters throughout a Parameter Set for a given 3DShape.
'
'Steps:
'
' 1. Creates 3DShape with a Parameter Set
' 2. Retrieves the Knowledge Service
' 3. Retrieves the Part Knowledge Collection
' 4. Retrieves the Created Parameter Set
' 5. Retrieves its Parameter Collection
' 6. Scans the Parameter list for the hidden Boolean Parameters
' 7. Displays the list of the hidden Boolean Parameters
'--------------------------------------------------------------------------------------------------------------------
Sub ScanningHiddenParameters()
'Error Handling
'On Error GoTo ErrorSub
'1 - Creates 3DShape with a Parameter Set with hidden/shown Parameters
Dim MyNewPart As Part
Create3DShape MyNewPart
'2 - Retrieves the Knowledge Service
Dim oKnowledgeServices As KnowledgeServices
Set oKnowledgeServices = CATIA.GetSessionService("KnowledgeServices")
'3 - Retrieves the Part Knowledge Collection
Dim oKnowledgeCollectionForPart As KnowledgeCollection
Set oKnowledgeCollectionForPart = oKnowledgeServices.GetKnowledgeCollection(MyNewPart, kweParametersType)
'4 - Retrieves the Created Parameter Set
Dim oParmsSetForMyParameterSet As ParmsSet
Set oParmsSetForMyParameterSet = oKnowledgeCollectionForPart.Item(1)
'5 - Retrieves its Parameter Collection
Dim oKnowledgeCollection As KnowledgeCollection
Set oKnowledgeCollection = oParmsSetForMyParameterSet.Collection
Dim oParamCollection As KnowledgeCollection
Set oParamCollection = oKnowledgeCollection.Find(kweParameterObjectType, True)
Dim oParamString0 As String
oParamString0 = " Name Value Comment"
Dim oParamString1 As String
oParamString1 = "Here is the list of hidden parameters of type Boolean are" & vbCrLf & oParamString0
'6 - Scans the Parameter list for the hidden Boolean Parameters
' Here we are scanning the hidden parameter list only for Boolean type of parameters.
' Tests whether the value returned by the hidden property of the Parameter is "True"
' Checks whether the type of the parameter belongs to "BoolParam" class object.
' Then increments the HiddenNumber variable.
Dim i As Integer
For i = 1 To oParamCollection.Count
Dim oParam As Parameter
Set oParam = oParamCollection.Item(i)
Dim HiddenNumber As Integer
If (oParam.Hidden) Then
If TypeName(oParam) = "BoolParam" Then
oParamString1 = oParamString1 & vbCrLf & oParam.Name & " " & oParam.Value & " " & "'" & oParam.Comment & "'": HiddenNumber = HiddenNumber + 1
End If
End If
Next
'7 - Displays the list of the hidden Boolean Parameters
If (HiddenNumber > 0) Then
MsgBox oParamString1
End If
GoTo EndSub
Error Handeling
ErrorSub:
MsgBox Str(Err.Number) + ":" + Err.Description
GoTo EndSub
EndSub:
End Sub
'--------------------------------------------------------------------------------------------------------------------
'Creates 3DShape with Parameters
'
'Steps:
'
' 1. Creates a 3DShape
' 2. Creates Part with Parameters
' 2.1 - Retrieves the part from the Active Editor
' 2.2 - Retrieves KnowledgeObjects Object from Part
' 2.3 - Creates Parameters Set
' 2.4 - Creates Parameters beneath the Parameters feature
' 2.5 - Creates another Parameter Set beneath the Parameter Set
' 2.6 - Adds Parameters below newly created sub Parameter Set
' 3. Updates Part
'--------------------------------------------------------------------------------------------------------------------
Sub Create3DShape(oPart)
'Error handling
'On Error GoTo ErrorSub
'1. Creates a 3DShape
'Creates a new 3DShape Rep Ref
Dim oNewService As PLMNewService
Set oNewService = CATIA.GetSessionService("PLMNewService")
Dim oEditor3DShape As Editor
oNewService.PLMCreate "3DShape", oEditor3DShape
'2. Creates Pad
'2.1 - Retrieves the part from the Active Editor
Set oPart = oEditor3DShape.ActiveObject
'2.2 - Retrieve KnowledgeObjects Object from Part
Dim oKnowledgeObjects As KnowledgeObjects
Set oKnowledgeObjects = oPart.GetItem("KnowledgeObjects")
'2.3 - Creates Parameters Set
Dim oParams As ParmsSet
Set oParams = oKnowledgeObjects.GetKnowledgeRootSet(True, kweParametersType)
'2.4 - Creates parameters beneath the Parameters feature
'Creates the parameters of type Boolean
Dim oParamString1 As Parameter
Set oParamString1 = oParams.Factory.CreateBoolean("TaskAsBoolean1", "True")
Dim oParamString2 As Parameter
Set oParamString2 = oParams.Factory.CreateBoolean("TaskAsBoolean2", "True")
oParamString2.Hidden = True
oParamString2.Comment = "HiddenParameter1"
Dim oParamString3 As Parameter
Set oParamString3 = oParams.Factory.CreateBoolean("TaskAsBoolean3", "False")
oParamString3.Hidden = True
oParamString3.Comment = "HiddenParameter2"
'Creates the parameters of type String
Dim oParamString4 As Parameter
Set oParamString4 = oParams.Factory.CreateString("TaskAsString1", "String1")
oParamString4.Hidden = True
oParamString4.Comment = "HiddenParameter3"
Dim oParamString5 As Parameter
Set oParamString5 = oParams.Factory.CreateString("TaskAsString2", "String2")
'Creates the parameter of type Integer
Dim oParamString6 As Parameter
Set oParamString6 = oParams.Factory.CreateInteger("TaskAsInteger1", 25)
oParamString6.Hidden = True
oParamString6.Comment = "HiddenParameter4"
'Creates another Parameter Set beneath the Parameter Set
Dim oSubParamSet As ParmsSet
Set oSubParamSet = oParams.Factory.CreateParametersSet("Sub-ParameterSet")
' Adds Parameters below newly created sub Parameter Set
'Creates the parameter of type Boolean
Dim oParamString7 As Parameter
Set oParamString7 = oSubParamSet.Factory.CreateBoolean("TaskAsBoolean4", "True")
oParamString7.Hidden = True
oParamString7.Comment = "HiddenParameter5"
'Creates the parameter of type Integer
Dim oParamString8 As Parameter
Set oParamString8 = oSubParamSet.Factory.CreateString("TaskAsInteger2", 50)
'3 - Updates Part
oPart.Update
GoTo EndSub
ErrorSub:
MsgBox Str(Err.Number) + ":" + Err.Description
GoTo EndSub
EndSub:
End Sub
3DExperience CATIA 扫描给定 3DShape 的整个参数集中隐藏的布尔参数
最新推荐文章于 2024-09-24 10:02:50 发布
该脚本主要用于在3DExperienceCATIA环境中扫描并显示参数集中隐藏的布尔参数。它首先创建一个带有参数集的3D形状,然后通过知识服务获取参数集,接着遍历参数列表,查找并显示隐藏的布尔类型参数。
摘要由CSDN通过智能技术生成