UserData

References
public abstract class UserData : IDisposable
Provides a base class for custom classes of information which may be attached to geometry or attribute classes.

Finalizer

~UserData

#
Passively reclaims unmanaged resources when the class user did not explicitly call Dispose().
~UserData()

Properties

Description

#Since v5.0
Descriptive name of the user data.
public virtual string Description { get; }

ShouldWrite

#Since v5.0
If you want to save this user data in a 3dm file, override ShouldWrite and return true. If you do support serialization, you must also override the Read and Write functions.
public virtual bool ShouldWrite { get; }

Transform

#Since v5.0
Updated if user data is attached to a piece of geometry that is transformed and the virtual OnTransform() is not overridden. If you override OnTransform() and want Transform to be updated, then call the base class OnTransform() in your override. The default constructor sets Transform to the identity.
public Transform Transform { get; protected set; }

Methods

Copy

#Since v5.0
Expert user tool that copies user data that has a positive CopyCount from the source object to a destination object. Generally speaking you don't need to use Copy(). Simply rely on things like the copy constructors to do the right thing.
public static void Copy(
source,
A source object for the data.
destination
A destination object for the data.
)

Dispose

#Since v5.0
Actively reclaims unmanaged resources that this instance uses.
public void Dispose()

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.
)

MoveUserDataFrom

#Since v5.0
Moves the user data from objectWithUserData to a temporary data storage identified by the return Guid. When MoveUserDataFrom returns, the objectWithUserData will not have any user data.
public static Guid MoveUserDataFrom(
objectWithUserData
Object with user data attached.
)
Guid identifier for storage of UserData that is held in a temporary list by this class. This function should be used in conjunction with MoveUserDataTo to transfer the user data to a different object. Returns Guid.Empty if there was no user data to transfer.

MoveUserDataTo

#Since v5.0
Moves the user data.

See MoveUserDataFrom(CommonObject) for more information.

public static void MoveUserDataTo(
objectToGetUserData,
Object data source.
id,
Target.
append
If the data should be appended or replaced.
)

OnDuplicate

#
Is called when the object is being duplicated.
protected virtual void OnDuplicate(
source
The source data.
)

OnTransform

#
Is called when the object associated with this data is transformed. If you override this function, make sure to call the base class if you want the stored Transform to be updated.
protected virtual void OnTransform(
transform
The transform being applied.
)

Read

#
Reads the content of this data from a stream archive.
protected virtual bool Read(
archive
An archive.
)
true if the data was successfully written. The default implementation always returns false.

Write

#
Writes the content of this data to a stream archive.
protected virtual bool Write(
archive
An archive.
)
true if the data was successfully written. The default implementation always returns false.