添加项目文件。

This commit is contained in:
GG Z
2026-02-28 21:01:57 +08:00
parent 9fe4e5a9aa
commit 7a229067cc
175 changed files with 18060 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#include "pch.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
[assembly:AssemblyTitleAttribute(L"MstnAPIAssist")];
[assembly:AssemblyDescriptionAttribute(L"")];
[assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"")];
[assembly:AssemblyProductAttribute(L"MstnAPIAssist")];
[assembly:AssemblyCopyrightAttribute(L"版权所有(c) 2025")];
[assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")];
[assembly:AssemblyVersionAttribute(L"1.0.*")];
[assembly:ComVisible(false)];

View File

@@ -0,0 +1,52 @@
#include "../pch.h"
#include "ElementHelper.h"
#include <vector>
#include <msclr/marshal.h>
#include "../Native/CElementHelper.h"
void BRDI::MstnAPI::ElementHelper::CreateLineElement(GeomNet::DPoint3d startPoint, GeomNet::DPoint3d endPoint)
{
DPoint3dCP pStartPoint = reinterpret_cast<DPoint3dCP>(&startPoint); // GeomNet::DPoint3d是值类型位于调用栈不需要固定直接取地址
DPoint3dCP pEndPoint = reinterpret_cast<DPoint3dCP>(&endPoint);
CElementHelper elemHelper;
elemHelper.CreateLineElement(pStartPoint, pEndPoint);
}
void BRDI::MstnAPI::ElementHelper::CreateLineStringElement(array<GeomNet::DPoint3d>^ points)
{
pin_ptr<GeomNet::DPoint3d> pPoints = &points[0]; // array<GeomNet::DPoint3d>^位于托管堆,需要先固定
DPoint3dCP pNativePoint = reinterpret_cast<DPoint3dCP>(pPoints);
int pointCount = points->Length;
CElementHelper elemHelper;
elemHelper.CreateLineStringElement(pNativePoint, pointCount);
}
void BRDI::MstnAPI::ElementHelper::CreateCurveElement(GeomNet::CurveVector^ curveVector)
{
CurveVectorCP pCurveVector = static_cast<CurveVectorCP>(GeomNet::CurveVector::DereferenceToNative(curveVector, false).ToPointer());
CElementHelper elemHelper;
elemHelper.CreateCurveElement(pCurveVector);
}
void BRDI::MstnAPI::ElementHelper::BodyFromLoft(array<GeomNet::CurveVector^>^ profiles, DgnPlatformNET::DgnModelRef^ dgnModelRef)
{
std::vector<CurveVectorPtr> curveVectorPtrs;
for each (GeomNet::CurveVector ^ profile in profiles)
{
CurveVectorPtr pCurveVector = static_cast<CurveVectorP>(GeomNet::CurveVector::DereferenceToNative(profile, false).ToPointer());
curveVectorPtrs.push_back(pCurveVector);
}
int profileCount = profiles->Length;
DgnModelRefP pDgnModelRef = static_cast<DgnModelRefP>(dgnModelRef->GetNative().ToPointer());
CElementHelper elemHelper;
elemHelper.BodyFromLoft(&curveVectorPtrs[0], profileCount, pDgnModelRef);
}
void BRDI::MstnAPI::ElementHelper::ShowMessage(String^ message)
{
msclr::interop::marshal_context context;
WCharCP msg = context.marshal_as<WCharCP>(message);
CElementHelper elemHelper;
elemHelper.ShowMessage(msg);
}

View File

@@ -0,0 +1,21 @@
#pragma once
#include "../Native/CElementHelper.h"
using namespace System;
namespace GeomNet = Bentley::GeometryNET;
namespace BRDI
{
namespace MstnAPI {
ref class ElementHelper
{
public:
void CreateLineElement(GeomNet::DPoint3d startPoint, GeomNet::DPoint3d endPoint);
void CreateLineStringElement(array<GeomNet::DPoint3d>^ points);
void CreateCurveElement(GeomNet::CurveVector^ curveVector);
void BodyFromLoft(array<GeomNet::CurveVector^>^ profiles, DgnPlatformNET::DgnModelRef^ dgnModelRef);
void ShowMessage(String^ message);
};
}
}

View File

@@ -0,0 +1,4 @@
#include "pch.h"
#include "MstnAPIAssist.h"

View File

@@ -0,0 +1,10 @@
#pragma once
using namespace System;
namespace MstnAPIAssist {
public ref class Class1
{
// TODO: 在此处为此类添加方法。
};
}

View File

@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectGuid>{BBFFA80D-71A2-AC08-B610-D8B3B7383D82}</ProjectGuid>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>MstnAPIAssist</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);winNT</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Program Files\Bentley\MicroStation2024SDK\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>mdlbltin.lib;
Bentley.lib
;BentleyAllocator.lib;
DgnPlatform.lib;
RmgrTools.lib
;DgnView.lib
;BentleyGeom.lib
;PSolidCore.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>C:\Program Files\Bentley\MicroStation2024SDK\library</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Native\CElementHelper.h" />
<ClInclude Include="Managed\ElementHelper.h" />
<ClInclude Include="MstnAPIAssist.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="Resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="Native\CElementHelper.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Managed\ElementHelper.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="MstnAPIAssist.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="app.ico" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Bentley.DgnPlatformNET">
<HintPath>C:\Program Files\Bentley\MicroStation 2024\MicroStation\Bentley.DgnPlatformNET.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Bentley.GeometryNET">
<HintPath>C:\Program Files\Bentley\MicroStation 2024\MicroStation\Bentley.GeometryNET.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Bentley.GeometryNET.Structs">
<HintPath>C:\Program Files\Bentley\MicroStation 2024\MicroStation\Bentley.GeometryNET.Structs.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MstnAPIAssist.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Native\CElementHelper.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Managed\ElementHelper.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MstnAPIAssist.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="AssemblyInfo.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Native\CElementHelper.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Managed\ElementHelper.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="app.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,55 @@
#include "../pch.h"
#include "CElementHelper.h"
#include <Mstn/MdlApi/MdlApi.h>
#include <DgnPlatform/DgnPlatformApi.h>
#include <Mstn/ISessionMgr.h>
#include <PSolid/PSolidCoreAPI.h>
#include <cassert>
USING_NAMESPACE_BENTLEY_DGNPLATFORM
USING_NAMESPACE_BENTLEY_MSTNPLATFORM
USING_NAMESPACE_BENTLEY_MSTNPLATFORM_ELEMENT
void CElementHelper::CreateLineElement(DPoint3dCP pStartPoint, DPoint3dCP pEndPoint)
{
DgnModelRefP pActiveModel = ISessionMgr::GetActiveDgnModelRefP();
DSegment3d segment = DSegment3d::From(*pStartPoint, *pEndPoint);
EditElementHandle eeh;
LineHandler::CreateLineElement(eeh, nullptr, segment, pActiveModel->Is3d(), *pActiveModel);
eeh.AddToModel();
}
void CElementHelper::CreateLineStringElement(DPoint3dCP pPoints, int pointCount)
{
assert(pPoints != nullptr && pointCount >= 2);
DgnModelRefP pActiveModel = ISessionMgr::GetActiveDgnModelRefP();
EditElementHandle eeh;
LineStringHandler::CreateLineStringElement(eeh, nullptr, pPoints, pointCount, pActiveModel->Is3d(), *pActiveModel);
eeh.AddToModel();
}
void CElementHelper::CreateCurveElement(CurveVectorCP pCurveVector)
{
assert(pCurveVector != nullptr);
DgnModelRefP pActiveModel = ISessionMgr::GetActiveDgnModelRefP();
EditElementHandle eeh;
DraftingElementSchema::ToElement(eeh, *pCurveVector, nullptr, pActiveModel->Is3d(), *pActiveModel);
eeh.AddToModel();
}
void CElementHelper::BodyFromLoft(CurveVectorPtr* pCurveVectorPtr, int profileCount, DgnModelRefP pDgnModelRef)
{
assert(pCurveVectorPtr != nullptr && profileCount >= 2);
ISolidKernelEntityPtr solidPtr;
BentleyStatus status = SolidUtil::Create::BodyFromLoft(solidPtr, pCurveVectorPtr, profileCount, nullptr, 0, *pDgnModelRef);
assert(status == SUCCESS && solidPtr.IsValid());
EditElementHandle eeh;
DraftingElementSchema::ToElement(eeh, *solidPtr, nullptr, *pDgnModelRef);
eeh.AddToModel();
}
void CElementHelper::ShowMessage(WCharCP message)
{
mdlDialog_dmsgsPrint(message);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include <Mstn/MdlApi/MdlApi.h>
class CElementHelper
{
public:
void CreateLineElement(DPoint3dCP pStartPoint, DPoint3dCP pEndPoint);
void CreateLineStringElement(DPoint3dCP pPoints, int pointCount);
void CreateCurveElement(CurveVectorCP pCurveVector);
void BodyFromLoft(CurveVectorPtr* pCurveVectorPtr, int profileCount, DgnModelRefP pDgnModelRef);
void ShowMessage(WCharCP message);
};

3
MstnAPIAssist/Resource.h Normal file
View File

@@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 使用者 app.rc

BIN
MstnAPIAssist/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
MstnAPIAssist/app.rc Normal file

Binary file not shown.

5
MstnAPIAssist/pch.cpp Normal file
View File

@@ -0,0 +1,5 @@
// pch.cpp: 与预编译标头对应的源文件
#include "pch.h"
// 当使用预编译的头时,需要使用此源文件,编译才能成功。

12
MstnAPIAssist/pch.h Normal file
View File

@@ -0,0 +1,12 @@
// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
#ifndef PCH_H
#define PCH_H
// 添加要在此处预编译的标头
#endif //PCH_H