XCAD.NET
XCAD.NET
Framework for .NET (C# and VB.NET) to create modern application for CAD systems (SOLIDWORKS)
Get technical support Access source code Explore code and application examples

Using xCAD to create out-of-process (stand-alone) applications


xCAD framework can be used to create out-of-process (stand-alone) applications, such as Console, Windows Forms, WPF etc. in .NET Framework or .NET Core.

Call SwApplication.Start to connect to SOLIDWORKS instance in one of the following ways:

  • To the specified SOLIDWORKS version
  • To the latest SOLIDWORKS version (set the value of vers parameter to null)
  • By optionally providing additional arguments

In order to connect to existing (running process of SOLIDWORKS) use SwApplication.FromProcess method and pass the pointer to Process

using SolidWorks.Interop.sldworks;
using System;
using System.Threading.Tasks;
using Xarial.XCad.Documents.Structures;
using Xarial.XCad.SolidWorks;
using Xarial.XCad.SolidWorks.Enums;

namespace Xarial.XCad.Documentation
{
    class Program
    {
        static async Task Main(string[] args)
        {
            using (var app = await SwApplication.Start(SwVersion_e.Sw2020, "/b"))
            {
                ISldWorks swApp = app.Sw;
                Console.WriteLine(swApp.RevisionNumber());

                var doc = app.Documents.Open(new DocumentOpenArgs()
                {
                    Path = @"D:\model1.SLDPRT",
                    ReadOnly = true
                });

                IModelDoc2 swModel = doc.Model;

                Console.WriteLine(swModel.GetTitle());

                app.Close();
            }
        }
    }
}

Refer Console Model Generator example which demonstrates how to access xCAD.API from .NET Core console.


Powered by Docify