跳转至

2025年09月

太原锅炉方案分析

方案一

先将所有零部件做成块
  • 所有的块需要遵循一个原则;要么所有图块的插入的基点在左边,要么基点在右边,建议统一个标准
  • 所有的块名定义按照**块名+视图**来命名
  • 如果有多个同名的块名,形状在2d上略有不同,那么块名---->**块名[编号]+视图**来命名
  • 件号需要重新插入,插入的时候选择零部件进行关联
  • 定型尺寸需要重新绘制在零部件的外框尺寸上
其它说明

[!WARNING]

由于存在块的尺寸与真实尺寸不一样的情况,这样定位尺寸和定型尺寸都不对

  • 需要保证尺寸标注标注在块的外框上
  • 除了在最左侧或最右侧的基准点,如果基准点在中间,需要保证基准点刚好是块的几何中心点

[!TIP]

  • 图纸上的尺寸标注数据基本都能提取出来,但是数据与块之间是没有关联关系的,需要人为去做一些处理告知程序这两者之间是有关联(比如在块上重新绘制标注信息)
  • 做成块是为了让零部件都是个整体,方便重新绘制件号与零部件关联,这样零部件对应的明细表信息就与部件关联起来了
我们能做什么
  • 将所有与块关联的尺寸提取出来
  • 将所有与块关联的明细表数据提取出来
  • 定位尺寸和定型尺寸如果不是真实尺寸,
  • 图纸上需要在块外框上标注尺寸
  • 需要保证基准点在最左端或最右端,或者在图块的中心,不然定位尺寸算不准
  • 开目图纸里的标注数据,如果只有一个文字可以将数据提取出来,但是与零部件的关联关系基本上是没有的
我们做不了什么
  • 提取的尺寸数据是有限的,如果没有关联关系,我们是无法将数据与图块进行联系
  • 开目图纸里除了只有一个文字的标注尺寸,其它的尺寸我们无法提取。文字数据太多也不清楚各个数据之间的关系以及表达方式。
  • 图块与图块之间是体现不了装配关系,所以单纯用图块来描述装配关系是描述不了
  • Excel表格大概需要109条数据,我们只能提取明细表的数据以及定位和定型尺寸数据

方案二

将所有的零部件做成块,然后为所有的零部件块增加自定义属性,

avatar

  • 每个零部件都增加一些自定义属性,零部件有一部分常规属性从图纸中获取,有一部分手动填写。
  • 自定义属性的好处在于,不管是要定型尺寸还是定位尺寸都可以手动填写。
  • 如果自动获取的数据不对也可以手动更改,方便随时调整更新
  • 不管什么数据都可以定义一个自定义信息
  • 不管是定型尺寸、定位尺寸、装配关系等,都可以自定义属性信息手动填写
  • 所有的数据都存储在当前dwg中,方便数据的导出

Vs自定义项目模板

image-20250415192756364

先配置好项目相关文件

导出项目相关文件

image-20250415192839962

导出为项目

image-20250415193017914

image-20250415193036748

image-20250415193112362

取消,需要对压缩文件进行处理

处理压缩包

image-20250415193410753

修改数据

img

修改完成后将压缩包放置到Visual Studio 2022\Templates\ProjectTemplates

Text Only
Visual Studio 2022\Templates\ProjectTemplates

image-20250415193604984

