public MaterialInfo Material {get; set;}
public MaterialInfo Material {get; set;}
Exception | Description |
---|---|
EPLAN.Harness.API.Exceptions.HpdApiNotInitializedException | Api is not in an initialized state. You can get current state from EPLAN.Harness.API.HpdApi.Status property. If API is uninitialized, you can initialize it by calling EPLAN.Harness.API.HpdApi.Init method. If API is in failed state, you can not resurrect it. |
EPLAN.Harness.API.Exceptions.ObjectInvalidException | The object is in invalid state. Obtain a new one. |
EPLAN.Harness.API.Exceptions.OccurrenceDeletedException | The exception that is thrown when you trying to access to already deleted occurrence. |
System.ArgumentException | Thrown when it is not allowed to select this material. |
// Obtain the occurrence. IOccPart part = designer.GetAllOccurrences<IOccPart>().FirstOrDefault(p => p.Name.Value == "Part:1"); // Select a required material from connected library. List<MaterialInfo> materials = project.ActiveConnection.GetMaterials().ToList(); MaterialInfo material = materials.FirstOrDefault(m => m.Name.Value == "Steel"); // Set its material. part.Material = material; // Notice: The possible null references should be handled in the code. This is simplified sample only.
// Obtain the occurrence. IOccBundle bundle = designer.GetAllOccurrences<IOccBundle>().FirstOrDefault(p => p.Name.Value == "MyBundle"); // Select a required material from predefined materials. List<MaterialInfo> materials = MaterialInfo.GetPredefinedMaterials().ToList(); MaterialInfo material = materials.FirstOrDefault(m => m.Name.Value == "Green"); // Set its material. bundle.Material = material;
// Obtain the occurrence. IOccBundle bundle = designer.GetAllOccurrences<IOccBundle>().FirstOrDefault(p => p.Name.Value == "MyBundle"); // Reset its material. (The default color from Designer settings is set.) bundle.Material = null;