MetaDataExtensions

public static class MetaDataExtensions
A set of extension methods for MetaData.

Methods

AnyMetaData

#Example
public static bool AnyMetaData(this IEnumerable<MetaData> items)
Test a collection to see if it has any meta data.
items (IEnumerable<MetaData>)Metadata collection to traverse.

AnyMetaData

#Example
public static bool AnyMetaData(this MetaData[] items)
Test a collection to see if it has any meta data.
items (MetaData[])Metadata collection to traverse.

AsIcon

#Example
public static IIcon AsIcon(this MetaType type)
Gets the icon associated with a specific meta data type.
type (MetaType)

AsIcon

#Example
public static IIcon AsIcon(this Notation notation)
Gets the icon associated with a specific meta data type.
notation (Notation)

Density

#Example
public static double Density(this Material m)
m (Material)
public static int Embed(this MetaData data, ArchivableDictionary userDictionary)
Embed a set of meta data in a Rhino user dictionary.
data (MetaData)
userDictionary (ArchivableDictionary)
Number of entries added.

Extract

#Example
public static MetaData Extract(this ArchivableDictionary userDictionary)
Extract a set of meta data from a Rhino user dictionary. This is the inverse of Embed(MetaData, ArchivableDictionary); only entries stored under a GH2: prefixed key are considered. Note that functions and gradients cannot survive a round-trip, they come back as text.
userDictionary (ArchivableDictionary)

HasReferenceId

#Example
public static bool HasReferenceId(this MetaData data, out Guid id)
Gets whether meta data has a Rhino reference ID. This method does not check the validity of the id, just whether it has been defined. Because this is an extension method, it can be called on null meta data.
data (MetaData)
id (out Guid)

HasReferenceId

#Example
public static bool HasReferenceId(this MetaData data)
Gets whether meta data has a Rhino reference ID. This method does not check the validity of the id, just whether it has been defined.
data (MetaData)

HasVectorAnchor

#Example
public static bool HasVectorAnchor(this MetaData data, out Point3d anchor)
Gets whether meta data has a vector anchor point.
data (MetaData)
anchor (out Point3d)

HasVectorAnchor

#Example
public static bool HasVectorAnchor(this MetaData data)
Gets whether meta data has a vector anchor point.
data (MetaData)

IsNullOrEmpty

#Example
public static bool IsNullOrEmpty(this MetaData meta)
Test whether meta data is null or empty.
meta (MetaData)

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, Angle constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (Angle)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, BigInteger constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (BigInteger)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, bool constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (bool)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, DateTime constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (DateTime)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, double constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (double)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, Guid constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (Guid)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, int constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (int)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, Interval constant)
Check whether meta data contains a key which matches the given pattern, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (Interval)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, MetaValue value)
Resolve a comparison with a meta value.
meta (MetaData)
pattern (string)
op (Operator)
value (MetaValue)

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, Plane constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (Plane)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, Point3d constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (Point3d)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, string constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (string)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, TimeSpan constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (TimeSpan)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, Transform constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (Transform)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern, Operator op, Vector3d constant)
Check whether meta data contains a key which matches the given name, and whose value matches a given comparison.
meta (MetaData)
pattern (string)
op (Operator)
constant (Vector3d)
True if at least one key matches the pattern.

PerformCompare

#Example
public static MetaDataComparison PerformCompare(this MetaData meta, string pattern)
Check whether meta data contains a key which matches the given name.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern, may contain wildcards.
True if at least one key matches the pattern.

Remove

#Example
public static MetaData[] Remove(this MetaData[] array, params MetaName[] names)
Remove the specified names from all metadata in an array.
array (MetaData[])Array to parse.
names (params MetaName[])Names to remove.
Either the original array if no values were removed, a modified array if some values were removed, or null if all values were removed.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out BigInteger value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out BigInteger)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out bool value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out bool)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out byte[] value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out byte[])Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out Color value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out Color)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out Colour value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out Colour)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out DateTime value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out DateTime)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out double value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out double)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out Guid value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out Guid)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out int value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out int)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out MetaValue value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out MetaValue)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out Plane value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out Plane)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out Point3d value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out Point3d)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out string value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out string)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out TimeSpan value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out TimeSpan)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out Transform value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out Transform)Value associated with key.
True if a key was found.

