Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Docs with vitepress #136

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think .gitignore are mainly kept as local files (not in the repo). Could you please remove from the repo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .gitignore is meant to prevent committing unwanted files in the repo.. for .net would be the obj and bin folders for the docs it would be the dist folder and node_modules.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
docs/.vitepress/dist
docs/.vitepress/cache

bin
obj

.vs
_build
packages
34 changes: 17 additions & 17 deletions README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md file is only used for the repo front page and NuGet (e.g. not run via docs). Could you please revert to the previous version?

Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

Visual Studio and Visual Studio Code templates can be installed from [NuGet](https://www.nuget.org/packages/Xarial.XCad.Templates/)

~~~
```
> 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.

~~~ cs
``` cs
[ComVisible(true)]
public class XCadAddIn : SwAddInEx
{
Expand All @@ -36,21 +36,21 @@ public class XCadAddIn : SwAddInEx

public override void OnConnect()
{
this.CommandManager.AddCommandGroup<Commands_e>().CommandClick += OnCommandsButtonClick;
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.

~~~ cs
``` cs
[ComVisible(true)]
public class IntroPmpPageAddIn : SwAddInEx
{
Expand All @@ -74,7 +74,7 @@ public class IntroPmpPageAddIn : SwAddInEx
{
m_Page = this.CreatePage<MyPMPageData>();
m_Page.Closed += OnPageClosed;
this.CommandManager.AddCommandGroup<Commands_e>().CommandClick += ShowPmpPage;
this.CommandManager.AddCommandGroup`<Commands_e>`().CommandClick += ShowPmpPage;
}

private void ShowPmpPage(Commands_e cmd)
Expand All @@ -89,13 +89,13 @@ public class IntroPmpPageAddIn : SwAddInEx
Debug.Print($"Selection component name: {m_Data.Component.Name}");
}
}
~~~
```

## Macro Features

Complex macro features became an ease with xCAD.NET

~~~ cs
``` cs
[ComVisible(true)]
public class IntroMacroFeatureAddIn : SwAddInEx
{
Expand Down Expand Up @@ -130,7 +130,7 @@ public class IntroMacroFeatureAddIn : SwAddInEx

public override void OnConnect()
{
this.CommandManager.AddCommandGroup<Commands_e>().CommandClick += OnCommandsButtonClick;
this.CommandManager.AddCommandGroup`<Commands_e>`().CommandClick += OnCommandsButtonClick;
}

private void OnCommandsButtonClick(Commands_e cmd)
Expand All @@ -143,13 +143,13 @@ public class IntroMacroFeatureAddIn : SwAddInEx
}
}
}
~~~
```

## 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](https://www.codestack.net/solidworks-document-manager-api/) using the same code base.

~~~ cs
``` cs
static void Main(string[] args)
{
var assmFilePath = @"C:\sample-assembly.sldasm";
Expand Down Expand Up @@ -181,7 +181,7 @@ private static void IterateComponentsRecursively(IXComponentRepository compsRepo
IterateComponentsRecursively(comp.Children, level + 1);
}
}
~~~
```

## Target Frameworks

Expand All @@ -201,18 +201,18 @@ When building the SOLIDWORKS add-ins see the information below
* Run Visual Studio as an Administrator
* Install [Xarial.XCad.SolidWorks](https://www.nuget.org/packages/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)
~~~ xml
``` xml
<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)

~~~ cs
``` cs
[ComRegisterFunction]
public static void RegisterFunction(Type t)
{
Expand All @@ -224,7 +224,7 @@ public static void UnregisterFunction(Type t)
{
SwAddInEx.UnregisterFunction(t);
}
~~~
```

Watch the [video demonstrations YouTube playlist](https://www.youtube.com/watch?v=YLFwqTX_V2I&list=PLZ8T-hyutVIEXMFgJ462Ou6Szjk26gPVo) of xCAD in action.

Expand Down
4 changes: 2 additions & 2 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

* Install [DefaultDocumentation](https://www.nuget.org/packages/DefaultDocumentation.Console) .NET Tool

~~~
```
dotnet tool install --global --add-source https://api.nuget.org/v3/index.json --ignore-failed-sources DefaultDocumentation.Console
~~~
```
29 changes: 29 additions & 0 deletions docs/.vitepress/components/YouTube.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div class="video_wrapper">
<iframe
frameborder="0"
width="100%"
height="100%"
:src="'https://www.youtube.com/embed/' + props.id"
allowfullscreen
></iframe>
</div>
</template>
<script setup>
const props = defineProps(["id"]);
</script>
<style scoped>
.video_wrapper {
position: relative;
padding-bottom: 56.25%;
/* 16:9, for an aspect ratio of 1:1 change to this value to 100% */
}

iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
49 changes: 49 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { defineConfig } from 'vitepress'
import { generateSidebar } from 'vitepress-sidebar';

const vitepressSidebarOptions = {
// debugPrint: true,
documentRootPath: "/docs",
useFolderLinkFromIndexFile: true,
hyphenToSpace: true,
capitalizeFirst: true,
collapsed: true,
excludeFolders:["_assets","_includes","_layouts","_legal","_src", "changelog"],
};

export default defineConfig({
head: [['link', { rel: 'icon', href: '/xcad/favicon.ico' }]],
title: 'XCad',
description: 'SOLIDWORKS API development made easy',
srcDir: "./",
base:"/xcad/",
themeConfig: {
logo: '/logo.svg',
search: {
provider: 'local'
},
nav:[
{ text: 'Contact', link: 'mailto:[email protected]' },
{ text: 'Guide', link: 'https://github.com/xarial/xcad-examples' },
{ text:'Changelog', link:'/changelog/'}
],
socialLinks: [
{icon:'discord', link: 'https://discord.gg/gbhABKu3eJ'} ,
{icon:'github', link: 'https://github.com/xarial/xcad'} ,
{icon:'youtube', link: 'https://www.youtube.com/@Xarial'} ,
{icon:{ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path xmlns="http://www.w3.org/2000/svg" d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>' }, link:'https://www.linkedin.com/company/xarial'},
{icon:{ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path xmlns="http://www.w3.org/2000/svg" d="M2.204 14.049c-.06.276-.091.56-.091.847 0 3.443 4.402 6.249 9.814 6.249 5.41 0 9.812-2.804 9.812-6.249 0-.274-.029-.546-.082-.809l-.015-.032a.456.456 0 0 1-.029-.165c-.302-1.175-1.117-2.241-2.296-3.103a.422.422 0 0 1-.126-.07c-.026-.02-.045-.042-.067-.064-1.792-1.234-4.356-2.008-7.196-2.008-2.815 0-5.354.759-7.146 1.971a.397.397 0 0 1-.179.124c-1.206.862-2.042 1.937-2.354 3.123a.454.454 0 0 1-.037.171l-.008.015zm9.773 5.441c-1.794 0-3.057-.389-3.863-1.197a.45.45 0 0 1 0-.632.47.47 0 0 1 .635 0c.63.629 1.685.943 3.228.943 1.542 0 2.591-.3 3.219-.929a.463.463 0 0 1 .629 0 .482.482 0 0 1 0 .645c-.809.808-2.065 1.198-3.862 1.198l.014-.028zm-3.606-7.573c-.914 0-1.677.765-1.677 1.677 0 .91.763 1.65 1.677 1.65s1.651-.74 1.651-1.65c0-.912-.739-1.677-1.651-1.677zm7.233 0c-.914 0-1.678.765-1.678 1.677 0 .91.764 1.65 1.678 1.65s1.651-.74 1.651-1.65c0-.912-.739-1.677-1.651-1.677zm4.548-1.595c1.037.833 1.8 1.821 2.189 2.904a1.818 1.818 0 1 0-2.189-2.902v-.002zM2.711 9.963a1.82 1.82 0 0 0-1.173 3.207c.401-1.079 1.172-2.053 2.213-2.876a1.82 1.82 0 0 0-1.039-.329v-.002zm9.217 12.079c-5.906 0-10.709-3.205-10.709-7.142 0-.275.023-.544.068-.809A2.723 2.723 0 0 1 0 11.777a2.725 2.725 0 0 1 2.725-2.713 2.7 2.7 0 0 1 1.797.682c1.856-1.191 4.357-1.941 7.112-1.992l1.812-5.524.404.095s.016 0 .016.002l4.223.993a2.237 2.237 0 0 1 4.296.874c0 1.232-1.003 2.234-2.231 2.234s-2.23-1.004-2.23-2.23l-3.851-.912-1.467 4.477c2.65.105 5.047.854 6.844 2.021a2.663 2.663 0 0 1 1.833-.719 2.716 2.716 0 0 1 2.718 2.711c0 .987-.54 1.886-1.378 2.365.029.255.059.494.059.749-.015 3.938-4.806 7.143-10.72 7.143l-.034.009zm8.179-19.187a1.339 1.339 0 1 0 0 2.678c.732 0 1.33-.6 1.33-1.334 0-.733-.598-1.332-1.347-1.332l.017-.012z"/></svg>' }, link:'https://www.reddit.com/r/xCAD/'},
{icon:{ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path xmlns="http://www.w3.org/2000/svg" d="M17.67 21.633a3.995 3.995 0 1 1 0-7.99 3.995 3.995 0 0 1 0 7.99m-7.969-9.157a2.497 2.497 0 1 1 0-4.994 2.497 2.497 0 0 1 0 4.994m8.145-7.795h-6.667a6.156 6.156 0 0 0-6.154 6.155v6.667a6.154 6.154 0 0 0 6.154 6.154h6.667A6.154 6.154 0 0 0 24 17.503v-6.667a6.155 6.155 0 0 0-6.154-6.155M3.995 2.339a1.998 1.998 0 1 1-3.996 0 1.998 1.998 0 0 1 3.996 0"/></svg>' }, link:'https://www.nuget.org/profiles/Xarial'},
{icon:{ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path xmlns="http://www.w3.org/2000/svg" d="M19.199 24C19.199 13.467 10.533 4.8 0 4.8V0c13.165 0 24 10.835 24 24h-4.801zM3.291 17.415c1.814 0 3.293 1.479 3.293 3.295 0 1.813-1.485 3.29-3.301 3.29C1.47 24 0 22.526 0 20.71s1.475-3.294 3.291-3.295zM15.909 24h-4.665c0-6.169-5.075-11.245-11.244-11.245V8.09c8.727 0 15.909 7.184 15.909 15.91z"/></svg>' }, link:'https://xcad.xarial.com/feed.xml'},
{icon:{ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path xmlns="http://www.w3.org/2000/svg" d="M2.117 3.185C.957 3.185.024 4.243.024 5.557v12.886c0 1.314.933 2.372 2.093 2.372h19.766c1.16 0 2.093-1.058 2.093-2.372V5.557c0-1.314-.933-2.372-2.093-2.372zm18.757 1.587a.811.811 0 0 1 .554 1.407l-7.842 7.46a2.495 2.495 0 0 1-3.53 0l-.002-.002-.004-.002-7.49-7.402A.811.811 0 1 1 3.701 5.08l7.497 7.41.004.002c.279.281.97.27 1.232.006l.008-.008 7.868-7.485a.811.811 0 0 1 .563-.231zm-3.644 7.726a.811.811 0 0 1 .58.253l4.847 4.963a.811.811 0 1 1-1.16 1.133l-4.847-4.963a.811.811 0 0 1 .58-1.386zm-10.176.035a.811.811 0 0 1 .604 1.385l-4.79 4.897A.811.811 0 1 1 1.71 17.68l4.79-4.897a.811.811 0 0 1 .555-.251z"/></svg>' }, link:'[email protected]'}
],
sidebar: generateSidebar(vitepressSidebarOptions),
footer: {
message: `<a style="margin-left: 10px;margin-right: 10px;" href="/terms-of-use/">Terms Of Use</a>
<a style="margin-left: 10px;margin-right: 10px;" href="/privacy-policy/">Privacy</a>
<a style="margin-left: 10px;margin-right: 10px;" href="/cookies-policy/">Cookies</a>`,
copyright: 'Copyright © 2024 Xarial Pty Limited. All rights reserved.',
}
}
})

23 changes: 23 additions & 0 deletions docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:root {
--vp-c-brand-1: #1ca7e1;
--vp-c-brand-2: #f7cb20;
}

.dark .VPHome .text {
background: -webkit-linear-gradient(315deg, var(--vp-c-brand-1) 25%, var(--vp-c-brand-2));
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}

.sub-links a {
font-weight: 500;
color: var(--vp-c-brand-1);
text-decoration: underline;
text-underline-offset: 2px;
transition: color 0.25s, opacity 0.25s;
}

.sub-links a:hover {
color: var(--vp-c-brand-2);
}
11 changes: 11 additions & 0 deletions docs/.vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import DefaultTheme from 'vitepress/theme'
import YouTube from '../components/YouTube.vue'
import './custom.css'

export default {
extends: DefaultTheme,
enhanceApp({ app }) {
// register your custom global components
app.component('YouTube', YouTube)
}
}
14 changes: 7 additions & 7 deletions docs/_src/CustomFeature/BackwardCompatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ namespace Xarial.XCad.Documentation
{
namespace V1
{
//--- OldParams
#region OldParams
[ParametersVersion("1.0", typeof(MacroFeatureParamsVersionConverter))]
public class MacroFeatureParams
{
public string Param1 { get; set; }
public int Param2 { get; set; }
}
//---
#endregion OldParams
}

namespace V2
{
//--- NewParams
#region NewParams
[ParametersVersion("2.0", typeof(MacroFeatureParamsVersionConverter))]
public class MacroFeatureParams
{
public string Param1A { get; set; }//parameter renamed
public int Param2 { get; set; }
public string Param3 { get; set; }//new parameter added
}
//---
#endregion NewParams
}

//--- Converter
#region Converter
public class MacroFeatureParamsVersionConverter : ParametersVersionConverter
{
private class VersConv_1_0To2_0 : IParameterConverter
{
public void Convert(IXDocument model, IXCustomFeature feat, ref Dictionary<string, object> parameters,
public void Convert(IXDocument model, IXCustomFeature feat, ref Dictionary<string, object> parameters,
ref CustomFeatureSelectionInfo[] selection, ref IXDimension[] dispDims, ref IXBody[] editBodies)
{
var paramVal = parameters["Param1"];
Expand All @@ -58,5 +58,5 @@ public MacroFeatureParamsVersionConverter()
//add more version converters
}
}
//---
#endregion Converter
}
14 changes: 7 additions & 7 deletions docs/_src/CustomFeature/EditBodies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ namespace Xarial.XCad.Documentation.CustomFeature
{
public class MacroFeatureEditBodiesParams
{
//--- single
#region single
public IXBody InputBody { get; set; }
//---
#endregion single

//--- multiple
#region multiple
public IXBody EditBody1 { get; set; }
public IXBody EditBody2 { get; set; }
//---
#endregion multiple

//--- list
#region list
public List<IXBody> EditBodies { get; set; }
//---
#endregion list
}

[ComVisible(true)]
public class EditBodiesMacroFeature : SwMacroFeatureDefinition<MacroFeatureEditBodiesParams>
{
public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model,
public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model,
ISwMacroFeature<MacroFeatureEditBodiesParams> feature, out AlignDimensionDelegate<MacroFeatureEditBodiesParams> alignDim)
{
alignDim = null;
Expand Down
10 changes: 5 additions & 5 deletions docs/_src/DocMgrAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace Xarial.XCad.Documentation
{
[Title("Document Manager Add-In")]
[ComVisible(true), Guid("37728E73-BB74-4430-9FEB-AEC2B97DF861")]
public class DocMgrAddIn : SwAddInEx
public class DocMgrAddIn : SwAddInEx
{
//--- DocHandlerDefinition
#region DocHandlerDefinition
public class MyDocHandler : SwDocumentHandler
{
protected override void AttachPartEvents(PartDoc part)
Expand All @@ -34,13 +34,13 @@ private int OnAddItemNotify(int EntityType, string itemName)
return 0;
}
}
//---
#endregion DocHandlerDefinition

//--- DocHandlerInit
#region DocHandlerInit
public override void OnConnect()
{
this.Application.Documents.RegisterHandler<MyDocHandler>();
}
//---
#endregion DocHandlerInit
}
}
Loading
Loading