[Serializable] public sealed class Material : ModelComponent

Constructors

Material

#Since v5.0
public Material()

Material

#Since v6.0
public Material(
Material
other
)

Properties

AlphaTransparency

#Since v6.0
public bool AlphaTransparency { get; set; }

AmbientColor

#Since v5.0
public Color AmbientColor { get; set; }

ComponentStatus

Gets or sets the component status of the model component.
public virtual ComponentStatus ComponentStatus { get; set; }
inherited fromModelComponent

ComponentType

#Since v6.0
public override ModelComponentType ComponentType { get; }

DefaultMaterial

#Since v5.0
public static Material DefaultMaterial { get; }

DeletedName

Gets the name of a component that is deleted.
public string DeletedName { get; }
inherited fromModelComponent

DiffuseColor

#Since v5.0
public Color DiffuseColor { get; set; }

DisableLighting

#Since v6.0
public bool DisableLighting { get; set; }

Disposed

Indicates if this object has been disposed or the document it originally belonged to has been disposed.
public bool Disposed { get; }
inherited fromCommonObject

EmissionColor

#Since v5.0
public Color EmissionColor { get; set; }

FresnelIndexOfRefraction

#Since v6.0
Gets or sets the Fresnel index of refraction of the material, default is 1.56
public double FresnelIndexOfRefraction { get; set; }

FresnelReflections

#Since v6.0
Gets or sets if Fresnel reflections are used.
public bool FresnelReflections { get; set; }

HasId

Returns a value indicating whether the component has an ID.
public bool HasId { get; }
inherited fromModelComponent

HasIndex

Returns a value indicating whether the component has an Index.
public bool HasIndex { get; }
inherited fromModelComponent

HasName

Returns a value indicating whether the component has a Name.
public bool HasName { get; }
inherited fromModelComponent

HasUserData

Gets true if this class has any custom information attached to it through UserData.
public bool HasUserData { get; }
inherited fromCommonObject

Id

Gets or sets the ID of the current instance.
public virtual Guid Id { get; set; }
inherited fromModelComponent
InvalidOperationExceptionWhen 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.
public bool IdIsLocked { get; }
inherited fromModelComponent

Index

Gets or sets the model component index attribute.
public virtual int Index { get; set; }
inherited fromModelComponent
InvalidOperationExceptionWhen 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.
public bool IndexIsLocked { get; }
inherited fromModelComponent

IndexOfRefraction

#Since v5.1
Gets or sets the index of refraction of the material, generally >= 1.0 (speed of light in vacuum)/(speed of light in material)
public double IndexOfRefraction { get; set; }

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.
[CLSCompliant(false)] public virtual uint InstanceDefinitionModelSerialNumber { get; }
inherited fromModelComponent
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.
public bool IsComponentStatusLocked { get; }
inherited fromModelComponent

IsDefaultMaterial

#Since v5.0
By default Rhino layers and objects are assigned the default rendering material.
public bool IsDefaultMaterial { get; }

IsDeleted

#Since v5.0
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.
public override bool IsDeleted { get; }

IsDocumentControlled

#Since v5.6
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.
public override bool IsDocumentControlled { get; }

IsPhysicallyBased

#Since v7.0
public bool IsPhysicallyBased { get; }

IsReference

#Since v5.0
Rhino allows multiple files to be viewed simultaneously. Materials in the document are "normal" or "reference". Reference materials are not saved.
public override bool IsReference { get; }

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
public bool IsSystemComponent { get; }
inherited fromModelComponent

IsValid

Tests an object to see if it is valid.
public virtual bool IsValid { get; }
inherited fromCommonObject

MaterialIndex

#Since v5.6
[EditorBrowsable(EditorBrowsableState.Never)] public int MaterialIndex { get; }

MaxShine

#Since v5.0
public static double MaxShine { get; }

ModelSerialNumber

A value identifying the model that manages this component.
[CLSCompliant(false)] public virtual uint ModelSerialNumber { get; }
inherited fromModelComponent
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.

Name

#Since v5.0
public override string Name { get; set; }