Text Only
MyTemplate.vstemplate
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    <Name>ZwObjectZrxNet</Name>
    <Description>ObjectZRX+WPF模板</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>ZwObjectZrxNet</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>__TemplateIcon.ico</Icon>
    <PreviewImage>__PreviewImage.ico</PreviewImage>
    <LanguageTag>CSharp</LanguageTag>
    <PlatformTag>Windows</PlatformTag>
    <ProjectTypeTag>Library</ProjectTypeTag>
  </TemplateData>
  <TemplateContent>
    <Project TargetFileName="$safeprojectname$.csproj" File="$safeprojectname$.csproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true" TargetFileName="app.config">app.config</ProjectItem>
      <ProjectItem ReplaceParameters="true" TargetFileName="Commands.cs">Commands.cs</ProjectItem>
      <Folder Name="Controls" TargetFolderName="Controls" />
      <Folder Name="Converters" TargetFolderName="Converters">
        <ProjectItem ReplaceParameters="true" TargetFileName="OptionToBooleanConverter.cs">OptionToBooleanConverter.cs</ProjectItem>
      </Folder>
      <Folder Name="Models" TargetFolderName="Models" />
      <ProjectItem ReplaceParameters="true" TargetFileName="packages.config">packages.config</ProjectItem>
      <ProjectItem ReplaceParameters="true" TargetFileName="PlugInApplication.cs">PlugInApplication.cs</ProjectItem>
      <Folder Name="Properties" TargetFolderName="Properties">
        <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
      </Folder>
      <Folder Name="Styles" TargetFolderName="Styles">
        <ProjectItem ReplaceParameters="true" TargetFileName="Styles.xaml">Styles.xaml</ProjectItem>
      </Folder>
      <Folder Name="ViewModel" TargetFolderName="ViewModel">
        <ProjectItem ReplaceParameters="true" TargetFileName="WpfDemoViewModel.cs">WpfDemoViewModel.cs</ProjectItem>
      </Folder>
      <Folder Name="Views" TargetFolderName="Views">
        <ProjectItem ReplaceParameters="true" TargetFileName="WpfDemo.xaml">WpfDemo.xaml</ProjectItem>
        <ProjectItem ReplaceParameters="true" TargetFileName="WpfDemo.xaml.cs">WpfDemo.xaml.cs</ProjectItem>
      </Folder>
    </Project>
  </TemplateContent>
</VSTemplate>

Csharp

Text Only
$safeprojectname$.csproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{$guid1$}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>$safeprojectname$</RootNamespace>
    <AssemblyName>$safeprojectname$</AssemblyName>
    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>..\..\Out\Debug\bin\x64\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>..\..\Out\Release\bin\x64\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <LangVersion>7.3</LangVersion>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="CommunityToolkit.Mvvm, Version=8.4.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2, processorArchitecture=MSIL">
      <HintPath>..\packages\CommunityToolkit.Mvvm.8.4.0\lib\netstandard2.0\CommunityToolkit.Mvvm.dll</HintPath>
    </Reference>
    <Reference Include="MaterialDesignColors, Version=5.2.1.0, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
      <HintPath>..\packages\MaterialDesignColors.5.2.1\lib\net462\MaterialDesignColors.dll</HintPath>
    </Reference>
    <Reference Include="MaterialDesignThemes.Wpf, Version=5.2.1.0, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
      <HintPath>..\packages\MaterialDesignThemes.5.2.1\lib\net462\MaterialDesignThemes.Wpf.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.39\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
    </Reference>
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
    </Reference>
    <Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
    </Reference>
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
    </Reference>
    <Reference Include="System.Numerics" />
    <Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
    </Reference>
    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
    </Reference>
    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
    </Reference>
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xaml" />
    <Reference Include="WindowsBase" />
    <Reference Include="WindowsFormsIntegration" />
    <Reference Include="ZcCui">
      <HintPath>$(ZrxSdk2025)\inc\ZcCui.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="ZcWindows">
      <HintPath>$(ZrxSdk2025)\inc\ZcWindows.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="ZdWindows">
      <HintPath>$(ZrxSdk2025)\inc\ZdWindows.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="ZwDatabaseMgd">
      <HintPath>$(ZrxSdk2025)\inc\ZwDatabaseMgd.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="ZwDatabaseMgdBrep">
      <HintPath>$(ZrxSdk2025)\inc\ZwDatabaseMgdBrep.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="ZwManaged">
      <HintPath>$(ZrxSdk2025)\inc\ZwManaged.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Commands.cs" />
    <Compile Include="Converters\OptionToBooleanConverter.cs" />
    <Compile Include="PlugInApplication.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="ViewModel\WpfDemoViewModel.cs" />
    <Compile Include="Views\WpfDemo.xaml.cs">
      <DependentUpon>WpfDemo.xaml</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Controls\" />
    <Folder Include="Models\" />
  </ItemGroup>
  <ItemGroup>
    <Page Include="Styles\Styles.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
    <Page Include="Views\WpfDemo.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
    <None Include="packages.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Import Project="..\packages\MaterialDesignThemes.5.2.1\build\MaterialDesignThemes.targets" Condition="Exists('..\packages\MaterialDesignThemes.5.2.1\build\MaterialDesignThemes.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\MaterialDesignThemes.5.2.1\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MaterialDesignThemes.5.2.1\build\MaterialDesignThemes.targets'))" />
    <Error Condition="!Exists('..\packages\CommunityToolkit.Mvvm.8.4.0\build\CommunityToolkit.Mvvm.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CommunityToolkit.Mvvm.8.4.0\build\CommunityToolkit.Mvvm.targets'))" />
  </Target>
  <Import Project="..\packages\CommunityToolkit.Mvvm.8.4.0\build\CommunityToolkit.Mvvm.targets" Condition="Exists('..\packages\CommunityToolkit.Mvvm.8.4.0\build\CommunityToolkit.Mvvm.targets')" />
