Add a unitless user parameter into an assembly |
Top Previous Next |
Here's a function to do that:
// Adds a unitless user parameter and its value into an assembly... void AddUserUlParamToAssembly(CComPtr<AssemblyComponentDefinition>& pAssemblyCompDef, const CString& kcsParamName, const double kParamValue) { // Parameters contains two lists, Model and User... CComPtr<Parameters> pParameters ; pAssemblyCompDef->get_Parameters (&pParameters) ;
// Get the model parameters list... CComPtr<UserParameters> pUserParameters ; pParameters->get_UserParameters (&pUserParameters) ;
CComVariant varValue(kParamValue); CComVariant varUnits(L"ul"); CComBSTR bstrVarName(kcsParamName);
HRESULT hRes = pUserParameters->AddByValue(bstrVarName, varValue, varUnits); if (FAILED(hRes)) { TRACE (L"Could not add user parameter <%s> to assembly", kcsParamName); } }
It seems like you cannot specify int or double, all parameters are doubles.
|
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)