CwAPI3D.Net.Bridge
0.0.4
dotnet add package CwAPI3D.Net.Bridge --version 0.0.4
NuGet\Install-Package CwAPI3D.Net.Bridge -Version 0.0.4
<PackageReference Include="CwAPI3D.Net.Bridge" Version="0.0.4" />
<PackageVersion Include="CwAPI3D.Net.Bridge" Version="0.0.4" />
<PackageReference Include="CwAPI3D.Net.Bridge" />
paket add CwAPI3D.Net.Bridge --version 0.0.4
#r "nuget: CwAPI3D.Net.Bridge, 0.0.4"
#:package CwAPI3D.Net.Bridge@0.0.4
#addin nuget:?package=CwAPI3D.Net.Bridge&version=0.0.4
#tool nuget:?package=CwAPI3D.Net.Bridge&version=0.0.4
CwAPI3D.Net.Bridge
This project serves as a .NET bridge for the C++ API from cadwork 3d. It leverages the power of C++ CLI (Common Language Infrastructure) to provide a seamless integration between the .NET environment and the cadwork 3d API. This allows developers to utilize the robust features of cadwork 3d API within their .NET applications.
Getting Started
Clone the repository to your local machine.
git clone https://github.com/Brunner246/CwAPI3D.Net.Bridge.git
Update the macros in CwAPI3D.props to point to the correct paths for cadwork. The macros are used to include the necessary headers and for copying the DLLs as a post-build event into the userprofile directory.
<PropertyGroup Label="UserMacros">
<CwAPI3D>./CwAPI3D/includes</CwAPI3D>
<USERPROFILE_API>D:\cadwork\userprofil_30\3d\API.x64</USERPROFILE_API>
<AssemblyName>CwAPI3D.Net.Bridge</AssemblyName>
<API_NAME>CwAPI3D.Net.Bridge</API_NAME>
</PropertyGroup>
Setup config file for .net assembly
This file must be located in the plugin directory (userprofil_30\3d\API.x64\YourPlugin\library.config)
The file needs the following name library.config
netLibraryName=yourSuperDotNetLibrary
initializerNamespace=yourNamespace
If the file does not exist, the defaults are:
netLibraryName=examplelibinitializerNamespace=examplelib
In my case, the structure looks like this.
Directory of D:\cadwork\userprofil_30\3d\API.x64\CwAPI3D.Net.Bridge
29/04/2024 09:48 992,256 CwAPI3D.Net.Bridge.dll (C++/CLI Library)
29/04/2024 09:33 5,632 yourSuperDotNetLibrary.dll (Pure C# Library)
29/04/2024 09:33 60 library.config (Config File)
Prerequisites
- Visual Studio 2022 or JetBrains Rider
- .NET Framework 4.8
- Install C++/CLI support in Visual Studio (Visual Studio Installer → Modify → Individual Components → C++/CLI support)
C++ CLI
Walkthrough: Compile a C++/CLI program
C++/CLI Syntax
using namespace System;
////////////////////////// managed C# code //////////////////////////
public ref class Greeter
{
public:
Greeter(String^ name)
{
this->name = name;
}
String^ Greet()
{
return "Hello, " + name;
}
private:
String^ name;
}
////////////////////////// native CXX code //////////////////////////
public ref class MyClass
{
public:
MyClass()
{
mPoint = new C3dPoint();
}
explicit MyClass(const double aX, const double aY, const double aZ)
{
Console::WriteLine("Hello from C++/CLI!");
mPoint = new C3dPoint(aX, aY, aZ);
}
explicit MyClass(const C3dPoint% p)
{
mPoint = new C3dPoint(p);
}
// Destructor
~MyClass()
{
this->!MyClass();
}
// Finalizer
!MyClass()
{
Console::WriteLine("Finalizer from C++/CLI!");
delete mPoint;
}
property C3dPoint* Point
{
C3dPoint* get()
{
return mPoint;
}
}
private:
C3dPoint* mPoint;
};
Design CwAPI3D Controller Implementation (Bridge Pattern)
classDiagram
IAttributeController-DotNet <|-- AttributeController-DotNet
IAttributeController-DotNet "1" *-- "1" IAttributeController-CPP : has
IAttributeController-CPP <|-- AttributeController-CPP
class IAttributeController-DotNet {
+GetName()
}
class AttributeController-DotNet {
- instance: IAttributeController-CPP
+GetName()
}
class IAttributeController-CPP {
+getName()*
}
class AttributeController-CPP {
+getName()
}
Debugging
Debugging in Visual Studio
- Open the project in Visual Studio.
- Set the project to run in 64-bit mode.
- Set the project to run in Debug mode.
- Attach the debugger to the process
3d.exe.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Contributing Back
If you extend or improve the CwAPI3D bridge, please commit your changes back to this repository. This way, all users can benefit from the enhancements. Your contributions help make the CwAPI3D .NET bridge better for everyone.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.