In the CATIA users can filter their parameters like UserParameters, Renamed Parameters, Visible Parameters and etc.
Like in the photo.
enter image description here
Here my code :
Products oInstances = oInstance.Products;
int numberOfInstance = oInstances.Count;
Product currentProduct;
KnowledgewareTypeLib.Parameter parameter;
int numberOfParameters;
HashSet<string> processedParts = new HashSet<string>();
Worksheet sheet1 = (Worksheet)workbook.Sheets[1];
int Kolon = 1;
int Satir = 1;
((Range)sheet1.Cells[Satir, Kolon + 1]).Value2 = "Parametre_Name";
((Range)sheet1.Cells[Satir, Kolon + 2]).Value2 = "Parametre_Value";
if (treeNode == null) { return; }
if (numberOfInstance == 0)
{
return;
}
else if (numberOfInstance > 0)
{
for (int i = 1; i <= numberOfInstance; i++)
{
currentProduct = oInstances.Item(i);
string partNumber = currentProduct.get_PartNumber();
if (processedParts.Contains(partNumber))
{
continue;
}
processedParts.Add(partNumber);
TreeNode iNode = new TreeNode() { Text = currentProduct.get_Name() };
treeNode.Nodes.Add(iNode);
numberOfParameters = currentProduct.Parameters.Count;
for (int j = 1; j <= numberOfParameters; j++)
{
parameter = currentProduct.Parameters.Item(j);
if(type == 1)
{
TreeNode jNode = new TreeNode() { Text = parameter.get_Name() + " = " + parameter.ValueAsString() };
Range partNameColumn = (Range)sheet1.Cells[Satir , Kolon];
partNameColumn.Value2 = parameter.get_Name();
Range partValueColumn = (Range)sheet1.Cells[Satir, Kolon + 1];
partValueColumn.Value2 = parameter.ValueAsString();
Satir++;
iNode.Nodes.Add(jNode);
}
else if(type == 2)
{
if (parameterList.Contains(parameter.get_Name().Split('\').Last()))
{
TreeNode jNode = new TreeNode() { Text = parameter.get_Name() + " = " + parameter.ValueAsString() };
Range partNameColumn = (Range)sheet1.Cells[Satir, Kolon ];
partNameColumn.Value2 = parameter.get_Name();
Range partValueColumn = (Range)sheet1.Cells[Satir, Kolon + 1];
partValueColumn.Value2 = parameter.ValueAsString();
Satir++;
iNode.Nodes.Add(jNode);
}
}
else if(type == 3)
{
return;
}
}
GetParameters(oInstances.Item(i), iNode, workbook, type);
}
return;
}
}
How can i filter this parameters in code. I cant find clear document about it.
I try to check parameter.type() but all parameters type __ComObject and no diffrance in naming.
1
Have a look at this:
Option Explicit
Sub CATMain()
Dim oDocument As Document 'Document Anchor
Dim oPart As Part 'Part Anchor
Dim aParam As Parameters 'Collection of all parameters
Dim Param As Parameter 'Current parameter
Dim Index As Integer 'index
Set oDocument = CATIA.ActiveDocument 'Anchor document
Set oPart = oDocument.Part 'Anchor part
Set aParam = oPart.Parameters 'Get parameters
For Index = 1 To aParam.count 'Loop for all parameters
Set Param = aParam.Item(Index) 'Get current Parameter
Debug.Print Param.Name 'Name/Path of Param
Debug.Print TypeName(Param) 'Prints the parameter type to Intermediate window
Debug.Print "Renamed: " & Param.Renamed 'True if varible was renamed, otherwise false
Debug.Print TypeName(Param.Context) 'Prints where the parameter is located. part, product, drawing
Debug.Print "Hidden: " & Param.Hidden 'True if hidden, outerwise false
Debug.Print "True Par: " & Param.IsTrueParameter 'True if Real, dimetion, or string; False if isolated point, curve or surface
Debug.Print "Read only: " & Param.ReadOnly 'True if read only
Select Case Param.UserAccessMode 'Get acess mode
Case 0 'Read Only
Debug.Print "Read only parameter (cannot be destroyed)."
Case 1 'Read/Write
Debug.Print "Read/write parameter (cannot be destroyed)."
Case 2 'User Parameter
Debug.Print "User parameter (can be read, written and destroyed)."
Case Else
Debug.Print "Error getting User acess mode"
End Select
Debug.Print vbNewLine
Next
End Sub
'---------------------------------------
'
' I ran this on a random part.
' Results for types:
'
' Parameter
' RealParam
' StrParam
' Length
' ListParameter
' IntParam
That are most of the important things that you can get for parameters. Just be carful running the code as it will take a while if there are a lot of parameters, its only supposed to be fore testing.
All the information that you need can be found in:
C:Program FilesDassault SystemesB32win_b64codebinV5Automation.chm
Just search for “KnowledgeInterfaces Parameter (Object)”