Yes, this is fairly simple. First you have to find the correct part. You can do this with a User Selection or by searching for a string or many other ways. Once you have the ComponentOccurrence of the part you want, you can access the PartComponentDefinition and that has the user parameters in it. I have written a couple of extensions to retrieve user parameters from a PartComponentDefinition, you can use these or adapt them to not be extensions.
public static T RetrieveParameter<T>(this PartComponentDefinition definition, string name)
{
var parameters = definition.Parameters.UserParameters;
try
{
var value = parameters[name].Value;
return (T)Convert.ChangeType(value, typeof(T));
}
catch (Exception e)
{
return default(T);
}
}
public static void SetParameter(this PartComponentDefinition definition, string parameter, dynamic value)
{
var parameters = definition.Parameters.UserParameters;
try
{
parameters[parameter].Value = value;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}