Anark Core SDK
Loading...
Searching...
No Matches
Anark.CoreSdkApi.SdkApi Class Reference

More...

Inheritance diagram for Anark.CoreSdkApi.SdkApi:
Anark.CoreSdkApi.ISdkApi

Public Member Functions

 SdkApi (ICadDocument document, IScriptDocument recipe, int actionId)
 Initialize a new api object.
void Dispose ()
SdkAnnotationInfo AddAnnotation (ISdkAnnotation annotation, ISdkVertex3D location, ISdkVector3D orientation, ISdkVector3D planeNormal, float scale, float layerDepthFactor=0.0001f)
 Add an annotation.
Parameters
annotationThe annotation to add - the origin of the 2D coordinate system of the annotation will be placed relative to the specified location.
locationThe annotation's location in 3D space.
orientationThe orientation vector of the annotation - this is relative to the specified location.
planeNormalThe normal of the plane in which the annotation exists.
scaleThe scale to apply to the annotation geometry. 1.0f is 100% (no change), 2.0f will scale the annotation twice as large, etc.
layerDepthFactorThe difference in depth between layers of geometry, as a proportion of the geometry's total height. 0.0001 by default
Returns
Information about the newly created annotation.

void RemoveMyAnnotations (ISdkEntityHandle[] annotationHandles)
 Removes annotations that have been created by your plug-in. This will not remove annotations from the imported 3D data and this will not remove annotations created by other plug-ins. This will remove the annotations from all user-defined views.
Parameters
annotationHandlesAn array of annotation handles. The handles must be handles to the annotation definition rather than the annotation occurrence. This would typically be the results of a query searching for SdkEntityType.Pmi.

SdkAnnotationInfo.DefinitionHandle SdkEntityType.Pmi

ISdkView[] GetViews ()
 Get all views.
Returns
An array of view objects.

int GetViewUpdateCount (ISdkView view)
 Gets the view update count, which is a counter that is incremented whenever there is any update to a view. It can be used for an incremental update mechanism where you only update views that have changed, by comparing this number against the value at your last plug-in execution.
Parameters
viewThe view.
Returns
Returns the update count or -1 if the view does not exist.

void AddUserEditableView (ISdkView view)
 Adds a new view to the list of user-authored views. Will throw an exception if you target entities under collapsed assemblies or add a view with a duplicate name.
Parameters
viewThe fully specified view definition.

object GetWorkspaceAttribute (string attributeName)
 Get a workspace attribute value.
Parameters
attributeNameThe name of the attribute.
Returns
The attribute value.

void SetWorkspaceAttribute (string attributeName, object attributeValue)
 Add or overwrite a workspace attribute value.
Parameters
attributeNameThe name of the attribute (will be published, used in the UI, etc.).
attributeValueThe value of the attribute.

ISdkEntityHandle[] Search (ISdkQueryExpression query, SdkEntityType resultEntityType=SdkEntityType.Invalid)
 Search for entities with a query expression. This returns the same results as the Query functionality in Anark Core Workstation.
Parameters
queryThe query expression.
resultEntityTypeThe resulting entity type to return. Omit this argument to directly return the entities from the query. Pass a different entity type to perform a conversion, where applicable. For example, when searching for CAD entities, the default entity return type will be occurrences, but this could be converted to a distinct collection of components.
Returns
An array of entities. The array will be empty if nothing is found.

ISdkEntityHandle[] ConvertEntityHandles (ISdkEntityHandle[] sourceHandles, SdkEntityType targetEntityType)
 Follows the object references to "convert" entity handles to the desired target entity type. For example, you can convert a component occurrence handle to a component instance and/or a component. The reverse is not true because it is often ambiguous. This can be useful if you have search results for component instances and you need to reference the actual component (part/assembly) for one or more of those instances. Also applies to PMI, etc.
Parameters
sourceHandlesThe source entity handles.
targetEntityTypeThe desired type of entity handle to return.
Returns
Distinct set of entity handles. Returns an empty array when the conversion is not possible (cannot convert PMI occurrence to component for example).

object GetEntityAttribute (ISdkEntityHandle entityHandle, string attributeName)
 Get an attribute value from an entity.
Parameters
entityHandleThe entity containing the attribute to retrieve
attributeNameThe name of the attribute to retrieve
Returns
The attribute value

void SetEntityAttribute (ISdkEntityHandle entityHandle, string attributeName, object attributeValue)
 Set an entity attribute value. Creates a new attribute if the attribute does not already exist.
Parameters
entityHandleThe entity to modify
attributeNameThe name of the attribute to set
attributeValueThe value of the attribute

string[] GetAttributeNames (SdkEntityType entityType)
 Get the available attribute names for a specified entity type.
Parameters
entityTypeThe entity type
Returns
Array of attribute names.

