Replaces the content of input background sheet on the sheet.
Visual Basic |
---|
Public Sub ReplaceBackground( _ ByVal DraftFileName As String, _ ByVal BackgroundSheetName As String _ ) |
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; } }