</Project>

Csharp

image-20250416092345724

模版参数

.Net封装ObjectARX自定义实体类型

参考Github ManagedCircle

使用ARX自带的向导

选择.NET mixed managed code support工程

将props中关于arx的删除

配置信息按照如下所示:

image-20250407193241272

image-20250407193257438

image-20250407193310752

image-20250407193323409

image-20250407193335187

关于主代码

image-20250407193517842

acrxEntryPoint.cpp

C++
//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#include "ZwSerialNoMgd.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("")
AC_DECLARE_EXTENSION_MODULE(MgdWrapperDLL) ;
static AcMgObjectFactoryBase** g_PEs = NULL;

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CMgdWrapperApp : public AcRxArxApp {

public:
    CMgdWrapperApp() : AcRxArxApp() {}

    virtual AcRx::AppRetCode On_kInitAppMsg(void *pkt) {
        // TODO: Load dependencies here
        // Save critical data pointers before running the constructors (see afxdllx.h for details)
        AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
        pModuleState->m_pClassInit = pModuleState->m_classList;
        pModuleState->m_pFactoryInit = pModuleState->m_factoryList;
        pModuleState->m_classList.m_pHead = NULL;
        pModuleState->m_factoryList.m_pHead = NULL;

        MgdWrapperDLL.AttachInstance (_hdllInstance) ;
        InitAcUiDLL () ;

        // You *must* call On_kInitAppMsg here
        AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt);

        // TODO: Add your initialization code here
        AcMgObjectFactoryBase* PEs[] =
        {
            new AcMgObjectFactory<ZDN::CustomWrapper::ZwSerialNoMgd, CZwSerialNo>(),
                    NULL
        };

        g_PEs = PEs;
        return (retCode);
    }

    virtual AcRx::AppRetCode On_kUnloadAppMsg(void *pkt) {
        // TODO: Add your code here
        int i = 0;
        while (g_PEs[i] != NULL)
            delete g_PEs[i++];
        // You *must* call On_kUnloadAppMsg here
        AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt);

        // TODO: Unload dependencies here
        MgdWrapperDLL.DetachInstance () ;

        return (retCode);
    }

    virtual void RegisterServerComponents() {
    }
};

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CMgdWrapperApp)

image-20250407193555427

stdafx.h

C++
#pragma once
#define MGDWRAPPER_MODULE

#pragma pack (push, 8)
#pragma warning(disable: 4786 4996)
//#pragma warning(disable: 4098)

