Tecnomatix 二次开发入门教程 3

第一个hello World程序

通过创建一个Hello World的消息框,来熟悉Tecnomatix 二次开发流程。具体步骤如下:

(1)使用Visual Studio 创建 C# Class 库
(2) 添加 Tecnomatix.Engineer.dll引用 设置copy local = false
(3)设置output 路径到 tecnomatix empower DoneTCommand路径下;
(4)Add new public class
  • 添加 using tecnomatix.engineering
  • 继承 TxButtonCommand
  • 设置Name return;
  • 设置Category return
  • Execute Command 实现弹出对话框(添加引用Windows Forms)
    TxMessageBox.Show("Hello World", "TecnomatixTraining", MessageBoxButtons.OK, MessageBoxIcon.Information);

实现代码如下(VB.Net 版本,可以自行转为C#版本):

Imports Tecnomatix.Engineering
Imports System.Windows.Forms
''' <summary>
''' Tecnomatix 二次开发入门教程 3
''' </summary>
''' <remarks></remarks>
Public Class Class3 : Inherits TxButtonCommand
    Public Overrides ReadOnly Property Category As String
        Get
            Return "testPDPS"
        End Get
    End Property

    Public Overrides Sub Execute(cmdParams As Object)
        TxMessageBox.Show("Hello World", "TecnomatixTraining", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Public Overrides ReadOnly Property Name As String
        Get
            Return "Command3"
        End Get
    End Property
End Class
(5) 注册命令

将程序集DLL放在<Installation dir> \ DotNetCommands \或其子目录中。建议将此目录预设为“构建配置属性”的“输出路径”字段中的路径。
通过运行CommandReg应用程序将命令注册(集成)到Tecnomatix产品中。

CommandReg.exe位于安装目录下,默认情况下为C:\ Program Files \ Tecnomatix \ eMPower。
使用CommandReg,可以将命令配置添加到.xml文件中,该文件包含将命令集成到所需产品所需的所有信息。因此,它可以与命令程序集一起分发,以便将其集成到其他计算机中。
要正常工作,.xml文件必须位于<安装目录> \ DotNetExternalApplications下。无需为分发.xml文件的每台计算机单独运行CommandReg.exe。唯一的要求是在这些计算机上,将文件放在<Installation dir> \ DotNetExternalApplications位置。

  • 浏览到包含新命令的程序集。
  • 从“类”列表中选择要添加的命令。
  • 选择要添加命令的产品。 (产品根据您的安装列出。)
  • 选择.xml文件名。
  • 创建新的.xml文件或将命令添加到<Installation dir> \ DotNetExternalApplications目录下的现有.xml。
  • 单击注册。命令注册将添加到选定的.xml文件中。
  • 要使用CommandReg从产品中取消注册命令,请选择与此命令集成的.xml文件,然后单击“取消注册”。保存此命令注册的部分将从.xml文件中删除。

以下为xml注册文件内容

<?xml version="1.0" encoding="UTF-8"?>
<TecnomatixConfigurationData>
  <ConfigurationsSection>
    <Configuration ID="viewer" Name="viewer">
      <DotNetCommands>
        <Assembly File="DotNetCommands\testPDPS001.dll">
          <DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
        </Assembly>
      </DotNetCommands>
    </Configuration>
    <Configuration ID="newassemblertc" Name="newassemblertc">
      <DotNetCommands>
        <Assembly File="DotNetCommands\testPDPS001.dll">
          <DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
        </Assembly>
      </DotNetCommands>
    </Configuration>
    <Configuration ID="newassembler" Name="newassembler">
      <DotNetCommands>
        <Assembly File="DotNetCommands\testPDPS001.dll">
          <DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
        </Assembly>
      </DotNetCommands>
    </Configuration>
    <Configuration ID="newviewer" Name="newviewer">
      <DotNetCommands>
        <Assembly File="DotNetCommands\testPDPS001.dll">
          <DotNetCommand Namespace="testPDPS001" ClassName="Class3" />
        </Assembly>
      </DotNetCommands>
    </Configuration>
  </ConfigurationsSection>
</TecnomatixConfigurationData>
(6)通过Customize Ribbon 找到注册的菜单

“自定义” 添加新命令。然后,将其拖动到工具栏或菜单中,单击即可执行。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容