NameIsLocked

Returns a value indicating whether the component Name is already locked.
public bool NameIsLocked { get; }
inherited fromModelComponent

PhysicallyBased

#Since v7.0
public PhysicallyBasedMaterial PhysicallyBased { get; }

PreviewColor

#Since v6.6
Very simple preview color function for GUIs.
public Color PreviewColor { get; }

RDKMaterialID

#Since v8.6
Gets the RDK material ID.
public Guid RDKMaterialID { get; }
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.
[CLSCompliant(false)] public virtual uint ReferenceModelSerialNumber { get; }
inherited fromModelComponent
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.

ReflectionColor

#Since v5.0
public Color ReflectionColor { get; set; }

ReflectionGlossiness

#Since v6.0
Gets or sets the reflection glossiness.
public double ReflectionGlossiness { get; set; }

Reflectivity

#Since v5.7
Gets or sets how reflective a material is, 0f is no reflection 1f is 100% reflective.
public double Reflectivity { get; set; }

RefractionGlossiness

#Since v6.0
Gets or sets the refraction glossiness.
public double RefractionGlossiness { get; set; }

RenderMaterial

#Since v6.0
Get the RenderMaterial related to this Material. Will create a new RenderMaterial if none exists. This can happen for older documents.
public RenderMaterial RenderMaterial { get; }

RenderMaterialInstanceId

#Since v6.0
public Guid RenderMaterialInstanceId { get; set; }

RenderPlugInId

#Since v5.0
The Id of the RenderPlugIn that is associated with this material.
public Guid RenderPlugInId { get; set; }

Shine

#Since v5.0
Gets or sets the shine factor of the material.
public double Shine { get; set; }

SpecularColor

#Since v5.0
public Color SpecularColor { get; set; }

Transparency

#Since v5.0
Gets or sets the transparency of the material (0.0 = opaque to 1.0 = transparent)
public double Transparency { get; set; }

TransparentColor

#Since v5.0
public Color TransparentColor { get; set; }

UseCount

#Since v5.0
Number of objects and layers that use this material.
public int UseCount { get; }

UserData

List of custom information that is attached to this class.
public UserDataList UserData { get; }
inherited fromCommonObject

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.
public ArchivableDictionary UserDictionary { get; }
inherited fromCommonObject

UserStringCount

#Since v5.0
public int UserStringCount { get; }

Methods

ClearId

Resets the HasId property of the model component to false, if possible.
public void ClearId()
inherited fromModelComponent
InvalidOperationExceptionIf the ID is locked.

ClearIndex

Resets the HasIndex property of the model component to false, if possible.
public void ClearIndex()
inherited fromModelComponent
InvalidOperationExceptionIf the index is locked.

ClearMaterialChannels

#Since v6.26
Removes all material channels
public void ClearMaterialChannels()

ClearName

Resets the HasName property of the model component to false, if possible.
public void ClearName()
inherited fromModelComponent
InvalidOperationExceptionIf the name is locked.

CommitChanges

#Since v5.0
public bool CommitChanges()

ConstructConstObject

Assigns a parent object and a sub-object index to this.
protected void ConstructConstObject(
parentObject,
The parent object.
subobjectIndex
The sub-object index.
)
inherited fromCommonObject

CopyFrom

#Since v6.0
public void CopyFrom(
Material
other
)

DataCRC

Increments the Cyclic Redundancy Check value by this instance.
[CLSCompliant(false)] public uint DataCRC(
currentRemainder
The current remainder value.
)
inherited fromModelComponent
The updated remainder value.

Default

#Since v5.0
Set material to default settings.
public void Default()

Dispose

Actively reclaims unmanaged resources that this instance uses.
public void Dispose()
inherited fromCommonObject

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.

protected virtual void Dispose(
disposing
true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer.
)
inherited fromCommonObject

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.
public void EnsurePrivateCopy()
inherited fromCommonObject

GetBitmapTexture

#Since v5.0
public Texture GetBitmapTexture()

GetBumpTexture

