Hi,
I am using Inventor ETO 2014 and have a list of List of Points defined in one of the ETO designs:
Rule controlPoints as List = _
{Point(1.0, 2.0, 3.0), _
Point(4.0, 5.0, 6.0), _
Point(7.0, 8.0, 9.0)}
I also have a custom .NET library – it has a class whose constructor accepts a list of points.
Is my understanding of the ETO to .NET mapping correct:
List maps to Object array
Point maps to Autodesk.Intent.Services.Point
If that’s right, should my method argument be an Object array the contents of which are expected to be Autodesk.Intent.Services.Point objects? Is something like this expected to work? (I haven’t tried this yet, just wanted to make sure this is the supported way of passing data across to .NET)
public Cable(….., Object[] controlPoints)
{
try
{
………..
………..
for (int routePtCt = 0; routePtCt < controlPoints.Length; routePtCt++)
{
Autodesk.Intent.Services.Point routePoint = (Autodesk.Intent.Services.Point)controlPoints[routePtCt];
……….
}
………..
………..
}
………..
}
Thanks,
-Venkatesh.
Hi Venkatesh,
If IntentAPI is referenced from your C# code, then the following code will allow you to access the Points in a List.
I provide only "good" workflow -- the real code should behave appropriately, if controlPoints Rule is not a List, and also if the elements of the List are not all Points:
// Evaluate Rule ControlPoint (assuming it is defined on Root Part) Value controlPoints = Autodesk.Intent.IntentAPI.Instance.ActiveRoot["controlPoints"]; // Ensure the result is a List if (controlPoints.DataType == DataType.List) { // Implicit conversion to array of Values Value[] points = controlPoints; // Iterate over collection foreach (Value pt in points) { // Ensure that each element is a Point if (pt.DataType == DataType.Point) { // Implicit cast Autodesk.Intent.Point point = pt; // ... } } }
Thank you very much for the answer.
It wasn't obvious to me which assembly I had to add a reference to that contained the definition of the Intent Point class. This is defined in Autodesk.IntentBase.dll. Autodesk.Intent.API provides access to the Intent API. Adding a reference to both gets me what I need. Sorry, if this is obvious to others, I'm not familiar with the Intent API and just learning to use it.
-Venkatesh.