But if I try to use that call in the code, the compiler does not recognize “Revolution” class. What should I import to get the “IsConnected” field? Is there any way to get this field?
EDIT:
I could not link the Revolution.dll to the project references. It says to check if the file is accessible, or if it’s a valid assembly or a COM component.
Just cast you IBehavior to ISimInterface instead, it has that IsConnected property.
The wrapper classes are internal, you should only use the interfaces defined in Create3D.Shared.
Unhandled exception occurred:System.InvalidCastException: Unable to cast object of type ‘VisualComponents.Revolution.OneWayPathWrapper’ to type ‘VisualComponents.Create3D.ISimInterface’.
Not every behavior is an “interface” behavior so you can’t cast all of them to ISimInterface.
foreach (IBehavior behavior in comp.Behaviors)
{
// "safe cast" that returns null if cast fails.
ISimInterface interfaceBehavior = behavior as ISimInterface;
if (interfaceBehavior != null &&
interfaceBehavior.Name.ToLower().Contains("conn") &&
interfaceBehavior.IsConnected)
{
// This behavior is of type ISimInterface, its name contains "conn", and it is connected.
}
}
This is pretty basic C# stuff you can easily learn from online tutorials. VC .NET API reference you can find from the help tab of the software.