#Since v5.0
Gets the bump texture of this material.
public Texture GetBumpTexture()
A texture; or null if no bump texture has been added to this material.

GetEnvironmentTexture

#Since v5.0
public Texture GetEnvironmentTexture()

GetObjectData

Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] public virtual void GetObjectData(
info,
The System.Runtime.Serialization.SerializationInfo to populate with data.
context
The destination (see System.Runtime.Serialization.StreamingContext) for this serialization.
)
inherited fromCommonObject

GetTexture

#Since v7.0
Get the texture that corresponds with the specified texture type for this material.
public Texture GetTexture()

GetTextures

#Since v5.7
Get array of textures that this material uses
public Texture[] GetTextures()

GetTransparencyTexture

#Since v5.0
public Texture GetTransparencyTexture()

GetUserString

#Since v5.0
Gets a user string.
public string GetUserString(
key
id used to retrieve the string.
)
string associated with the key if successful. null if no key was found.

GetUserStrings

#Since v5.0
Gets an independent copy of the collection of (user text key, user text value) pairs attached to this object.
public NameValueCollection GetUserStrings()
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.
public bool IsValidWithLog(
out string
log
A textual log. This out parameter is assigned during this call.
)
inherited fromCommonObject
true if this object is valid; false otherwise.

LockId

Locks the component Id property.
public void LockId()
inherited fromModelComponent

LockIndex

Locks the component Index property.
public void LockIndex()
inherited fromModelComponent

LockName

Locks the component Name property.
public void LockName()
inherited fromModelComponent

MaterialChannelIdFromIndex

#Since v6.26
Finds id of the material channel at given index.
public Guid MaterialChannelIdFromIndex(
material_channel_index
Index
)
Id of the material channel

MaterialChannelIndexFromId

#Since v6.26
Finds index of the material channel that refers to a material channel with the given id. Optionally adds channel if one is not found.
public int MaterialChannelIndexFromId(
material_channel_id,
Id
bAddIdIfNotPresent
Controls whether to add channel if none exist
)
Index of the material channel

NonConstOperation

For derived classes implementers.

Defines the necessary implementation to free the instance from being constant.

protected virtual void NonConstOperation()
inherited fromCommonObject

OnSwitchToNonConst

#
protected override void OnSwitchToNonConst()

SetBitmapTexture

#Since v5.0
public bool SetBitmapTexture(
filename
)

SetBitmapTexture

#Since v9.0
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.

public bool SetBitmapTexture(
name,
The name to cache the pixels under. See TextureCache.Set(string, Bitmap).
bitmap
The pixels to use.
)
true on success.
TextureCache

SetBitmapTexture

#Since v5.0
public bool SetBitmapTexture(
texture
)

SetBumpTexture

#Since v5.0
public bool SetBumpTexture(
filename
)

SetBumpTexture

#Since v5.0
public bool SetBumpTexture(
texture
)

SetEnvironmentTexture

#Since v5.0
public bool SetEnvironmentTexture(
filename
)

SetEnvironmentTexture

#Since v5.0
public bool SetEnvironmentTexture(
texture
)

SetTexture

#Since v7.0
Set the texture that corresponds with the specified texture type for this material.
public bool SetTexture(
texture,
An instance of Rhino.DocObjects.Texture
which
Use Rhino.DocObjects.TextureType
)

SetTransparencyTexture

#Since v5.0
public bool SetTransparencyTexture(
filename
)

SetTransparencyTexture

#Since v5.0
public bool SetTransparencyTexture(
texture
)

SetUserString

#Since v5.0
Attach a user string (key,value combination) to this geometry.
public bool SetUserString(
key,
id used to retrieve this string.
value
string associated with key.
)
true on success.

ToJSON

Create a JSON string representation of this object
public string ToJSON()
inherited fromCommonObject

ToPhysicallyBased

#Since v7.0
public void ToPhysicallyBased()

ToString

Returns the name of the model component type, and then its name and index.
public override string ToString()
inherited fromModelComponent
Remarks: This is provided as a visual aid. Do not rely on this for serialization.
Object.ToString