Solid Edge Assembly Type Library
SaveAsEcad Method
Specifies the export format for the document. This is the document which we select from drop down list available on "Save As ECAD" dialogue box. e.g "Bentley - promis-e"
Location for the component document. You can save the document to .CMP or .CMP_XML format.
Location for the connection document. You can save the document to .CON or .CON_XML format.
Description
Saves wire harness component and connection list files for input to an Ecad system
Syntax
Visual Basic
Public Sub SaveAsEcad( _
   ByRef HarnessSaveAsEcadStatus As HarnessSaveAsEcadStatusConstants, _
   ByVal CompanyName As String, _
   Optional ByVal ComponentFilePath As Variant, _
   Optional ByVal ConnectionFilePath As Variant _
) 
Parameters
HarnessSaveAsEcadStatus
ValueDescription
seHarnessSaveAsEcadStatus_FailedThe Save As ECAD operation has failed.
seHarnessSaveAsEcadStatus_FailedBadArgsThe Save As ECAD operation has failed. The SaveAsEcad api argument list is invalid.
seHarnessSaveAsEcadStatus_FailedBadConfigThe Save As ECAD operation has failed. The document format is invalid.
seHarnessSaveAsEcadStatus_FailedBothThe Save As ECAD operation has failed. The component and connection document will not be created.
seHarnessSaveAsEcadStatus_FailedCompsThe Save As ECAD operation has failed. A component document will not be created.
seHarnessSaveAsEcadStatus_FailedConnsThe Save As ECAD operation has failed. A connection document will not be created.
seHarnessSaveAsEcadStatus_FailedDupCompsThis harness contains duplicate components. The component and connection document will not be created.
seHarnessSaveAsEcadStatus_FailedDupConnsThis harness contains duplicate connections. A connection document will not be created.
seHarnessSaveAsEcadStatus_FailedNoCompsThis harness contains no components. A component document will not be created.
seHarnessSaveAsEcadStatus_FailedNoConnsThis harness contains no connections. A connection document will not be created.
seHarnessSaveAsEcadStatus_SuccessThe input documents for the ECAD system have been successfully generated.
CompanyName
Specifies the export format for the document. This is the document which we select from drop down list available on "Save As ECAD" dialogue box. e.g "Bentley - promis-e"
ComponentFilePath
Location for the component document. You can save the document to .CMP or .CMP_XML format.
ConnectionFilePath
Location for the connection document. You can save the document to .CON or .CON_XML format.
Example
Imports System.Runtime.InteropServices
Imports System.IO

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim objSEApp As SolidEdgeFramework.Application = Nothing
        Dim objAsmDoc As SolidEdgeAssembly.AssemblyDocument = Nothing
        Dim objHarnesses As SolidEdgeAssembly.Harnesses = Nothing
        Dim objHarness As SolidEdgeAssembly.Harness = Nothing
        Dim SEInstallDir As DirectoryInfo
        Dim strPath1, strPath2 As String
        Dim Occ1, Occ2 As String
        Dim strCompanyName As String = "Bentley - promis-e"
        
        Try
            ' Get  SE Application object.
            Try
                objSEApp = Marshal.GetActiveObject("SolidEdge.Application")
            Catch ex As Exception
                objSEApp = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"))
                objSEApp.DisplayAlerts = True
                objSEApp.Visible = True
            End Try
            'Get Path of Training folder
            SEInstallDir = GetTrainingFolder()
            strPath1 = SEInstallDir.FullName + "\Wiring Harness\seeabwh2.cmp"
            strPath2 = SEInstallDir.FullName + "\Wiring Harness\seeabwh2.con"
            Occ1 = SEInstallDir.FullName + "\Wiring Harness\gauge3.par"
            Occ2 = SEInstallDir.FullName + "\Wiring Harness\plug4.par"
            'Add new assembly file
            objAsmDoc = objSEApp.Documents.Add("SolidEdge.AssemblyDocument")
            objAsmDoc.Occurrences.AddByFilename(Occ1)
            objAsmDoc.Occurrences.AddByFilename(Occ2)
            objHarnesses = objAsmDoc.Harnesses
            objHarnesses.CreateFromNetlistImporter(strCompanyName, strPath1, strPath2)
            objHarness = objHarnesses.Item(1)
            objHarness.SaveAsEcad(SolidEdgeAssembly.HarnessSaveAsEcadStatusConstants.seHarnessSaveAsEcadStatus_Success, strCompanyName, strPath1, strPath2)
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            ' USER DISPLAY
            ' Release objects
            objSEApp = Nothing
            objAsmDoc = Nothing
        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 Class
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;

public class Form1
{

    private void Button1_Click(object sender, EventArgs e)
    {
        SolidEdgeFramework.Application objSEApp = null;
        SolidEdgeAssembly.AssemblyDocument objAsmDoc = null;
        SolidEdgeAssembly.Harnesses objHarnesses = null;
        SolidEdgeAssembly.Harness objHarness = null;
        DirectoryInfo SEInstallDir = null;
        string strPath1 = null;
        string strPath2 = null;
        string Occ1 = null;
        string Occ2 = null;
        string strCompanyName = "Bentley - promis-e";

        try
        {
            // Get  SE Application object.
            try
            {
                objSEApp = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
            }
            catch (Exception ex)
            {
                objSEApp = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"));
                objSEApp.DisplayAlerts = true;
                objSEApp.Visible = true;
            }
            //Get Path of Training folder
            SEInstallDir = GetTrainingFolder();
            strPath1 = SEInstallDir.FullName + "\\Wiring Harness\\seeabwh2.cmp";
            strPath2 = SEInstallDir.FullName + "\\Wiring Harness\\seeabwh2.con";
            Occ1 = SEInstallDir.FullName + "\\Wiring Harness\\gauge3.par";
            Occ2 = SEInstallDir.FullName + "\\Wiring Harness\\plug4.par";
            //Add new assembly file
            objAsmDoc = objSEApp.Documents.Add("SolidEdge.AssemblyDocument");
            objAsmDoc.Occurrences.AddByFilename(Occ1);
            objAsmDoc.Occurrences.AddByFilename(Occ2);
            objHarnesses = objAsmDoc.Harnesses;
            objHarnesses.CreateFromNetlistImporter(strCompanyName, strPath1, strPath2);
            objHarness = objHarnesses.Item(1);
            objHarness.SaveAsEcad(SolidEdgeAssembly.HarnessSaveAsEcadStatusConstants.seHarnessSaveAsEcadStatus_Success, strCompanyName, strPath1, strPath2);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        finally
        {
            // USER DISPLAY
            // Release objects
            objSEApp = null;
            objAsmDoc = null;
        }


    }
    public 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;
    }


    public Form1()
    {
        SubscribeToEvents();
    }

    private bool EventsSubscribed = false;
    private void SubscribeToEvents()
    {
        if (EventsSubscribed)
            return;
        else
            EventsSubscribed = true;

        Button1.Click += Button1_Click;
    }

}
See Also

Harness Object  | Harness Members  | Solid Edge V18 - What's New