Constructors
Properties
ComponentStatus
Gets or sets the component status of the model component.
Returns ModelComponentType.RenderMaterial.
Overrides: ModelComponent.ComponentType
public static Material DefaultMaterial { get; }
Disposed
Indicates if this object has been disposed or the document it originally belonged to has been disposed.
Gets or sets the Fresnel index of refraction of the material, default is 1.56
Gets or sets if Fresnel reflections are used.
HasUserData
Gets true if this class has any custom information attached to it through UserData.
Exceptions:
| InvalidOperationException | When setting the ID failed. This usually happened because the instance ID is already locked. |
IdIsLocked
Returns a value indicating whether the component ID is already locked.
Exceptions:
| InvalidOperationException | When setting the Index failed. This usually happens because the instance Index is already locked. |
IndexIsLocked
Returns a value indicating whether the component Index is already locked.
Gets or sets the index of refraction of the material, generally >= 1.0 (speed of light in vacuum)/(speed of light in material)
InstanceDefinitionModelSerialNumber
When a component is in a model as part of the information required for a linked instance definition, this value identifies the linked instance definition reference model.
Remarks: Reference components are not saved in .3dm archives. Typically this value is set and locked by the code that adds a component to a model. This value is not saved in .3dm archives.
IsComponentStatusLocked
The component status itself can be locked. This returns an indication.
By default Rhino layers and objects are assigned the default rendering material.
Deleted materials are kept in the runtime material table so that undo will work with materials. Call IsDeleted to determine to determine if a material is deleted.
Overrides: ModelComponent.IsDeleted
If true this object may not be modified. Any properties or functions that attempt to modify this object when it is set to "IsReadOnly" will throw a NotSupportedException.
Overrides: CommonObject.IsDocumentControlled
Rhino allows multiple files to be viewed simultaneously. Materials in the document are "normal" or "reference". Reference materials are not saved.
Overrides: ModelComponent.IsReference
IsSystemComponent
True if this model component is a system constant.
An incomplete list of system constant model components is below:
- ON_ModelComponent::Unset
- ON_InstanceDefinition::Empty
- ON_Linetype::Unset
- ON_Linetype::Continuous
- ON_Linetype::ByLayer
- ON_Linetype::ByParent
- ON_Layer::Unset
- ON_Layer::Default
- ON_TextStyle::Unset
- ON_TextStyle::Default
- ON_TextStyle::ByLayer
- ON_TextStyle::ByParent
- ON_DimStyle::Unset
- ON_DimStyle::Default
- ON_DimStyle::DefaultInchDecimal
- ON_DimStyle::DefaultInchFractional
- ON_DimStyle::DefaultFootInchArchitecture
- ON_DimStyle::DefaultMillimeterSmall
- ON_DimStyle::DefaultMillimeterLarge
- ON_DimStyle::DefaultMillimeterArchitecture
ModelSerialNumber
A value identifying the model that manages this component.
Remarks: If the component is being managed by a model, this value identifies the model. In Rhino, this value is the document runtime serial number. Typically this value is set and locked by the code that adds a component to a model. This value is not saved in .3dm archives.
NameIsLocked
Returns a value indicating whether the component Name is already locked.
public PhysicallyBasedMaterial PhysicallyBased { get; }
Very simple preview color function for GUIs.
Gets the RDK material ID.
Remarks: Multiple Rhino materials ( with unique component IDs) can have the same RDK material ID.
ReferenceModelSerialNumber
When a component is in a model for reference, this value identifies the reference model.
Remarks: Reference components are not saved in .3dm archives. Typically this value is set and locked by the code that adds a component to a model. This value is not saved in .3dm archives.
Gets or sets the reflection glossiness.
Gets or sets how reflective a material is, 0f is no reflection 1f is 100% reflective.
Gets or sets the refraction glossiness.
Get the RenderMaterial related to this Material. Will create a new RenderMaterial if none exists. This can happen for older documents.
The Id of the RenderPlugIn that is associated with this material.
Gets or sets the transparency of the material (0.0 = opaque to 1.0 = transparent)
UserData
List of custom information that is attached to this class.
UserDictionary
Dictionary of custom information attached to this class. The dictionary is actually user data provided as an easy to use shareable set of information.
Methods
ClearId
public void ClearId()
Resets the HasId property of the model component to false, if possible.
Exceptions:
| InvalidOperationException | If the ID is locked. |
ClearIndex
public void ClearIndex()
Resets the HasIndex property of the model component to false, if possible.
Exceptions:
| InvalidOperationException | If the index is locked. |
ClearName
public void ClearName()
Resets the HasName property of the model component to false, if possible.
Exceptions:
| InvalidOperationException | If the name is locked. |
ConstructConstObject
Assigns a parent object and a sub-object index to this.
DataCRC
Increments the Cyclic Redundancy Check value by this instance.
Parameters:
| currentRemainder (uint) | The current remainder value. |
Returns: The updated remainder value.
Dispose
public void Dispose()
Actively reclaims unmanaged resources that this instance uses.
Dispose
For derived class implementers.
This method is called with argument true when class user calls Dispose(), while with argument false when the Garbage Collector invokes the finalizer, or Finalize() method.
You must reclaim all used unmanaged resources in both cases, and can use this chance to call Dispose on disposable fields if the argument is true.
Also, you must call the base virtual method within your overriding method.
Parameters:
| disposing (bool) | true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer. |
EnsurePrivateCopy
public void EnsurePrivateCopy()
If you want to keep a copy of this class around by holding onto it in a variable after a command completes, call EnsurePrivateCopy to make sure that this class is not tied to the document. You can call this function as many times as you want.
Gets the bump texture of this material.
Returns: A texture; or null if no bump texture has been added to this material.
GetObjectData
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.
Parameters:
| info (SerializationInfo) | The System.Runtime.Serialization.SerializationInfo to populate with data. |
| context (StreamingContext) | The destination (see System.Runtime.Serialization.StreamingContext) for this serialization. |
Get the texture that corresponds with the specified texture type for this material.
Parameters:
| which (TextureType) |
Gets a user string.
Parameters:
| key (string) | id used to retrieve the string. |
Returns: string associated with the key if successful. null if no key was found.
Gets an independent copy of the collection of (user text key, user text value) pairs attached to this object.
Returns: A collection of key strings and values strings. This
IsValidWithLog
Determines if an object is valid. Also provides a report on errors if this object happens not to be valid.
Parameters:
| log (out string) | A textual log. This out parameter is assigned during this call. |
Returns: true if this object is valid; false otherwise.
LockId
public void LockId()
Locks the component Id property.
LockIndex
public void LockIndex()
Locks the component Index property.
LockName
public void LockName()
Locks the component Name property.
Finds id of the material channel at given index.
Parameters:
| material_channel_index (int) | Index |
Returns: Id of the material channel
Finds index of the material channel that refers to a material channel with the given id. Optionally adds channel if one is not found.
NonConstOperation
protected virtual void NonConstOperation()
For derived classes implementers.
Defines the necessary implementation to free the instance from being constant.
OnSwitchToNonConst
#protected override void OnSwitchToNonConst()
Overrides: CommonObject.OnSwitchToNonConst
Parameters:
| filename (string) |
Uses the pixels of an in-memory bitmap as this material's bitmap texture, without writing an image file.
The pixels are copied into TextureCache under name. Calling this again with the same name replaces them in place, and the change shows up on the next redraw.
Parameters:
| name (string) | The name to cache the pixels under. See TextureCache.Set(string, Bitmap). |
| bitmap (Bitmap) | The pixels to use. |
Returns: true on success.
Parameters:
| texture (Texture) |
Parameters:
| filename (string) |
Parameters:
| texture (Texture) |
Set the texture that corresponds with the specified texture type for this material.
Parameters:
| texture (Texture) | An instance of Rhino.DocObjects.Texture |
| which (TextureType) | Use Rhino.DocObjects.TextureType |
Parameters:
| filename (string) |
Parameters:
| texture (Texture) |
Attach a user string (key,value combination) to this geometry.
ToJSON
Create a JSON string representation of this object
Parameters:
| options (SerializationOptions) |
public void ToPhysicallyBased()
ToString
Returns the name of the model component type, and then its name and index.
Remarks: This is provided as a visual aid. Do not rely on this for serialization.
Overrides: Object.ToString