//-----------------------------------------------------------------------------
#define STRICT

#include <sdkddkver.h>

//- ObjectARX and OMF headers needs this
#include <map>

//-----------------------------------------------------------------------------
#include <afxwin.h>             //- MFC core and standard components
#include <afxext.h>             //- MFC extensions
#include <afxcmn.h>             //- MFC support for Windows Common Controls

//-----------------------------------------------------------------------------
#using <mscorlib.dll>
#using <System.dll>

//#using <acdbmgd.dll>
//#using <acmgd.dll>
//#using <AcCui.dll>

#include <vcclr.h>
//-----------------------------------------------------------------------------
#include <afxwin.h>             //- MFC core and standard components
#include <afxext.h>             //- MFC extensions

#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h>             //- MFC OLE classes
#include <afxodlgs.h>           //- MFC OLE dialog classes
#include <afxdisp.h>            //- MFC Automation classes
#endif // _AFX_NO_OLE_SUPPORT

#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h>              //- MFC ODBC database classes
#endif // _AFX_NO_DB_SUPPORT

#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h>             //- MFC DAO database classes
#endif // _AFX_NO_DAO_SUPPORT

#include <afxdtctl.h>           //- MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>             //- MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//-----------------------------------------------------------------------------
//- Include ObjectDBX/ObjectARX headers
//- Uncomment one of the following lines to bring a given library in your project.
//#define _BREP_SUPPORT_                    //- Support for the BRep API
//#define _HLR_SUPPORT_                     //- Support for the Hidden Line Removal API
//#define _AMODELER_SUPPORT_                //- Support for the AModeler API
//#define _ASE_SUPPORT_                         //- Support for the ASI/ASE API
//#define _RENDER_SUPPORT_                  //- Support for the AutoCAD Render API
//#define _ARX_CUSTOM_DRAG_N_DROP_  //- Support for the ObjectARX Drag'n Drop API
//#define _INC_LEAGACY_HEADERS_         //- Include legacy headers in this project
#include "arxHeaders.h"

#include <afxcview.h>
//-----------------------------------------------------------------------------
#include "DocData.h" //- Your document specific data class holder

//- Declare it as an extern here so that it becomes available in all modules
extern AcApDataManager<CDocData> DocVars ;

#pragma pack (pop)

image-20250407193816704

ZwSerialNoMgd.h

C++
#pragma once
#include <CZwSerialNo.h>
using namespace System ;
using namespace ZwSoft::ZwCAD::Geometry ;
using namespace  ZwSoft::ZwCAD::DatabaseServices ;
namespace ZDN
{
    namespace CustomWrapper
    {
        [ZwSoft::ZwCAD::Runtime::Wrapper("CZwSerialNo")] 
        public ref class ZwSerialNoMgd
            : public ZwSoft::ZwCAD::DatabaseServices::Entity 
        {
         public:
          //- Constructor
          ZwSerialNoMgd();

        internal:

          ZwSerialNoMgd(System::IntPtr unmanagedPointer, bool bAutoDelete);

          //- Returns the unmanaged ARX Object
          inline CZwSerialNo *GetImpObj() {
            return (static_cast<CZwSerialNo *>(UnmanagedObject.ToPointer()));
          }

         public:
          void SetInsertPt(ZwSoft::ZwCAD::Geometry::Point3d center);
          void setScale(ZwSoft::ZwCAD::Geometry::Scale3d newScale);
          void setDescription(String ^ strDescription);
          void setTag(String ^ strDescription);
          void setValue(String ^ strDescription);
          void setGaugename(String ^ strDescription);
          void setGaugecode(String ^ strDescription);

         /* void setRadius(double radius);
          void gc2AcString(System::String ^ s);*/
          void convertFromMgdObjectId(ZwSoft::ZwCAD::DatabaseServices::ObjectId mgdId);
        };
    }

} // namespace ZDN

