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

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

Properties

Description

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

ShouldWrite

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

Transform

#Since v5.0
public Transform Transform { get; protected set; }
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.

Methods

Copy

#Since v5.0
public static void Copy(CommonObject source, CommonObject destination)
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.
source (CommonObject)A source object for the data.
destination (CommonObject)A destination object for the data.

Dispose

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

Dispose

#
protected virtual void Dispose(bool disposing)
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.

disposing (bool)true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer.

MoveUserDataFrom

#Since v5.0
public static Guid MoveUserDataFrom(CommonObject objectWithUserData)
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.
objectWithUserData (CommonObject)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
public static void MoveUserDataTo(CommonObject objectToGetUserData, Guid id, bool append)
Moves the user data.

See MoveUserDataFrom(CommonObject) for more information.

objectToGetUserData (CommonObject)Object data source.
id (Guid)Target.
append (bool)If the data should be appended or replaced.

OnDuplicate

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

OnTransform

#
protected virtual void OnTransform(Transform transform)
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.
transform (Transform)The transform being applied.

Read

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

Write

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