Resolve

#Example
public static bool Resolve(this MetaData meta, string pattern, out Vector3d value)
Check whether meta data contains a key which matches the given pattern, and output the associated value.
meta (MetaData)Meta data, may be null.
pattern (string)Key pattern.
value (out Vector3d)Value associated with key.
True if a key was found.

ToMetaData

#Example
public static MetaData ToMetaData(this NameValueCollection userStrings, List<Message> messages = null)
Harvest metadata from Rhino userstrings. Note that all returned values are marked as 'transient' which is an internal state that allows Grasshopper to remove them in the case of an update.
userStrings (NameValueCollection)
messages (List<Message> = null)

TryGet<T>

#Example
public static bool TryGet<T>(this MetaData meta, MetaName name, MetaName alternate, out T value)
Try to get the value with the given name. If the name is defined but associated with a value type other than T, a widening conversion will be performed if possible.
meta (MetaData)Meta data to operate on.
name (MetaName)Name to retrieve.
alternate (MetaName)Alternate fallback name.
value (out T)Value will be returned here.
True if value was found, false if name is undefined or if the type doesn't match.

TryGet<T>

#Example
public static bool TryGet<T>(this MetaData meta, MetaName name, out T value)
Try to get the value with the given name. If the name is defined but associated with a value type other than T, a widening conversion will be performed if possible.
meta (MetaData)Meta data to operate on.
name (MetaName)Name to retrieve.
value (out T)Value will be returned here.
True if value was found, false if name is undefined or if the type doesn't match.

TryGetMatch

#Example
public static bool TryGetMatch(this MetaData data, string namePattern, out MetaValue value)
Try and find the first value whose name matches the given pattern.
data (MetaData)
namePattern (string)
value (out MetaValue)

WithoutReferenceId

#Example
public static MetaData WithoutReferenceId(this MetaData data, bool retainUnderAlternate)
Remove reference id data from meta data.
data (MetaData)Data to remove from. May be null.
retainUnderAlternate (bool)If true, and the metadata contains an Id value, it will be moved into an alternate name.
Meta data without reference id.

WithoutTransientMetaData

#Example
public static IPear WithoutTransientMetaData(this IPear pear, TransientMetaData filter)
Remove the transient meta data entries which are not supposed to be copied to offspring values.
pear (IPear)Pear to operate on, may be null.
filter (TransientMetaData)Transient data to remove.

WithoutTransientMetaData<T>

#Example
public static Pear<T> WithoutTransientMetaData<T>(this Pear<T> pear, TransientMetaData filter)
Remove the transient meta data entries which are not supposed to be copied to offspring values.
pear (Pear<T>)Pear to operate on, may be null.
filter (TransientMetaData)Transient data to remove.

WithReferenceId

#Example
public static MetaData WithReferenceId(this MetaData data, Guid id)
Add a reference id to meta data.
data (MetaData)Data to append to. May be null.
id (Guid)Id to add.
Meta data with reference id.

Zip<T>

#Example
public static IEnumerable<Pear<T>> Zip<T>(this (IEnumerable<T> items, IEnumerable<MetaData> metaData) contents)
Zip an item and a meta data collection into a Pair collection.
contents ((IEnumerable<T> items, IEnumerable<MetaData> metaData))Tuple containing the item and meta data enumerations.
Pair enumeration.

Zip<T>

#Example
public static IEnumerable<Pear<T>> Zip<T>(this IEnumerable<T> items, IEnumerable<MetaData> metaData)
Zip an item and a meta data collection into a Pair collection.
items (IEnumerable<T>)Collection of item values.
metaData (IEnumerable<MetaData>)Collection of meta data values.
Pair enumeration.