Solid Edge Draft Type Library
ReplaceBackground Method
Solid Edge Draft Type Library > Sheet Object : ReplaceBackground Method
This is the draft file name from which the content is to be copied.
This is the input background sheet.
Description
Replaces the content of input background sheet on the sheet.
Syntax
Visual Basic
Public Sub ReplaceBackground( _
   ByVal DraftFileName As String, _
   ByVal BackgroundSheetName As String _
) 
Parameters
DraftFileName
This is the draft file name from which the content is to be copied.
BackgroundSheetName
This is the input background sheet.
Remarks
Both the inputs are mandatory and this API should be called using background sheet object as shown in below sample. This API should not be called on the working sheet object
Example
Imports System.IO
Imports System.Runtime.InteropServices

Module Module1

    Sub Main()
        Dim objSEApplication As SolidEdgeFramework.Application = Nothing
        Dim objDoc As SolidEdgeDraft.DraftDocument = Nothing
        Dim objSheet As SolidEdgeDraft.Sheet = Nothing
        Dim SEInstallDir As DirectoryInfo

        Try
            ' Start Solid Edge
            objSEApplication = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"))
            objSEApplication.Visible = True
            SEInstallDir = GetTrainingFolder()
            'open the draft document mentioned from available files.
            objDoc = objSEApplication.Documents.Open(SEInstallDir.FullName + "\sbddaan.dft")

            'Get background sheet
            objSheet = objDoc.ActiveSheet.Background

            objSheet.ReplaceBackground(SEInstallDir.FullName + "\stodcmm.dft", "A4-Sheet")

        Catch ex As Exception
            Console.WriteLine(ex.ToString)
        End Try
    End Sub
    Function GetTrainingFolder() As DirectoryInfo
        Dim objInstallData As SEInstallDataLib.SEInstallData = Nothing
        Dim objInstallFolder As DirectoryInfo = Nothing
        Dim objTrainingFolder As DirectoryInfo = Nothing

        Try
            objInstallData = New SEInstallDataLib.SEInstallData
            objInstallFolder = New DirectoryInfo(objInstallData.GetInstalledPath())
            objTrainingFolder = New DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"))
        Catch
        Finally
            If Not (objInstallData Is Nothing) Then
                Marshal.FinalReleaseComObject(objInstallData)
                objInstallData = Nothing
            End If
        End Try

        Return objTrainingFolder
    End Function


End Module
using System.IO;
using System.Runtime.InteropServices;

internal static class Module1
{

    public static void Main()
    {
        SolidEdgeFramework.Application objSEApplication = null;
        SolidEdgeDraft.DraftDocument objDoc = null;
        SolidEdgeDraft.Sheet objSheet = null;
        DirectoryInfo SEInstallDir = null;

        try
        {
            // Start Solid Edge
            objSEApplication = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"));
            objSEApplication.Visible = true;
            SEInstallDir = GetTrainingFolder();
            //open the draft document mentioned from available files.
            objDoc = objSEApplication.Documents.Open(SEInstallDir.FullName + "\\sbddaan.dft");

            //Get background sheet
            objSheet = objDoc.ActiveSheet.Background;

            objSheet.ReplaceBackground(SEInstallDir.FullName + "\\stodcmm.dft", "A4-Sheet");

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
    public static DirectoryInfo GetTrainingFolder()
    {
        SEInstallDataLib.SEInstallData objInstallData = null;
        DirectoryInfo objInstallFolder = null;
        DirectoryInfo objTrainingFolder = null;

        try
        {
            objInstallData = new SEInstallDataLib.SEInstallData();
            objInstallFolder = new DirectoryInfo(objInstallData.GetInstalledPath());
            objTrainingFolder = new DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"));
        }
        catch
        {
        }
        finally
        {
            if (objInstallData != null)
            {
                Marshal.FinalReleaseComObject(objInstallData);
                objInstallData = null;
            }
        }

        return objTrainingFolder;
    }


}
See Also

Sheet Object  | Sheet Members