SDK load SmartComponent

I have created a GraphicComponent group in an addin and wish to programmatically to add a PositionSensor from the standard RS SmartComponent Library. How do I do this and paramatise it (ie set length and size)

Correction I meant a Line Sensor

Hi Simon, try this:

            GraphicComponentGroup myGroup = ...
            var libPath = Path.Combine(ApiConfiguration.ABBLibraryDirectory, "Components", "LineSensor.rslib");
            var library = GraphicComponentLibrary.Load(libPath, true);
            var lineSensor = library.RootComponent.CopyInstance() as SmartComponent;
            myGroup.GraphicComponents.Add(lineSensor);

The CopyInstance() call is needed to create a modifiable copy of the component.

Regards,
Johannes