//get 3d function from selection
SelectionSet oSelectionSet = new SelectionSet();
Function3D oMainFunction = oSelectionSet.Selection[0] as Function3D;
//set accessory data
String strPartNumber = "SE.GV3A01";
String strPartVariant = "1";
//set accessory placement data
String strAccessoryPlacement = "SE.GV";
String strInstallationVariant = "Top";
//insert accessory
List<Placement3D> listCreatedPlacements = new List<Placement3D>();
bool bPlacedAutomatically = new DeviceService().InsertAccessory3D(
        oMainFunction, 
        strPartNumber, 
        strPartVariant, 
        strAccessoryPlacement, 
        strInstallationVariant, 
        false, 
        listCreatedPlacements);
//evaluates the full name for all placed functions and interruption points
new NameService3D(oMainFunction.InstallationSpace).EvaluateAndSetAllNames();
//if accessory not placed automatically then location needs to be set manually
if (bPlacedAutomatically == false)
{
    foreach (Placement3D oPlacement in listCreatedPlacements)
    {
        //set parent for accessory
        oPlacement.SetParent(oMainFunction, false);
        //calculate transformation
        Matrix3D oTransformation = new Matrix3D();
        // TODO
        //set location is 3d space relatively to parent function
        oPlacement.RelativeTransformation = oTransformation;
    }
}