{"id":37039076,"url":"https://github.com/xarial/xcad","last_synced_at":"2026-01-14T04:38:24.141Z","repository":{"id":40665111,"uuid":"238175889","full_name":"xarial/xcad","owner":"xarial","description":"Framework for developing CAD applications for SOLIDWORKS, including add-ins, stand-alone applications, macro features, property manager pages, etc.","archived":false,"fork":false,"pushed_at":"2025-12-22T11:54:25.000Z","size":13886,"stargazers_count":177,"open_issues_count":35,"forks_count":40,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-12-23T22:50:36.862Z","etag":null,"topics":["macrofeature","pmp","propertymanagerpage","solidworks","solidworks-api","solidworksapi"],"latest_commit_sha":null,"homepage":"https://xcad.net","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xarial.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-02-04T10:08:06.000Z","updated_at":"2025-12-13T07:57:33.000Z","dependencies_parsed_at":"2023-10-17T07:58:22.778Z","dependency_job_id":"9d11ff5a-71f2-4ad6-9516-0ab44db4620c","html_url":"https://github.com/xarial/xcad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xarial/xcad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarial%2Fxcad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarial%2Fxcad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarial%2Fxcad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarial%2Fxcad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xarial","download_url":"https://codeload.github.com/xarial/xcad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarial%2Fxcad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["macrofeature","pmp","propertymanagerpage","solidworks","solidworks-api","solidworksapi"],"created_at":"2026-01-14T04:38:23.624Z","updated_at":"2026-01-14T04:38:24.126Z","avatar_url":"https://github.com/xarial.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xCAD.NET: SOLIDWORKS API development made easy\n\n![Logo](https://raw.githubusercontent.com/xarial/xcad/master/data/icon.png)\n\n[![NuGet version (xCAD.NET)](https://img.shields.io/nuget/v/Xarial.XCad.svg?style=flat-square)](https://www.nuget.org/packages/Xarial.XCad/)\n[![Build status](https://dev.azure.com/xarial/xcad/_apis/build/status/xcad)](https://dev.azure.com/xarial/xcad/_build/latest?definitionId=34)\n\n[![Templates](https://img.shields.io/badge/-Templates-yellow.svg)](https://www.nuget.org/packages/Xarial.XCad.Templates/)\n[![User Guide](https://img.shields.io/badge/-Documentation-green.svg)](https://xcad.xarial.com)\n[![Examples](https://img.shields.io/badge/-Examples-blue.svg)](https://github.com/xarial/xcad-examples)\n[![Videos](https://img.shields.io/badge/-Videos-red.svg)](https://www.youtube.com/watch?v=YLFwqTX_V2I\u0026list=PLZ8T-hyutVIEXMFgJ462Ou6Szjk26gPVo)\n\n[xCAD.NET](https://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.\n\n## Templates\n\nVisual Studio and Visual Studio Code templates can be installed from [NuGet](https://www.nuget.org/packages/Xarial.XCad.Templates/)\n\n~~~\n\u003e dotnet new install Xarial.XCad.Templates\n~~~\n\n## SOLIDWORKS Add-in Applications\n\nIt has never been easier to create SOLIDWORKS add-ins with toolbar and menu commands.\n\n~~~ cs\n[ComVisible(true)]\npublic class XCadAddIn : SwAddInEx\n{\n    public enum Commands_e\n    {\n        Command1,\n        Command2\n    }\n\n    public override void OnConnect()\n    {\n        this.CommandManager.AddCommandGroup\u003cCommands_e\u003e().CommandClick += OnCommandsButtonClick;\n    }\n\n    private void OnCommandsButtonClick(Commands_e cmd)\n    {\n        //TODO: handle the button click\n    }\n}\n~~~\n\n## Property Manager Pages\n\nFramework 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.\n\n~~~ cs\n[ComVisible(true)]\npublic class IntroPmpPageAddIn : SwAddInEx\n{\n    [ComVisible(true)]\n    public class MyPMPageData : SwPropertyManagerPageHandler\n    {\n        public string Text { get; set; }\n        public int Number { get; set; }\n        public IXComponent Component { get; set; }\n    }\n\n    private enum Commands_e\n    {\n        ShowPmpPage\n    }\n\n    private IXPropertyPage\u003cMyPMPageData\u003e m_Page;\n    private MyPMPageData m_Data = new MyPMPageData();\n\n    public override void OnConnect()\n    {\n        m_Page = this.CreatePage\u003cMyPMPageData\u003e();\n        m_Page.Closed += OnPageClosed;\n        this.CommandManager.AddCommandGroup\u003cCommands_e\u003e().CommandClick += ShowPmpPage;\n    }\n\n    private void ShowPmpPage(Commands_e cmd)\n    {\n        m_Page.Show(m_Data);\n    }\n\n    private void OnPageClosed(PageCloseReasons_e reason)\n    {\n        Debug.Print($\"Text: {m_Data.Text}\");\n        Debug.Print($\"Number: {m_Data.Number}\");\n        Debug.Print($\"Selection component name: {m_Data.Component.Name}\");\n    }\n}\n~~~\n\n## Macro Features\n\nComplex macro features became an ease with xCAD.NET\n\n~~~ cs\n[ComVisible(true)]\npublic class IntroMacroFeatureAddIn : SwAddInEx \n{\n    [ComVisible(true)]\n    public class BoxData : SwPropertyManagerPageHandler\n    {\n        public double Width { get; set; }\n        public double Length { get; set; }\n        public double Height { get; set; }\n    }\n\n    [ComVisible(true)]\n    public class BoxMacroFeature : SwMacroFeatureDefinition\u003cBoxData, BoxData\u003e\n    {\n        public override ISwBody[] CreateGeometry(ISwApplication app, ISwDocument model, ISwMacroFeature\u003cBoxData\u003e feat)\n        {\n            var data = feat.Parameters;\n\n            var body = (ISwBody)app.MemoryGeometryBuilder.CreateSolidBox(new Point(0, 0, 0),\n                new Vector(1, 0, 0), new Vector(0, 1, 0),\n                data.Width, data.Length, data.Height).Bodies.First();\n\n            return new ISwBody[] { body };\n        }\n\n    }\n\n    public enum Commands_e\n    {\n        InsertMacroFeature,\n    }\n\n    public override void OnConnect()\n    {\n        this.CommandManager.AddCommandGroup\u003cCommands_e\u003e().CommandClick += OnCommandsButtonClick;\n    }\n\n    private void OnCommandsButtonClick(Commands_e cmd)\n    {\n        switch (cmd) \n        {\n            case Commands_e.InsertMacroFeature:\n                Application.Documents.Active.Features.CreateCustomFeature\u003cBoxMacroFeature, BoxData, BoxData\u003e();\n                break;\n        }\n    }\n}\n~~~\n\n## SOLIDWORKS And Document Manager API\n\nxCAD.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](https://www.codestack.net/solidworks-document-manager-api/) using the same code base.\n\n~~~ cs\nstatic void Main(string[] args)\n{\n    var assmFilePath = @\"C:\\sample-assembly.sldasm\";\n\n    //print assembly components using SOLIDWORKS API\n    var swApp = SwApplicationFactory.Create(SwVersion_e.Sw2022, ApplicationState_e.Silent);\n    PrintAssemblyComponents(swApp, assmFilePath);\n\n    //print assembly components using SOLIDWORKS Document Manager API\n    var swDmApp = SwDmApplicationFactory.Create(\"[Document Manager Lincese Key]\");\n    PrintAssemblyComponents(swDmApp, assmFilePath);\n}\n\n//CAD-agnostic function to open assembly, print all components and close assembly\nprivate static void PrintAssemblyComponents(IXApplication app, string filePath) \n{\n    using (var assm = app.Documents.Open(filePath, DocumentState_e.ReadOnly))\n    {\n        IterateComponentsRecursively(((IXAssembly)assm).Configurations.Active.Components, 0);\n    }\n}\n\nprivate static void IterateComponentsRecursively(IXComponentRepository compsRepo, int level) \n{\n    foreach (var comp in compsRepo)\n    {\n        Console.WriteLine(Enumerable.Repeat(\"  \", level) + comp.Name);\n\n        IterateComponentsRecursively(comp.Children, level + 1);\n    }\n}\n~~~\n\n## Target Frameworks\n\nxCAD.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)\n\nWhen building the SOLIDWORKS add-ins see the information below\n\n### .NET Framework\n\n* Run Visual Studio as an Administrator\n* Install [Xarial.XCad.SolidWorks](https://www.nuget.org/packages/Xarial.XCad.SolidWorks) package from the nuget and create add-in class as shown above\n* Build the solution. Add-in will be automatically registered. Clean the solution to unregister the add-in.\n* 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.\n\n### .NET Core/.NET 6/.NET 7\n\n* Run Visual Studio as an Administrator\n* Install [Xarial.XCad.SolidWorks](https://www.nuget.org/packages/Xarial.XCad.SolidWorks) package from the nuget and create add-in class as shown above\n* Add the following property into the project file (*.csproj or *.vbproj)\n~~~ xml\n\u003cPropertyGroup\u003e\n    \u003cEnableComHosting\u003etrue\u003c/EnableComHosting\u003e\n\u003c/PropertyGroup\u003e\n~~~\n* Build the solution. Add-in will be automatically registered. Clean the solution to unregister the add-in.\n\n### .NET Core Only\n\nAutomatic 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)\n\n~~~ cs\n[ComRegisterFunction]\npublic static void RegisterFunction(Type t)\n{\n    SwAddInEx.RegisterFunction(t);\n}\n\n[ComUnregisterFunction]\npublic static void UnregisterFunction(Type t)\n{\n    SwAddInEx.UnregisterFunction(t);\n}\n~~~\n\nWatch the [video demonstrations YouTube playlist](https://www.youtube.com/watch?v=YLFwqTX_V2I\u0026list=PLZ8T-hyutVIEXMFgJ462Ou6Szjk26gPVo) of xCAD in action.\n\nVisit [User Guide](https://xcad.net) page and start exploring the framework.\n\n## Unit Tests\n\nSolution contains unit and integration tests\n\nTo execute integration tests\n\n* Download the [Test Data](https://1drv.ms/u/s!AjSRTGmPuUunpFTsZGgl4gfyjLRg?e=kZuO5c)\n* Unzip into the folder\n* Create an environment variable **XCAD_TEST_DATA** and set its value to the path of the folder above\n* To test SOLIDWORKS Document Manager, add an environment variable **SW_DM_KEY** and set its value to your [Document Manager Key](https://www.codestack.net/solidworks-document-manager-api/getting-started/create-connection#activating-document-manager)\n* Run tests","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxarial%2Fxcad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxarial%2Fxcad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxarial%2Fxcad/lists"}