类似这种,避免每次去找exe文件.
流程,
1# 准备cs macro文件和图标文件
下面的是宏的内容
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Tekla.Structures.ModelInternal;
using Tekla.Structures.Internal;
using System;
namespace Tekla.Technology.Akit.UserScript
{
public class Script
{
public static void Run(Tekla.Technology.Akit.IScript akit)
{
string exeProcessName = "SWH.Tekla.Commands";//exe的文件名称
string exeFileDirName = Environment.GetEnvironmentVariable("OneDrive") +
"\\MyCodeHub\\SWH.Tekla.Commands\\bin\\Debug\\";//发布的exe的目录
string exeNetDriveFileName = Path.Combine(exeFileDirName, exeProcessName + ".exe");//最新的exe的目录
string exeLocalDriveFileName = Path.Combine(Path.GetTempPath(), exeProcessName + ".exe");//本机的exe的目录
var pros = Process.GetProcessesByName(exeProcessName);
if (pros.Length == 0)
{
Process NewProcess = new Process();
if (File.Exists(exeNetDriveFileName))
{
File.Copy(exeNetDriveFileName, exeLocalDriveFileName, true);
NewProcess.StartInfo.FileName = exeLocalDriveFileName;
try
{
NewProcess.Start();
}
catch
{
MessageBox.Show("Starting " + exeLocalDriveFileName + " failed.");
}
}
else MessageBox.Show(exeNetDriveFileName + " not found.");
}
else
{
MessageBox.Show(exeProcessName + "已开启,无需重复开启!");
}
}
}
}
2#将cs文件和图标复制到对应的目录
下面的复制的脚本
echo off rem //C:\ProgramData\Trimble\Tekla Structures\2022.0\Environments\common\macros\modeling
rem //C:\ProgramData\Trimble\Tekla Structures\2022.0\Environments\common\macros\drawings
set modelingDir="C:\ProgramData\Trimble\Tekla Structures\2022.0\Environments\common\macros\modeling"
set drawingsDir="C:\ProgramData\Trimble\Tekla Structures\2022.0\Environments\common\macros\drawings"
echo
for %%a in (*.cs) do copy %%a %modelingDir%\%%a /y
for %%b in (*.bmp) do copy %%b %modelingDir%\%%b /y
for %%c in (*.cs) do copy %%c %drawingsDir%\%%c /y
for %%d in (*.bmp) do copy %%d %drawingsDir%\%%d /y
@pause
测试效果挺好
标签:TEKLA,Tekla,exe,%%,exeProcessName,二次开发,using,Structures From: https://www.cnblogs.com/NanShengBlogs/p/18005199