Creating parameters and formulas in CAA RADE

To create and view parameters and formulas you will need the CATICkeParmFactory, CATIParmPublisher and CATICkeFunctionFactory. The CATICkeParmFactory lets you create parameters and formulas. The CATIParmPublisher is used in viewing the paramters in the tree. The CATICkeFunctionFactory allows you to add parameters to the parameter set and formulas to the relation set (putting them in the tree).

The following code sets up the CATICkeParmFactory, CATIParmPublisher and CATICkeFunctionFactory:

CATICkeParmFactory_var spParmFactory = NULL_var;
spParmFactory = pSpecContainer;
	
CATIParmPublisher_var  spParmPublisher = NULL_var;
spParmPublisher = pSpecContainer;

CATICkeFunctionFactory_var spFuncFactory = NULL_var;
spFuncFactory = CATCkeGlobalFunctions::GetFunctionFactory();

Note that pSpecContainer is a CATIContainer that is instantiated from the GetSpecContainer function of the CATIContainerOfDocument. The CATIParmPublisher and CATICkeFunctionFactory both inherit from the pSpecContainer and the CATICkeFunctionFactory is retrieved from the call CATCkeGlobalFunctions::GetFunctionFactory().


The next piece of code sets up three length parameters. These parameters are then added to the parameter set using by the CATICkeFunctionFactory:

CATICkeParm_var spParam1 = spParmFactory->CreateLength("Base",.1);
CATICkeParm_var spParam2 = spParmFactory->CreateLength("Width",.15);
CATICkeParm_var spParam3 = spParmFactory->CreateLength("Height",.2);

spFuncFactory->AddToCurrentParameterSet(spParam1, spParmPublisher);
spFuncFactory->AddToCurrentParameterSet(spParam2, spParmPublisher);
spFuncFactory->AddToCurrentParameterSet(spParam3, spParmPublisher);

Note that in the call CreateLength, the first parameter is the name name of your parameter and the second is the value of the parameter in meters.


The next piece of code creates a formula. You first need to set up a list of what parameters you will use in the formula, and then create it. The line adds the formula to the relation set:

CATCkeListOfParm pList = new CATCkeListOf(Parm);
pList->Append (spParam1);  
pList->Append (spParam2); 
pList->Append (spParam3); 

CATICkeRelation_var spFormula1 = spParmFactory->CreateFormula("Formula", "", "", spParam3, pList, "Width+Base",  spParmPublisher, CATCke::True); 

spFuncFactory->AddToCurrentRelationSet(spFormula1, spParmPublisher);

The formula will read: Height = Width + Base.

Note: You can change the value of a parameter programmatically by calling "Valuate" as shown below:

spParam1->Valuate(.5);