GH_UserObject

public class GH_UserObject
Represents a custom user object. A User Object is an existing IGH_DocumentObject with overridden icon, instance description and exposure.

Constructors

GH_UserObject

#
Empty constructor
public GH_UserObject()

GH_UserObject

#
Create a new user object from an existing *.ghuser file.
public GH_UserObject(
source_file
File that contains the User Object definition.
)

Properties

BaseGuid

#
Gets or sets the ComponentID of the IGH_DocumentObject that functions as the base class for this User Object.
public Guid BaseGuid { get; set; }

Data

#
Gets or sets the serialized data. This data is used to deserialize a new instance of the base class.
public byte[] Data { get; set; }

Description

#
Gets or sets the Instance Description override for this User Object.
public GH_InstanceDescription Description { get; set; }

Exposure

#
Gets or sets the Exposure of this User Object.
public GH_Exposure Exposure { get; set; }

Guid

#
Gets or sets the Guid of this User Object. The Guid is created anew during construction and is not stored in the User Object File. You should never have to set this field.
public Guid Guid { get; set; }

Icon

#
Gets or sets the icon associated with this User Object. If the icon hasn't been overridden, then a Default icon is returned.
public Bitmap Icon { get; set; }

Path

#
Gets or sets the file path this User Object is loaded from or saved to.
public string Path { get; set; }

Methods

Clear

#
Destroy all data except the file path and the ID.
public void Clear()

CreateDefaultPath

#
Set the Path field for this user object to the default. The default file name is derived from the Description.Name field. This method also ensures the UserObject directory exists.
public void CreateDefaultPath(
avoid_conflict
If true, a unique file path is assigned.
)

InstantiateObject

#
Instantiate a new IGH_DocumentObject from this User Object.
public IGH_DocumentObject InstantiateObject()
The IGH_DocumentObject instance defined inside the UserObject file or null on error.

ReadFromFile

#
Force an update of the local data from the file. The Path field must be set for this to work.
public void ReadFromFile()
InvalidOperationExceptionThrown when the source file doesn't exist or is corrupted.

SaveToFile

#
Save the current User Object state to a file. Any existing file will be overwritten.
public bool SaveToFile()
True on success, false on failure.

SetDataFromObject

#
Set the Data field content of ths UserObject from a Document object instance.
public void SetDataFromObject(
obj
Object to assign
)