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

#
public GH_UserObject()
Empty constructor

GH_UserObject

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

Properties

BaseGuid

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

Data

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

Description

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

Exposure

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

Guid

#
public Guid Guid { get; set; }
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.

Icon

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

Path

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

Methods

Clear

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

CreateDefaultPath

#
public void CreateDefaultPath(bool avoid_conflict)
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.
avoid_conflict (bool)If true, a unique file path is assigned.

InstantiateObject

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

ReadFromFile

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

SaveToFile

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

SetDataFromObject

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