RobotStudio event

Attatching WorkObject to Smart Component

Hi,

I am creating a smart component[SC] using code behind. I create a work object of type RsWorkObject and use the SC's 'Attach' property to attach the workobject to the SC. After the SC is added to the station, and when I move it from its initial position to another position, I see that the SC moves, but the workobject doesn't. 

How to ensure that the WObj is attached to the SC using code behind ?

My SC contains a mechanism, signals and properties.

Sample Code Snippet (as I am currently doing):

 _workObject = new RsWorkObject();
                _workObject.Name = "wobjName";
                _workObject.RobotHold = false;
                _workObject.Synchronize = true;
                _workObject.StorageType = RapidStorageType.TaskPersistent;


//WorkObjectModel gives the position of the workobject
                _workObject.UserFrame.X = mt_station.specificMachine.MachineGM.WorkObjectModel.X;
                _workObject.UserFrame.Y = mt_station.specificMachine.MachineGM.WorkObjectModel.Y;
                _workObject.UserFrame.Z = mt_station.specificMachine.MachineGM.WorkObjectModel.Z;
                _workObject.UserFrame.RX = mt_station.specificMachine.MachineGM.WorkObjectModel.RX;// *System.Math.PI / 180;
                _workObject.UserFrame.RY = mt_station.specificMachine.MachineGM.WorkObjectModel.RY;// *System.Math.PI / 180;
                _workObject.UserFrame.RZ = mt_station.specificMachine.MachineGM.WorkObjectModel.RZ;// *System.Math.PI / 180;
               
           Helper.ActiveTask.DataDeclarations.Add(_workObject);


       // and attach the workobject to the smart component
            SC.Attach(_workObject, false, Matrix4.Identity);