image-20250407193859988

ZwSerialNoMgd.cpp

C++
#include "StdAfx.h"
#include "ZwSerialNoMgd.h"
#include <gcroot.h>
#include "zmgdinterop.h"

ZDN::CustomWrapper::ZwSerialNoMgd::ZwSerialNoMgd() :
    ZwSoft::ZwCAD::DatabaseServices::Entity((System::IntPtr) new CZwSerialNo(), true)
{}
ZDN::CustomWrapper::ZwSerialNoMgd::ZwSerialNoMgd(System::IntPtr unmanagedPointer, bool bAutoDelete) :
    ZwSoft::ZwCAD::DatabaseServices::Entity(unmanagedPointer, bAutoDelete)
{}
void ZDN::CustomWrapper::ZwSerialNoMgd::SetInsertPt(ZwSoft::ZwCAD::Geometry::Point3d center)
{
    AcGePoint3d _center = GETPOINT3D(center);

    GetImpObj()->SetInsertPt(_center);
}

void ZDN::CustomWrapper::ZwSerialNoMgd::setScale(ZwSoft::ZwCAD::Geometry::Scale3d newScale)
{
    AcGeScale3d _center = GETSCALE3D(newScale);

    GetImpObj()->setScale(_center);
}

void ZDN::CustomWrapper::ZwSerialNoMgd::setDescription(String ^ strDescription)
{
    GetImpObj()->setDescription((LPCTSTR)StringToCIF(strDescription));
}

void ZDN::CustomWrapper::ZwSerialNoMgd::setTag(String ^ strDescription)
{
    GetImpObj()->setTag((LPCTSTR)StringToCIF(strDescription));
}

void ZDN::CustomWrapper::ZwSerialNoMgd::setValue(String ^ strDescription)
{
    GetImpObj()->setValue((LPCTSTR)StringToCIF(strDescription));
}

void ZDN::CustomWrapper::ZwSerialNoMgd::setGaugename(String ^ strDescription)
{
    GetImpObj()->setGaugename((LPCTSTR)StringToCIF(strDescription));
}

void ZDN::CustomWrapper::ZwSerialNoMgd::setGaugecode(String ^ strDescription)
{
    GetImpObj()->setGaugecode((LPCTSTR)StringToCIF(strDescription));
}

void ZDN::CustomWrapper::ZwSerialNoMgd::convertFromMgdObjectId(
    ZwSoft::ZwCAD::DatabaseServices::ObjectId mgdId)
{
    System::String ^ hStr = mgdId.Handle.ToString();
    UInt64     hInt = System::Convert::ToInt64(hStr, 16);
    AcDbHandle handle(hInt);

    AcDbObjectId      objId;
    Acad::ErrorStatus es =
        acdbHostApplicationServices()->workingDatabase()->getAcDbObjectId(objId, false, handle);
    if (es == Acad::eOk)
    {
        acutPrintf(ACRX_T("\nObjectClass from Id : %s"), objId.objectClass()->name());
    }
}

image-20250407193924510

.net中调用

C#
 [CommandMethod("TestNo")]
 public void TestNo()
 {
     Document doc = Application.DocumentManager.MdiActiveDocument;
     Database db = doc.Database;
     Editor ed = doc.Editor;

     PromptEntityOptions peo = new PromptEntityOptions("\nSelect custom object: ");
     peo.SetRejectMessage("\nInvalid selection...");
     peo.AddAllowedClass(typeof(ZwSerialNoMgd), true);

     PromptEntityResult per = ed.GetEntity(peo);

     if (per.Status != PromptStatus.OK)
         return;

     using (Transaction Tx = db.TransactionManager.StartTransaction())
     {
         ZwSerialNoMgd entity = Tx.GetObject(per.ObjectId, OpenMode.ForWrite)
             as ZwSerialNoMgd;

         entity.ColorIndex = 1;

         Tx.Commit();
     }
 }