void RemoveMyAttributes ()
 Removes all attributes that were created by the caller. Includes workspace attributes and attributes in other entities. Does not revert any attribute values that have been set for attributes that were not created by the caller.
ISdk3DBoundingBox GetBoundingBox (ISdkEntityHandle entityHandle)
 Gets the 3D bounding box of a part or annotation, in the local coordinate system of the part or annotation.
Parameters
entityHandleThe handle to the part or annotation.
Returns
A 3D bounding box

ISdkVertex3D[] GetPartVertices (ISdkEntityHandle entityHandle)
 Gets the 3D mesh points for a part. Note that this can be a relatively expensive operation - see GetBoundingBox if you only need the part bounding box. The points are returned in the part's local coordinate system.
Parameters
entityHandleThe handle to a part.
Returns
An array of 3D vertices.

Dictionary< ISdkEntityHandle, float > FindObjectsByLocation (IEnumerable< ISdkEntityHandle > visibleEntities, ISdkVertex3D objectLocationInWorldCoords, float maxDistance=float.MaxValue, SdkEntityType resultEntityType=SdkEntityType.Component)
 Provides a point-to-solid interference clash test to identify parts or part occurrences in which a specific point is located. Identifies all objects that are nearer than maxDistance from objectLocation and their associated observed distances.
Parameters
visibleEntitiesEntities to be considered "visible" - i.e. those entities which should take part in the interference clash test.
objectLocationThe start point of all rays used to intersect parts in the model.
maxDistanceThe maximum distance to consider when finding close objects.
resultEntityTypeThe resulting entity type to return. Valid types are SdkEntityType.Component (returns matching part definitions) and SdkEntityType.ComponentOccurrence (returns matching part occurrences). Omit this parameter to return part definitions.
Returns
A Dictionary of part or occurrence handles and associated observed closest intersection distances from objectLocation. The Dictionary will be empty if nothing is found.

ISdkMatrix4X4 GetTransform (ISdkEntityHandle entityHandle)
 Gets the current 3D transform for a part or assembly instance.
Parameters
entityHandleA part instance or an assembly instance.
Returns
The 3D transformation matrix.

void SetTransform (ISdkEntityHandle entityHandle, ISdkMatrix4X4 transformMatrix)
 Updates the 3D transform on a part or assembly instance.
Parameters
entityHandleA part instance or an assembly instance.
transformMatrixThe 3D transform to apply.

ISdk3DGeometry GetGeometry (ISdkEntityHandle entityHandle)
 Gets the geometric representation of a Supplemental Geometry Definition or Occurrence Given a Supplemental Definition Entity, Local coordinates will be returned. Given a Supplemental Geometry Occurrence, Global coordinates for that particular occurrence will be returned.
void AddVisibleOccurrencesToView (ISdkView view, IEnumerable< ISdkEntityHandle > handles)
 Show specified 3D entities in a view that has been authored in Anark Core Workstation. This replaces any prior set of 3D entities for the specified view that were previously made visible in a call to AddVisibleOccurrencesToView with the current set of 3D entity handles (i.e. this method cannot be used to incrementally add an additional visibility state). Visibility states that were specified by Anark Core Workstation users will be retained (not overwritten). The modifications will be retained in the Anark Core Recipe. Limitations: the view cannot be an imported view, and the entities to make visible must be entities that have been created via this SDK API.
Parameters
viewThe view to modify.
handlesThe occurrence handles of the 3D entities to show in the view.

Detailed Description

Constructor & Destructor Documentation

◆ SdkApi()

Anark.CoreSdkApi.SdkApi.SdkApi ( ICadDocument document,
IScriptDocument recipe,
int actionId )
inline

Initialize a new api object.

Parameters
documentInternal Anark Core data structure.
recipeInternal Anark Core data structure.
actionIdAction Id from the recipe.

Member Function Documentation

◆ AddAnnotation()

SdkAnnotationInfo Anark.CoreSdkApi.SdkApi.AddAnnotation ( ISdkAnnotation annotation,
ISdkVertex3D location,
ISdkVector3D orientation,
ISdkVector3D planeNormal,
float scale,
float layerDepthFactor = 0::0001f )
inline

Add an annotation.

Parameters
annotationThe annotation to add - the origin of the 2D coordinate system of the annotation will be placed relative to the specified location.
locationThe annotation's location in 3D space.
orientationThe orientation vector of the annotation - this is relative to the specified location.
planeNormalThe normal of the plane in which the annotation exists.
scaleThe scale to apply to the annotation geometry. 1.0f is 100% (no change), 2.0f will scale the annotation twice as large, etc.
layerDepthFactorThe difference in depth between layers of geometry, as a proportion of the geometry's total height. 0.0001 by default
Returns
Information about the newly created annotation.

Implements Anark.CoreSdkApi.ISdkApi.

