Class AntFarmAPI
The main API
class.
Contains all methods and events to access AntFarm internal data storage and manipulation system.
Inheritance
Inherited Members
Namespace: AntFarm.API
Assembly: AntFarm.dll
Syntax
public static class AntFarmAPI
Methods
ChangeClientColour(Guid, APIColour)
Declaration
public static bool ChangeClientColour(Guid clientId, APIColour colour)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | |
APIColour | colour |
Returns
Type | Description |
---|---|
System.Boolean |
Exceptions
Type | Condition |
---|---|
APIException |
CheckInCategory(APICategory)
Performs a check in of a given Category for the registered client.
Declaration
public static void CheckInCategory(APICategory category)
Parameters
Type | Name | Description |
---|---|---|
APICategory | category | Valid APICategory container |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
CheckInDataSet(APIDataSet)
Performs a check in of a given DataSet as registered to the client.
Declaration
public static void CheckInDataSet(APIDataSet dataSet)
Parameters
Type | Name | Description |
---|---|---|
APIDataSet | dataSet | Valid APIDataSet container |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
CheckInPropertyType(APIPropertyType)
Performs a check in of a given PropertyType for the registered client.
Declaration
public static void CheckInPropertyType(APIPropertyType propertyType)
Parameters
Type | Name | Description |
---|---|---|
APIPropertyType | propertyType | Valid APIPropertyType container |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
CheckOutCategory(APICategory)
Performs a check out of a given Category for the registered client.
Declaration
public static void CheckOutCategory(APICategory category)
Parameters
Type | Name | Description |
---|---|---|
APICategory | category | Valid APICategory container |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
CheckOutDataSet(APIDataSet)
Performs a check out of a given DataSet. This is useful if you want to write to the database or save the data into the Rhino file.
Declaration
public static void CheckOutDataSet(APIDataSet dataSet)
Parameters
Type | Name | Description |
---|---|---|
APIDataSet | dataSet | Valid APIDataSet container |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
CheckOutPropertyType(APIPropertyType)
Performs a check in of a given PropertyType for the registered client.
Declaration
public static void CheckOutPropertyType(APIPropertyType propertyType)
Parameters
Type | Name | Description |
---|---|---|
APIPropertyType | propertyType | Valid APIPropertyType container |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
DataSetTrySelectTabItem(Guid, String)
Selects a AFTabItem in the UI by name for the registered client.
Declaration
public static bool DataSetTrySelectTabItem(Guid clientId, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Name of the AFTabItem to select in UI |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
DisableAntFarmEvents()
Warning: This is an advanced feature and if not used properly will break AntFarm Use this method to turn off AntFarm internal events
Declaration
public static void DisableAntFarmEvents()
EnableAntFarmEvents()
Warning: This is an advanced feature and if not used properly will break AntFarm Use this method to turn on AntFarm internal events
Declaration
public static void EnableAntFarmEvents()
ExecuteQuery(Guid, String)
Gets a complete DataTable based on the query for the registered client
Declaration
public static DataTable ExecuteQuery(Guid clientId, string query)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | query | SQL statement |
Returns
Type | Description |
---|---|
System.Data.DataTable | DataTable based on the provided query. |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
GetCategory(Guid, String, Boolean)
Returns a Category by name and for a client.
Declaration
public static APICategory GetCategory(Guid clientId, string name, bool isWrite)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Category name |
System.Boolean | isWrite | Flag if write access is needed
|
Returns
Type | Description |
---|---|
APICategory | APICategory, if Category with specified name exists in AntFarm |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or Category with name specified does not exist. Check for APIExceptionCode to process further. |
GetCategoryNames(Guid)
Returns a list of names of all existing category in AntFarm.
Declaration
public static List<string> GetCategoryNames(Guid clientId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | List of all Category names in AntFarm |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
GetDataSet(Guid, String, Boolean)
Get a DataSet by name that is registered with the current client
Declaration
public static APIDataSet GetDataSet(Guid clientId, string name, bool isWrite)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Name of DataSet |
System.Boolean | isWrite | Flag if write access is needed
|
Returns
Type | Description |
---|---|
APIDataSet | APIDataSet, if DataSet with specified name exists in AntFarm |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or DataSet with name specified does not exist. Check for APIExceptionCode to process further. |
GetDataSetNames(Guid)
Returns a list of names of all existing DataSets in AntFarm.
Declaration
public static List<string> GetDataSetNames(Guid clientId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | List of all active DataSet names |
Exceptions
Type | Condition |
---|---|
APIException |
GetPropertyType(Guid, String, Boolean)
Get an PropertyType by name register to the client.
Declaration
public static APIPropertyType GetPropertyType(Guid clientId, string name, bool isWrite)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | PropertyType name |
System.Boolean | isWrite | Flag if write access is needed
|
Returns
Type | Description |
---|---|
APIPropertyType | APICategory, if PropertyType with specified name exists in AntFarm |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or Category with name specified does not exist. Check for APIExceptionCode to process further. |
GetPropertyTypeNames(Guid)
Returns a list of names of all existing PropertyTypes in AntFarm.
Declaration
public static List<string> GetPropertyTypeNames(Guid clientId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | List of all PropertyType names in AntFarm |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
LoadAPISchema(APISchema, Boolean)
Loads an APISchema for a registered client. Writes to AntFarm.
Declaration
public static void LoadAPISchema(APISchema schema, bool invokeHistory)
Parameters
Type | Name | Description |
---|---|---|
APISchema | schema | APISchema to load into AntFarm |
System.Boolean | invokeHistory | Flag if rhino history needs to be provided for this method |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid or client is not registered. |
NewAttribute(Guid, String, APICategory)
Registers a new virutal Attribute to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Use this method to create a new Attribute of type Category.
Does not write to AntFarm.
Declaration
public static APIAttribute NewAttribute(Guid clientId, string name, APICategory category)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Attribute name |
APICategory | category | Attribute category |
Returns
Type | Description |
---|---|
APIAttribute | New API AntFarm Attribute |
Exceptions
Type | Condition |
---|---|
APIException |
NewAttribute(Guid, String, APIAttributeType)
Registers a new virtual Attribute to your client application. Does not save to file unless a DatSet is committed to AntFarm.
Use this method to create a new Attribute of type
Does not write to AntFarm.
Declaration
public static APIAttribute NewAttribute(Guid clientId, string name, APIAttributeType type)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Attribute name |
APIAttributeType | type | Attribute type |
Returns
Type | Description |
---|---|
APIAttribute | New API AntFarm Attribute |
Exceptions
Type | Condition |
---|---|
APIException |
NewAttribute(Guid, String, APIGeometricAttributeType)
Registers a new virutal Attribute to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Use this method to create a new Attribute of type Geometric.
Does not write to AntFarm.
Declaration
public static APIAttribute NewAttribute(Guid clientId, string name, APIGeometricAttributeType type)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Attribute name |
APIGeometricAttributeType | type | Attribute geometric type |
Returns
Type | Description |
---|---|
APIAttribute | New API AntFarm Attribute |
Exceptions
Type | Condition |
---|---|
APIException |
NewCategory(Guid, String)
Registers a new virutal Category to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Declaration
public static APICategory NewCategory(Guid clientId, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Category name |
Returns
Type | Description |
---|---|
APICategory | New APICategory |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid. |
NewColour(Byte, Byte, Byte, Byte)
Registers a new virutal Colour to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Declaration
public static APIColour NewColour(byte a, byte r, byte g, byte b)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | a | Alpha value of the colour |
System.Byte | r | Red value of the colour |
System.Byte | g | Green value of the colour |
System.Byte | b | Blue value of the colour |
Returns
Type | Description |
---|---|
APIColour | New APIColour |
NewColour(Color)
Registers a new virutal Colour to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Declaration
public static APIColour NewColour(Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | color | Color based on System.Drawing |
Returns
Type | Description |
---|---|
APIColour | New APIColour |
NewColour(Color)
Creates a new APIColour in your client application.
Declaration
public static APIColour NewColour(Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Media.Color | color | Color based on System.Windows.Media |
Returns
Type | Description |
---|---|
APIColour | New APIColour |
NewDataSet(Guid, String)
Registers a virtual DataSet to your client application. Does not save to file unless committed to AntFarm. Uses default settings.
Declaration
public static APIDataSet NewDataSet(Guid clientId, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Name of the APIDataSet |
Returns
Type | Description |
---|---|
APIDataSet | New APIDataSet |
Exceptions
Type | Condition |
---|---|
APIException |
NewDataSet(Guid, String, APIDataSetSettings)
Registers a virtual DataSet to your client application. Does not save to file unless committed to AntFarm.
Declaration
public static APIDataSet NewDataSet(Guid clientId, string name, APIDataSetSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Name of the APIDataSet |
APIDataSetSettings | settings | Settings of the APIDataSet |
Returns
Type | Description |
---|---|
APIDataSet | New APIDataSet |
Exceptions
Type | Condition |
---|---|
APIException |
NewDataSetSettings(Guid, ObjectType, Boolean, APIColour, Double)
Registers a new virutal DataSetSettings to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Declaration
public static APIDataSetSettings NewDataSetSettings(Guid clientId, ObjectType filter, bool isClosed, APIColour colour, double rowHeight)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
Rhino.DocObjects.ObjectType | filter | Object filter for APIDataSet based on ObjectType |
System.Boolean | isClosed | Flag if DataSet is shown in AntFarm UI |
APIColour | colour | DataSet display colour in AntFarm UI |
System.Double | rowHeight | Default row height of DataGrid in AntFarm UI |
Returns
Type | Description |
---|---|
APIDataSetSettings | New APIDataSetSettings |
NewElement(Guid, String, List<APIProperty>)
Registers a new virutal Element to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Declaration
public static APIElement NewElement(Guid clientId, string name, List<APIProperty> properties)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Element name |
System.Collections.Generic.List<APIProperty> | properties | List of Properties to add to Element |
Returns
Type | Description |
---|---|
APIElement | New APIElement |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid. |
NewProperty(Guid, String, APIPropertyType, Object)
Registers a new virutal Property to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Declaration
public static APIProperty NewProperty(Guid clientId, string name, APIPropertyType type, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | Property name |
APIPropertyType | type | Property type (see APIPropertyType) |
System.Object | value | Value assigned to property |
Returns
Type | Description |
---|---|
APIProperty | New APIProperty |
NewPropertyType(Guid, String, APIPropertyBaseType)
Registers a new virutal PropertyType to your client application. Does not save to file unless a DatSet is commited to AntFarm.
Declaration
public static APIPropertyType NewPropertyType(Guid clientId, string name, APIPropertyBaseType baseType)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | PropertyType name |
APIPropertyBaseType | baseType | Base type of PropertyType |
Returns
Type | Description |
---|---|
APIPropertyType | New APIPropertyType |
Exceptions
Type | Condition |
---|---|
APIException | Thrown when one of the arguments provided to this method is not valid. |
NewRecord(Guid, Dictionary<APIAttribute, Object>, Object)
Registers a new virutal Record to your client application. Does not save to file unless a DatSet or Rhino Object is commited to AntFarm.
Declaration
public static APIRecord NewRecord(Guid id, Dictionary<APIAttribute, object> values, object rhinoObject)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Rhino Object id |
System.Collections.Generic.Dictionary<APIAttribute, System.Object> | values | Values in this row referenced to the Attribute column |
System.Object | rhinoObject | The rhino object / reference object |
Returns
Type | Description |
---|---|
APIRecord | New APIRecord |
NewSchema(Guid, String, Guid, APIColour, Boolean, String, APIColour)
Declaration
public static APISchema NewSchema(Guid clientId, string name, Guid id, APIColour colour, bool createLayer, string layerName, APIColour layerColour)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
System.String | name | DataSet name |
System.Guid | id | DataSet Id |
APIColour | colour | DataSet colour |
System.Boolean | createLayer | Flag if |
System.String | layerName | |
APIColour | layerColour |
Returns
Type | Description |
---|---|
APISchema |
RegisterPlugin(String, APIColour)
Registers a new client to AntFarm.
Declaration
public static Guid RegisterPlugin(string name, APIColour colour = default(APIColour))
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the client |
APIColour | colour | Colour of the client (optional) |
Returns
Type | Description |
---|---|
System.Guid | New or existing client Id |
Examples
Guid id = AntFarmAPI.RegisterPlugin("YourPlugInName", default);
Exceptions
Type | Condition |
---|---|
APIException |
UnRegisterPlugin(Guid)
Unregisters an API client from AntFarm
Declaration
public static bool UnRegisterPlugin(Guid clientId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | clientId | Valid Id of the registered client (see RegisterPlugin(String, APIColour)). |
Returns
Type | Description | ||||
---|---|---|---|---|---|
System.Boolean |
|
Examples
bool success = AntFarmAPI.UnRegisterPlugin(yourClientId);
Exceptions
Type | Condition |
---|---|
APIException |
Events
DataEventHandler
Declaration
public static event APIEvent.APIEventHandler DataEventHandler
Event Type
Type | Description |
---|---|
APIEvent.APIEventHandler | Public API data event handler |
Examples
AntFarmAPI.DataEventHandler += new APIEvent.APIEventHandler(OnAPIDataEvent);
private void OnAPIDataEvent(object sender, APIEventArgs e)
{
// Add your code here.
}