# Attatching WorkObject to Smart Component

**URL:** https://tech-community.robotics.abb.com/t/attatching-workobject-to-smart-component/4988
**Category:** Developer Tools
**Created:** [July 18, 2012, 5:18am UTC](https://tech-community.robotics.abb.com/t/attatching-workobject-to-smart-component/4988 "2012-07-18T05:18:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Bhavana\_K](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@Bhavana\_K](https://tech-community.robotics.abb.com/u/Bhavana_K)
#### Post date: [July 18, 2012, 5:18am UTC](https://tech-community.robotics.abb.com/t/attatching-workobject-to-smart-component/4988/1 "2012-07-18T05:18:07Z")

</div>

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);