◆ AddUserEditableView()

void Anark.CoreSdkApi.SdkApi.AddUserEditableView ( ISdkView view)
inline

Adds a new view to the list of user-authored views. Will throw an exception if you target entities under collapsed assemblies or add a view with a duplicate name.

Parameters
viewThe fully specified view definition.

Implements Anark.CoreSdkApi.ISdkApi.

◆ AddVisibleOccurrencesToView()

void Anark.CoreSdkApi.SdkApi.AddVisibleOccurrencesToView ( ISdkView view,
IEnumerable< ISdkEntityHandle > handles )
inline

Show specified 3D entities in a view that has been authored in Anark Core Workstation. This replaces any prior set of 3D entities for the specified view that were previously made visible in a call to AddVisibleOccurrencesToView with the current set of 3D entity handles (i.e. this method cannot be used to incrementally add an additional visibility state). Visibility states that were specified by Anark Core Workstation users will be retained (not overwritten). The modifications will be retained in the Anark Core Recipe. Limitations: the view cannot be an imported view, and the entities to make visible must be entities that have been created via this SDK API.

Parameters
viewThe view to modify.
handlesThe occurrence handles of the 3D entities to show in the view.

Implements Anark.CoreSdkApi.ISdkApi.

◆ ConvertEntityHandles()

ISdkEntityHandle[] Anark.CoreSdkApi.SdkApi.ConvertEntityHandles ( ISdkEntityHandle[] sourceHandles,
SdkEntityType targetEntityType )
inline

Follows the object references to "convert" entity handles to the desired target entity type. For example, you can convert a component occurrence handle to a component instance and/or a component. The reverse is not true because it is often ambiguous. This can be useful if you have search results for component instances and you need to reference the actual component (part/assembly) for one or more of those instances. Also applies to PMI, etc.

Parameters
sourceHandlesThe source entity handles.
targetEntityTypeThe desired type of entity handle to return.
Returns
Distinct set of entity handles. Returns an empty array when the conversion is not possible (cannot convert PMI occurrence to component for example).

Implements Anark.CoreSdkApi.ISdkApi.

◆ Dispose()

void Anark.CoreSdkApi.SdkApi.Dispose ( )
inline

◆ FindObjectsByLocation()

Dictionary< ISdkEntityHandle, float > Anark.CoreSdkApi.SdkApi.FindObjectsByLocation ( IEnumerable< ISdkEntityHandle > visibleEntities,
ISdkVertex3D objectLocationInWorldCoords,
float maxDistance = float::MaxValue,
SdkEntityType resultEntityType = SdkEntityType::Component )
inline

Provides a point-to-solid interference clash test to identify parts or part occurrences in which a specific point is located. Identifies all objects that are nearer than maxDistance from objectLocation and their associated observed distances.

Parameters
visibleEntitiesEntities to be considered "visible" - i.e. those entities which should take part in the interference clash test.
objectLocationThe start point of all rays used to intersect parts in the model.
maxDistanceThe maximum distance to consider when finding close objects.
resultEntityTypeThe resulting entity type to return. Valid types are SdkEntityType.Component (returns matching part definitions) and SdkEntityType.ComponentOccurrence (returns matching part occurrences). Omit this parameter to return part definitions.
Returns
A Dictionary of part or occurrence handles and associated observed closest intersection distances from objectLocation. The Dictionary will be empty if nothing is found.

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetAttributeNames()

string[] Anark.CoreSdkApi.SdkApi.GetAttributeNames ( SdkEntityType entityType)
inline

Get the available attribute names for a specified entity type.

Parameters
entityTypeThe entity type
Returns
Array of attribute names.

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetBoundingBox()

ISdk3DBoundingBox Anark.CoreSdkApi.SdkApi.GetBoundingBox ( ISdkEntityHandle entityHandle)
inline

Gets the 3D bounding box of a part or annotation, in the local coordinate system of the part or annotation.

Parameters
entityHandleThe handle to the part or annotation.
Returns
A 3D bounding box

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetEntityAttribute()

object Anark.CoreSdkApi.SdkApi.GetEntityAttribute ( ISdkEntityHandle entityHandle,
string attributeName )
inline

Get an attribute value from an entity.

Parameters
entityHandleThe entity containing the attribute to retrieve
attributeNameThe name of the attribute to retrieve
Returns
The attribute value

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetGeometry()

ISdk3DGeometry Anark.CoreSdkApi.SdkApi.GetGeometry ( ISdkEntityHandle entityHandle)
inline

Gets the geometric representation of a Supplemental Geometry Definition or Occurrence Given a Supplemental Definition Entity, Local coordinates will be returned. Given a Supplemental Geometry Occurrence, Global coordinates for that particular occurrence will be returned.

