Creating Serial Numbers (C#) 您所在的位置:网站首页 numbers格式刷如何选择格式 Creating Serial Numbers (C#)

Creating Serial Numbers (C#)

2023-06-10 18:47| 来源: 网络整理| 查看: 265

此示例展示如何使用Visual C#编写的Add-ins为文件数据卡生成序列号。

注意事项:

SOLIDWORKS PDM Professional无法强制重新加载用.NET编写的Add-ins,必须重新启动所有客户端计算机,以确保使用Add-ins的最新版本。

SOLIDWORKS PDM Professional建议使用内置格式字符串或列表生成序列号。它们提供了比Add-ins生成的序列号或文件序列号更好的性能。仅当内置格式字符串或列表不足时,才编写Add-ins以生成序列号。

序列号编码器与其他类型挂钩的区别在于:

在IEdmAddIn5::GetAddInInfo方法中注册你的钩子。在IEdmAddIn5::OnCmd方法中编写内容。

 启动VS。新建项目,选择类库。在“解决方案资源管理器”中右键单击项目名称 ,然后单击添加引用。

单击 COM 在 左侧面板,单击PDMWorks Enterprise 2019 Type Library,然后单击添加。

如果需要,引入相关的程序集。设置Interop.EdmLib的嵌入互操作类型为False。在“解决方案资源管理器”中右击项目名称,然后单击“属性”。 “应用程序>程序集信息”。取消勾选“使程序集 COM 可见(M)”。修改Class1.cs。这里修改类名为MySerial.cs。 添加和创建GUID。修改代码 using System; using System.Runtime.InteropServices;//添加 using EdmLib;//添加 namespace Creating_Serial_Numbers​​ { [Guid("90C81B4A-560D-4FBF-9F08-E670D4ABB892"), ComVisible(true)] public class MySerial:IEdmAddIn5 { } } 实现 IEdmAddIn5::GetAddInInfo 和IEdmAddIn5::OnCmd         ​ using System; using System.Runtime.InteropServices;//添加 using EdmLib;//添加 namespace Creating_Serial_Numbers​​ { [Guid("90C81B4A-560D-4FBF-9F08-E670D4ABB892"), ComVisible(true)] public class MySerial:IEdmAddIn5 { public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr) { //Return information about this add-in to the Administrate Add-ins dialog poInfo.mbsAddInName = "My serial number generator"; poInfo.mbsCompany = "The name of my company"; poInfo.mbsDescription = "Implements serial numbers"; poInfo.mlAddInVersion = 1; poInfo.mlRequiredVersionMajor = 5; poInfo.mlRequiredVersionMinor = 2; //Notify that a serial number needs to be generated poCmdMgr.AddHook(EdmCmdType.EdmCmd_SerialNo); ​​ } public void OnCmd(ref EdmCmd poCmd, ref Array ppoData) { //Check the upper and lower bounds of the array int Index = ppoData.GetLowerBound(0);//获取数组中指定维度第一个元素的索引。 int last = ppoData.GetUpperBound(0);//获取数组中指定维度最后一个元素的索引。 if (Index 文件卡 -> Text Card,选择Title后面的Textbox,在右侧窗口选择序列号,我的序列号,保存数据卡。    

在库中新建text文件。    

 打包:https://download.csdn.net/download/hd51cc/87887157



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有