I am replacing the parameter with code. This is the code I'm using. Although the parameter has changed and the line is relative to it, the profile does not extend relative to the line. I need to do the update process with code. If I do it manually, I can't achieve my goal.
My parameter change code.
public void ChangeParam(Document doc, string paramName, string paramValue)
{
UserParameters userParams;
if (doc.DocumentType == DocumentTypeEnum.kPartDocumentObject)
{
Console.WriteLine("Part Document");
PartComponentDefinition partComponentDef = ((PartDocument)doc).ComponentDefinition;
Parameters docParams = partComponentDef.Parameters;
userParams = docParams.UserParameters;
}
else if (doc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject)
{
Console.WriteLine("Assembly Document");
AssemblyComponentDefinition assemblyComponentDef = ((AssemblyDocument)doc).ComponentDefinition;
Parameters docParams = assemblyComponentDef.Parameters;
userParams = docParams.UserParameters;
}
else
{
Console.WriteLine("Unknown Document");
// unsupported doc type, throw excepstion
throw new Exception("Unsupported document type: " + doc.DocumentType.ToString());
}
try
{
Console.WriteLine($"Setting {paramName} to {paramValue}");
UserParameter modelParam = userParams[paramName];
modelParam.Expression = paramValue;
doc.Update();
}
catch (Exception e)
{
Console.WriteLine("Cannot update '{0}' parameter. ({1})", paramName, e.Message);
}
}