Class Scene.FinishesConfig
Represents finishes config, which is in essence a set of available finish types and one assigned finish assigned to each of them.
Inherited Members
Namespace: KD.SDK2
Assembly: KD.SDK2.dll
Syntax
public class Scene.FinishesConfig : IEnumerable<Appli.CatalogFinish>, IEnumerable, IEquatable<Scene.FinishesConfig>
Remarks
This class operates on a finishes config string which can be obtained for example from FinishesConfigString property. Use ToString() method to convert finishes config back to its string representation.
Examples
The following example shows how to manipulate an object's finishes config using the Scene.FinishesConfig class.
public void SetFrontColourToWhiteIfAvailable(Scene.Object obj)
{
// This methods sets front colour of given object to white, if such
// an option is available.
// Let's parse object's finishes config string to access individual
// finishes and types.
var finishesConfig = new Scene.FinishesConfig(obj, obj.FinishesConfigString);
// Now let's find "Front colour" finish type.
Appli.CatalogFinishType frontColorFinishType;
if(!finishesConfig.TryGetFinishTypeByName("Front Colour",
out frontColorFinishType))
{
// This object doesn't utilize "Front colour" finish type.
return;
}
// Now let's find "white" finish in the finish type.
Appli.CatalogFinish whiteFrontColor;
if(!frontColorFinishType.TryGetFinishByName("white",
out whiteFrontColor))
{
// This object doesn't have "white" front color option.
return;
}
// Let's set white front colour to the finishes config.
finishesConfig[frontColorFinishType] = whiteFrontColor;
// And now let's assign the result back to the object to apply the
// result.
obj.FinishesConfigString = finishesConfig.ToString();
}
// This snippet tries to open the .scn file belonging to "@K2.cat" catalog to show the finishes
// Important note :
// If you want to get finishes chosen for the catalog images rendering, the trick is to set a scene filename to
// the name of the catalog and set finishes in Mobiscript first or by sdk
// So when generating images from catalog "@K2.cat", the SDK looks for "@K2.scn" to use first generic finsihes
// string catalogTrickSceneFilepath = System.IO.Path.ChangeExtension(catalogFilepath, ".scn");
// Firstly, let's find and open the scene
string catalogFilename = "@K2.cat";
string catalogFilepath = System.IO.Path.Combine(appli.CatalogsDir, catalogFilename);
string sceneFilepath = System.IO.Path.Combine(appli.ScenesDir, "5CE3A242_17616_01.scn");
if (!System.IO.File.Exists(sceneFilepath))
{
Console.WriteLine("The scene file doesn't exist. The finishes weren't configured in Catalog. Go to Catalog | Thumbnails | Generic finsihes.");
return;
}
scene.Load(sceneFilepath);
Console.WriteLine(scene.FilenameWithPath);
// Now we need to obtain the first generic finishes configuration
if (!scene.Generics.Any())
{
Console.WriteLine("No generic finishes configuration was found in the scene. Finishes aren't configured");
return;
}
foreach (var generic in scene.Generics)
{
Console.WriteLine("Generic: " + generic.FinishesConfigString);
}
// The finishes can be obtained as a classical finishes config string from SDK1:
var firstGeneric = scene.Generics.First();
var finishesConfigString = firstGeneric.FinishesConfigString;
Console.WriteLine("The first finishes config string is:");
Console.WriteLine(finishesConfigString);
Console.WriteLine();
// Or they can be parsed to access individual finishes in a convenient manner
var finishesConfig = new Scene.FinishesConfig(appli, firstGeneric.CatalogFilename, finishesConfigString);
foreach (var finish in finishesConfig)
{
Console.WriteLine($"{finish.Type.Name}: ({finish.Code}) {finish.Name}");
}
Constructors
Name | Description |
---|---|
FinishesConfig(Appli, string, string) | Instantiates FinishesConfig object from Appli instance and catalog filename to which finishes config string belongs to, and finishes config string itself. |
FinishesConfig(Object, string) | Instantiates FinishesConfig object from an object to which finishes config string belongs to, and finishes config string itself. |
Properties
Name | Description |
---|---|
FinishTypes | Provides access to the finish types available in the finishes config. |
Finishes | Provides access to all the finishes that are set in the finishes config. |
this[CatalogFinishType] | Allows to access a finish by its finish type. |
Methods
Name | Description |
---|---|
Equals(FinishesConfig) | Compares two instances based on their internal finishes config string representation. |
Equals(object) | Compares two instances based on their internal finishes config string representation. |
GetEnumerator() | Implements |
GetFinishTypeByName(string) | Gets finish type from the finishes config by its name. Throws an exception if given name doesn't exist in the finishes config. |
GetFinishTypeByTypeNumber(int) | Gets finish type from the finishes config by its type number. Throws an exception if given name doesn't exist in the finishes config. |
GetHashCode() | Generates instance hash code based on the internal string representation. |
ToString() | Returns string representation of the finishes config. |
TryGetFinish(CatalogFinishType, out CatalogFinish) | Tries to get finish for given finish type. |
TryGetFinishTypeByName(string, out CatalogFinishType) | Tries to get finish type with given name from the finishes config. |
TryGetFinishTypeByTypeNumber(int, out CatalogFinishType) | Tries to get finish type with given type number from the finishes config. |
TrySetFinish(CatalogFinishType, CatalogFinish) |
Operators
Name | Description |
---|---|
operator ==(FinishesConfig, FinishesConfig) | Determines whether two specified instances have the same value. |
operator !=(FinishesConfig, FinishesConfig) | Determines whether two specified instances have different values. |