Parameters
entityHandleThe Supplemental Geometry Definition or Occurrence
Returns
The geometric representation of the Supplemental Geometry

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetPartVertices()

ISdkVertex3D[] Anark.CoreSdkApi.SdkApi.GetPartVertices ( ISdkEntityHandle entityHandle)
inline

Gets the 3D mesh points for a part. Note that this can be a relatively expensive operation - see GetBoundingBox if you only need the part bounding box. The points are returned in the part's local coordinate system.

Parameters
entityHandleThe handle to a part.
Returns
An array of 3D vertices.

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetTransform()

ISdkMatrix4X4 Anark.CoreSdkApi.SdkApi.GetTransform ( ISdkEntityHandle entityHandle)
inline

Gets the current 3D transform for a part or assembly instance.

Parameters
entityHandleA part instance or an assembly instance.
Returns
The 3D transformation matrix.

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetViews()

ISdkView[] Anark.CoreSdkApi.SdkApi.GetViews ( )
inline

Get all views.

Returns
An array of view objects.

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetViewUpdateCount()

int Anark.CoreSdkApi.SdkApi.GetViewUpdateCount ( ISdkView view)
inline

Gets the view update count, which is a counter that is incremented whenever there is any update to a view. It can be used for an incremental update mechanism where you only update views that have changed, by comparing this number against the value at your last plug-in execution.

Parameters
viewThe view.
Returns
Returns the update count or -1 if the view does not exist.

Implements Anark.CoreSdkApi.ISdkApi.

◆ GetWorkspaceAttribute()

object Anark.CoreSdkApi.SdkApi.GetWorkspaceAttribute ( string attributeName)
inline

Get a workspace attribute value.

Parameters
attributeNameThe name of the attribute.
Returns
The attribute value.

Implements Anark.CoreSdkApi.ISdkApi.

◆ RemoveMyAnnotations()

void Anark.CoreSdkApi.SdkApi.RemoveMyAnnotations ( ISdkEntityHandle[] annotationHandles)
inline

Removes annotations that have been created by your plug-in. This will not remove annotations from the imported 3D data and this will not remove annotations created by other plug-ins. This will remove the annotations from all user-defined views.

Parameters
annotationHandlesAn array of annotation handles. The handles must be handles to the annotation definition rather than the annotation occurrence. This would typically be the results of a query searching for SdkEntityType.Pmi.

SdkAnnotationInfo.DefinitionHandle SdkEntityType.Pmi

Implements Anark.CoreSdkApi.ISdkApi.

◆ RemoveMyAttributes()

void Anark.CoreSdkApi.SdkApi.RemoveMyAttributes ( )
inline

Removes all attributes that were created by the caller. Includes workspace attributes and attributes in other entities. Does not revert any attribute values that have been set for attributes that were not created by the caller.

Implements Anark.CoreSdkApi.ISdkApi.

◆ Search()

ISdkEntityHandle[] Anark.CoreSdkApi.SdkApi.Search ( ISdkQueryExpression query,
SdkEntityType resultEntityType = SdkEntityType::Invalid )
inline

Search for entities with a query expression. This returns the same results as the Query functionality in Anark Core Workstation.

Parameters
queryThe query expression.
resultEntityTypeThe resulting entity type to return. Omit this argument to directly return the entities from the query. Pass a different entity type to perform a conversion, where applicable. For example, when searching for CAD entities, the default entity return type will be occurrences, but this could be converted to a distinct collection of components.
Returns
An array of entities. The array will be empty if nothing is found.

Implements Anark.CoreSdkApi.ISdkApi.

◆ SetEntityAttribute()

void Anark.CoreSdkApi.SdkApi.SetEntityAttribute ( ISdkEntityHandle entityHandle,
string attributeName,
object attributeValue )
inline

Set an entity attribute value. Creates a new attribute if the attribute does not already exist.

Parameters
entityHandleThe entity to modify
attributeNameThe name of the attribute to set
attributeValueThe value of the attribute

Implements Anark.CoreSdkApi.ISdkApi.

◆ SetTransform()

void Anark.CoreSdkApi.SdkApi.SetTransform ( ISdkEntityHandle entityHandle,
ISdkMatrix4X4 transformMatrix )
inline

Updates the 3D transform on a part or assembly instance.

Parameters
entityHandleA part instance or an assembly instance.
transformMatrixThe 3D transform to apply.

Implements Anark.CoreSdkApi.ISdkApi.

◆ SetWorkspaceAttribute()

void Anark.CoreSdkApi.SdkApi.SetWorkspaceAttribute ( string attributeName,
object attributeValue )
inline

Add or overwrite a workspace attribute value.

Parameters
attributeNameThe name of the attribute (will be published, used in the UI, etc.).
attributeValueThe value of the attribute.

Implements Anark.CoreSdkApi.ISdkApi.