Xarial.XCad.Toolkit
0.8.0-beta.4867
See the version list below for details.
dotnet add package Xarial.XCad.Toolkit --version 0.8.0-beta.4867
NuGet\Install-Package Xarial.XCad.Toolkit -Version 0.8.0-beta.4867
<PackageReference Include="Xarial.XCad.Toolkit" Version="0.8.0-beta.4867" />
paket add Xarial.XCad.Toolkit --version 0.8.0-beta.4867
#r "nuget: Xarial.XCad.Toolkit, 0.8.0-beta.4867"
// Install Xarial.XCad.Toolkit as a Cake Addin #addin nuget:?package=Xarial.XCad.Toolkit&version=0.8.0-beta.4867&prerelease // Install Xarial.XCad.Toolkit as a Cake Tool #tool nuget:?package=Xarial.XCad.Toolkit&version=0.8.0-beta.4867&prerelease
xCAD.NET: SOLIDWORKS API development made easy
xCAD.NET is a framework for building CAD agnostic applications. It allows developers to implement complex functionality with a very simple innovative approach. This brings the best user experience to the consumers of the software.
Templates
Visual Studio and Visual Studio Code templates can be installed from NuGet
> dotnet new install Xarial.XCad.Templates
SOLIDWORKS Add-in Applications
It has never been easier to create SOLIDWORKS add-ins with toolbar and menu commands.
[ComVisible(true)]
public class XCadAddIn : SwAddInEx
{
public enum Commands_e
{
Command1,
Command2
}
public override void OnConnect()
{
this.CommandManager.AddCommandGroup<Commands_e>().CommandClick += OnCommandsButtonClick;
}
private void OnCommandsButtonClick(Commands_e cmd)
{
//TODO: handle the button click
}
}
Property Manager Pages
Framework reinvents the way you work with Property Manager Pages. No need to code a complex code behind for adding the controls and handling the values. Simply define your data model and the framework will build the suitable Property Manager Page automatically and two-way bind controls to the data model.
[ComVisible(true)]
public class IntroPmpPageAddIn : SwAddInEx
{
[ComVisible(true)]
public class MyPMPageData : SwPropertyManagerPageHandler
{
public string Text { get; set; }
public int Number { get; set; }
public IXComponent Component { get; set; }
}
private enum Commands_e
{
ShowPmpPage
}
private IXPropertyPage<MyPMPageData> m_Page;
private MyPMPageData m_Data = new MyPMPageData();
public override void OnConnect()
{
m_Page = this.CreatePage<MyPMPageData>();
m_Page.Closed += OnPageClosed;
this.CommandManager.AddCommandGroup<Commands_e>().CommandClick += ShowPmpPage;
}
private void ShowPmpPage(Commands_e cmd)
{
m_Page.Show(m_Data);
}
private void OnPageClosed(PageCloseReasons_e reason)
{
Debug.Print($"Text: {m_Data.Text}");
Debug.Print($"Number: {m_Data.Number}");
Debug.Print($"Selection component name: {m_Data.Component.Name}");
}
}
Macro Features
Complex macro features became an ease with xCAD.NET
[ComVisible(true)]
public class IntroMacroFeatureAddIn : SwAddInEx
{
[ComVisible(true)]
public class BoxData : SwPropertyManagerPageHandler
{
public double Width { get; set; }
public double Length { get; set; }
public double Height { get; set; }
}
[ComVisible(true)]
public class BoxMacroFeature : SwMacroFeatureDefinition<BoxData, BoxData>
{
public override ISwBody[] CreateGeometry(ISwApplication app, ISwDocument model, ISwMacroFeature<BoxData> feat)
{
var data = feat.Parameters;
var body = (ISwBody)app.MemoryGeometryBuilder.CreateSolidBox(new Point(0, 0, 0),
new Vector(1, 0, 0), new Vector(0, 1, 0),
data.Width, data.Length, data.Height).Bodies.First();
return new ISwBody[] { body };
}
}
public enum Commands_e
{
InsertMacroFeature,
}
public override void OnConnect()
{
this.CommandManager.AddCommandGroup<Commands_e>().CommandClick += OnCommandsButtonClick;
}
private void OnCommandsButtonClick(Commands_e cmd)
{
switch (cmd)
{
case Commands_e.InsertMacroFeature:
Application.Documents.Active.Features.CreateCustomFeature<BoxMacroFeature, BoxData, BoxData>();
break;
}
}
}
SOLIDWORKS And Document Manager API
xCAD.NET allows to write the same code targeting different CAD implementation in a completely agnostic way. Example below demonstrates how to perform opening of assembly, traversing components recursively and closing the assembly via SOLIDWORKS API and SOLIDWORKS Document Manager API using the same code base.
static void Main(string[] args)
{
var assmFilePath = @"C:\sample-assembly.sldasm";
//print assembly components using SOLIDWORKS API
var swApp = SwApplicationFactory.Create(SwVersion_e.Sw2022, ApplicationState_e.Silent);
PrintAssemblyComponents(swApp, assmFilePath);
//print assembly components using SOLIDWORKS Document Manager API
var swDmApp = SwDmApplicationFactory.Create("[Document Manager Lincese Key]");
PrintAssemblyComponents(swDmApp, assmFilePath);
}
//CAD-agnostic function to open assembly, print all components and close assembly
private static void PrintAssemblyComponents(IXApplication app, string filePath)
{
using (var assm = app.Documents.Open(filePath, DocumentState_e.ReadOnly))
{
IterateComponentsRecursively(((IXAssembly)assm).Configurations.Active.Components, 0);
}
}
private static void IterateComponentsRecursively(IXComponentRepository compsRepo, int level)
{
foreach (var comp in compsRepo)
{
Console.WriteLine(Enumerable.Repeat(" ", level) + comp.Name);
IterateComponentsRecursively(comp.Children, level + 1);
}
}
Target Frameworks
xCAD.NET is compatible with multiple target frameworks: .NET Framework 4.6.1, .NET Core 3.1, .NET 6.0, .NET 7.0 and number of additional computed target frameworks (e.g. .NET Framework 4.8)
When building the SOLIDWORKS add-ins see the information below
.NET Framework
- Run Visual Studio as an Administrator
- Install Xarial.XCad.SolidWorks package from the nuget and create add-in class as shown above
- Build the solution. Add-in will be automatically registered. Clean the solution to unregister the add-in.
- Set the Embed Interop option to True for all SOLIDWORKS type libraries (e.g. SolidWorks.Interop.SldWorks.tlb, SolidWorks.Interop.SwConst.tlb, SolidWorks.Interop.SwPublished.tlb). Note this might not be required as nuget will set this flag automatically.
.NET Core/.NET 6/.NET 7
- Run Visual Studio as an Administrator
- Install Xarial.XCad.SolidWorks package from the nuget and create add-in class as shown above
- Add the following property into the project file (*.csproj or *.vbproj)
<PropertyGroup>
<EnableComHosting>true</EnableComHosting>
</PropertyGroup>
- Build the solution. Add-in will be automatically registered. Clean the solution to unregister the add-in.
.NET Core Only
Automatic registration does not work in .NET Core and it needs to be called manually by adding the following code into the add-in (this is not required for .NET6)
[ComRegisterFunction]
public static void RegisterFunction(Type t)
{
SwAddInEx.RegisterFunction(t);
}
[ComUnregisterFunction]
public static void UnregisterFunction(Type t)
{
SwAddInEx.UnregisterFunction(t);
}
Watch the video demonstrations YouTube playlist of xCAD in action.
Visit User Guide page and start exploring the framework.
Unit Tests
Solution contains unit and integration tests
To execute integration tests
- Download the Test Data
- Unzip into the folder
- Create an environment variable XCAD_TEST_DATA and set its value to the path of the folder above
- To test SOLIDWORKS Document Manager, add an environment variable SW_DM_KEY and set its value to your Document Manager Key
- Run tests
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- Xarial.XCad (>= 0.8.0-beta.4867)
-
.NETStandard 2.1
- System.Drawing.Common (>= 7.0.0)
- Xarial.XCad (>= 0.8.0-beta.4867)
-
net6.0
- System.Drawing.Common (>= 7.0.0)
- Xarial.XCad (>= 0.8.0-beta.4867)
-
net7.0
- System.Drawing.Common (>= 7.0.0)
- Xarial.XCad (>= 0.8.0-beta.4867)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Xarial.XCad.Toolkit:
Package | Downloads |
---|---|
Xarial.XCad.SolidWorks
Framework for developing SOLIDWORKS applications based on xCAD.NET |
|
Xarial.XCad.SwDocumentManager
Framework for developing SOLIDWORKS applications using Document Manager based on xCAD.NET |
|
Xarial.XCad.Inventor
Framework for developing Autodesk Inventor applications based on xCAD.NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.8.0 | 1,410 | 1/30/2024 |
0.8.0-beta.4964 | 71 | 1/29/2024 |
0.8.0-beta.4960 | 75 | 1/25/2024 |
0.8.0-beta.4956 | 58 | 1/25/2024 |
0.8.0-beta.4948 | 83 | 1/18/2024 |
0.8.0-beta.4929 | 148 | 12/19/2023 |
0.8.0-beta.4922 | 98 | 12/17/2023 |
0.8.0-beta.4913 | 111 | 12/1/2023 |
0.8.0-beta.4901 | 137 | 11/9/2023 |
0.8.0-beta.4893 | 73 | 11/9/2023 |
0.8.0-beta.4875 | 130 | 10/25/2023 |
0.8.0-beta.4867 | 88 | 10/25/2023 |
0.8.0-beta.4855 | 99 | 10/17/2023 |
0.8.0-beta.4843 | 106 | 10/10/2023 |
0.8.0-beta.4839 | 93 | 10/1/2023 |
0.8.0-beta.4687 | 427 | 5/25/2023 |
0.8.0-beta.4670 | 96 | 5/11/2023 |
0.8.0-beta.4627 | 328 | 2/9/2023 |
0.8.0-beta.4619 | 199 | 1/18/2023 |
0.8.0-beta.4614 | 113 | 1/16/2023 |
0.8.0-beta.4602 | 135 | 1/15/2023 |
0.8.0-beta.4599 | 125 | 1/12/2023 |
0.8.0-beta.4594 | 115 | 12/21/2022 |
0.8.0-beta.4593 | 105 | 12/21/2022 |
0.8.0-beta.4590 | 97 | 12/13/2022 |
0.8.0-beta.4583 | 101 | 12/11/2022 |
0.8.0-alpha.4560 | 173 | 12/6/2022 |
0.7.12 | 6,343 | 11/26/2021 |
0.7.11 | 542 | 11/23/2021 |
0.7.10 | 607 | 11/19/2021 |
0.7.9 | 587 | 11/18/2021 |
0.7.8 | 645 | 11/1/2021 |
0.7.7 | 643 | 10/26/2021 |
0.7.6 | 669 | 10/13/2021 |
0.7.5 | 1,127 | 10/6/2021 |
0.7.4 | 829 | 7/11/2021 |
0.7.3 | 677 | 7/2/2021 |
0.7.2 | 652 | 7/2/2021 |
0.7.1 | 725 | 6/8/2021 |
0.7.0 | 816 | 5/2/2021 |
0.6.10 | 1,094 | 12/7/2020 |
0.6.9 | 531 | 11/27/2020 |
0.6.8 | 616 | 11/9/2020 |
0.6.7 | 595 | 11/9/2020 |
0.6.6 | 584 | 10/28/2020 |
0.6.5 | 660 | 10/14/2020 |
0.6.4 | 565 | 10/8/2020 |
0.6.3 | 740 | 9/30/2020 |
0.6.2 | 568 | 9/28/2020 |
0.6.1 | 604 | 9/23/2020 |
0.6.0 | 664 | 9/13/2020 |
0.5.8 | 614 | 9/1/2020 |
0.5.7 | 712 | 7/19/2020 |
0.5.6 | 703 | 6/26/2020 |
0.5.5 | 703 | 6/26/2020 |
0.5.4 | 646 | 6/25/2020 |
0.5.3 | 682 | 6/25/2020 |
0.5.2 | 613 | 6/15/2020 |
0.5.1 | 606 | 6/15/2020 |
0.5.0 | 620 | 6/15/2020 |
0.4.0 | 710 | 2/13/2020 |
0.3.3 | 661 | 2/11/2020 |
0.3.1 | 746 | 2/9/2020 |
0.3.0 | 689 | 2/8/2020 |
0.2.4 | 641 | 2/6/2020 |
0.2.3 | 695 | 2/6/2020 |
0.2.2 | 696 | 2/6/2020 |
0.2.0 | 665 | 2/5/2020 |
0.1.1 | 650 | 2/4/2020 |
0.1.0 | 531 | 2/3/2020 |