Revit二次开发_使用InnoSetup打包插件

news/2024/9/19 18:38:29/ 标签: revit二次开发

InnoSetup是一个开源的安装包制作工具。

如果是简单的安装,例如安装流程只需要用户选一个安装路径,那么直接按引导操作就行,甚至不需要写代码。

如果有更复杂的需求,通常需要使用Inno支持的Pascal脚本进行自定义。

Inno打包程序脚本引导部分比较简单,资料网上也非常多,这里不再赘述。

对于Revit插件安装,特别的是最后要把addin文件复制到合适的位置,并且修改内容,指向对应文件,这部分网上内容相对少,记录一下。

下面三个示例,第一个是常规打包,

第二个与第一个类似,但增加了一个自定义页面,让用户设置一个资源存放的文件夹,计划用于存放依赖资源,

第三个则是通过调用一个外部程序来执行addin修改操作——如果对Pascal脚本不熟悉,可以用熟悉的语言写一个程序,然后在脚本中进行调用,从而执行类似操作

示例一(常规打包)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyRevitPlugin"
#define MyAppVersion "1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{782BAC7F-2B51-4378-B9CC-8559EB6E2CE7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=F:\packet_ex
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"// 调整dll路径;addin.template其实是常规的addin文件改了下文件名
[Files]
Source: "C:\Users\lisiting01\source\repos\MyRevitPlugin\MyRevitPlugin\bin\x64\Debug\MyRevitPlugin.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\addin\2019.addin.template"; DestDir: "{app}\addin"; Flags: ignoreversion[UninstallDelete]
Type: files; Name: "C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin"[Code]
varInstallPath: string;// CurStepChanged事件,安装阶段变化时触发
procedure CurStepChanged(CurStep: TSetupStep);
varAddinTemplateFile: string;AddinTargetFile: string;AddinContentANSI: AnsiString;AddinContentUCS: string;
begin// 到达 ssPostInstall 阶段时(安装后)触发事件if CurStep = ssPostInstall thenbegin// 安装路径InstallPath := ExpandConstant('{app}');// .addin 模板文件和目标文件路径AddinTemplateFile := InstallPath + '\addin\2019.addin.template';AddinTargetFile := 'C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin';// 注册 .addin 文件并指向到安装目录if LoadStringFromFile(AddinTemplateFile, AddinContentANSI) thenbeginAddinContentUCS := String(AddinContentANSI);StringChangeEx(AddinContentUCS, '{InstallPath}', InstallPath, True);SaveStringToFile(AddinTargetFile, AddinContentUCS, False);end;end;
end;

示例二(自定义页面)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyRevitPlugin"
#define MyAppVersion "1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{782BAC7F-2B51-4378-B9CC-8559EB6E2CE7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=F:\packet_ex
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"// 调整dll路径;addin.template其实是常规的addin文件改了下文件名
[Files]
Source: "C:\Users\lisiting01\source\repos\MyRevitPlugin\MyRevitPlugin\bin\x64\Debug\MyRevitPlugin.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\addin\2019.addin.template"; DestDir: "{app}\addin"; Flags: ignoreversion[UninstallDelete]
Type: files; Name: "{app}\Settings.ini"
Type: files; Name: "C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin"[Code]
varInstallPath: string;InputDirWizardPage: TInputDirWizardPage;// InitializeWizard事件,初始化安装向导时触发
procedure InitializeWizard;
begin// 创建自定义页面InputDirWizardPage := CreateInputDirPage(wpSelectDir, '设置资源文件夹路径', '这个文件夹将用于存放相关资源(族、贴图、渲染资源等)', '设置资源文件夹,然后点击下一步',True, 'BIMResource');InputDirWizardPage.Add('');InputDirWizardPage.Values[0] := ExpandConstant('{userdocs}')+'\BIMResource';end;// CurStepChanged事件,安装阶段变化时触发
procedure CurStepChanged(CurStep: TSetupStep);
varAddinTemplateFile: string;AddinTargetFile: string;AddinContentANSI: AnsiString;AddinContentUCS: string;ConfigFile: string;
begin// 到达 ssPostInstall 阶段时(安装后)触发事件if CurStep = ssPostInstall thenbegin// 安装路径InstallPath := ExpandConstant('{app}');// .addin 模板文件和目标文件路径AddinTemplateFile := InstallPath + '\addin\2019.addin.template';AddinTargetFile := 'C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin';// 配置文件路径ConfigFile := InstallPath + '\Settings.ini';// 注册 .addin 文件并指向到安装目录if LoadStringFromFile(AddinTemplateFile, AddinContentANSI) thenbeginAddinContentUCS := String(AddinContentANSI);StringChangeEx(AddinContentUCS, '{InstallPath}', InstallPath, True);SaveStringToFile(AddinTargetFile, AddinContentUCS, False);end;// 创建用户指定的资源文件夹CreateDir(InputDirWizardPage.Values[0]);// 设置配置文件SaveStringToFile(ConfigFile, 'BIMResource=' + InputDirWizardPage.Values[0] , False);end;
end;// 更新准备安装页的信息
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
varS: String;
beginS := '';S := S + '安装路径:' + NewLine;S := S + Space + ExpandConstant('{app}') + NewLine;S := S + NewLine;S := S + '资源路径:' + NewLine;S := S + Space + InputDirWizardPage.Values[0] + NewLine;Result := S;
end;

示例三(调用程序执行)

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!#define MyAppName "MyRevitPlugin"
#define MyAppVersion "1.0"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{782BAC7F-2B51-4378-B9CC-8559EB6E2CE7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=F:\packet_ex
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"// 调整dll路径;addin.template其实是常规的addin文件改了下文件名
[Files]
Source: "C:\Users\lisiting01\source\repos\MyRevitPlugin\MyRevitPlugin\bin\x64\Debug\MyRevitPlugin.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "F:\SetupProgram.exe"; DestDir: "{app}"; Flags: ignoreversion[UninstallDelete]
Type: files; Name: "C:\ProgramData\Autodesk\Revit\Addins\2019\RevitPlugin.addin"[Code]
varInstallPath: string;// CurStepChanged事件,安装阶段变化时触发
procedure CurStepChanged(CurStep: TSetupStep);
begin// 到达 ssPostInstall 阶段时(安装后)触发事件if CurStep = ssPostInstall thenbegin// 安装路径InstallPath := ExpandConstant('{app}');// 执行 SetupProgram.exeExec(ExpandConstant(InstallPath + '\SetupProgram.exe'), '', '', SW_SHOW, ewNoWait, ResultCode);end;
end;

资料:

InnoSetup文档:https://jrsoftware.org/ishelp.php

中文安装语言:https://github.com/kira-96/Inno-Setup-Chinese-Simplified-Translation


http://www.ppmy.cn/news/1511596.html

相关文章

Unity项目优化记录

背景:测试反馈项目组游戏存在内存泄露,来找到中台这边协调排查。好家伙,跑了两次看了内存快照,再看资源组织和管理方式,存在的问题确实比较多。 1、修复内存泄露:结算界面由于资源引用丢失导致整个面板不会…

JSON Web Token (JWT): 理解与应用

JWT(JSON Web Token)是一种开放标准(RFC 7519),它定义了一种紧凑且自包含的方式,用于在各方之间以JSON对象的形式安全地传输信息。JWT通常用于身份验证和授权目的,因为它可以使用JSON对象在各方…

更改Docker默认存储位置

Docker镜像和容器等数据默认保存在目录/var/lib/docker目录下,我们可以更改Docker 的默认存储位置,比如改到数据盘。需注决,变更存储位置时,原来的镜像和容器有可能丢失。 1、确认docker默认存放目录 [rootkfk12 ~]# docker inf…

Linux平台Display Server与Desktop Environment

Display Driver Linux中的显示服务器(Display Server)是什么? 显示服务器是一个应用程序,其主要任务是协调客户端与其他操作系统,硬件以及彼此之间的输入和输出。显示服务器通过显示服务器协议与其客户端进行通信。 …

<数据集>骑行头盔识别数据集<目标检测>

数据集格式:VOCYOLO格式 图片数量:5026张 标注数量(xml文件个数):5026 标注数量(txt文件个数):5026 标注类别数:3 标注类别名称:[helmet, without_helmet, two_wheeler] 序号类别名称图片数框数1helm…

在Matlab中进行射频电路S、Z、Y、ABCD等参数的转换

在Matlab中进行射频电路S、Z、Y、ABCD等参数的转换 目录 在Matlab中进行射频电路S、Z、Y、ABCD等参数的转换1、转换案例-3dB电桥2、将转换结果应用到ADS中制造理想3dB电桥器件 在微带线的ABCD矩阵的推导、转换与级联-Matlab计算实例(S、Z、Y参数转换)中&…

SpringBoot开启多端口探究--开启gRPC端口

文章目录 前情提要一、gRPC的特别之处二、粗暴方案原始的GrpcObservabilityServer集成支持方案评价 三、改进方案基本原理改造结果 四、小结 前情提要 之前咱们聊过SpringBoot下开启多端口有3个思路,并分析了第一种开启独立management端口的实现细节,今…

【深度学习】【语音TTS】GPT-SoVITS v2 实战,训练一个人的音色,Docker镜像

文章目录 原理Dockerdocker push训练教程: https://www.yuque.com/baicaigongchang1145haoyuangong/ib3g1e/xyyqrfwiu3e2bgyk 原理 Docker 不用docker不行,不好分配显卡, 做个docker镜像: docker pull pytorch/pytorch:2.1.2

【AI趋势6】大模型与游戏共振

大语言模型与游戏环境的相结合,正在为AI Agent训练打造最佳训练场。游戏不仅能为AI Agent训练提与现实世界类似的虚拟环境,还能为AI Agent训练提供清晰、可量化的评估规则,大幅提升技术迭代与测试效率。当前,包括OpenAI、DeepMind…

前端面试题-什么是JavaScript的闭包?有哪些应用场景?

定义: 一个函数能够访问其它函数内部定义的变量 形成的原理: (1)函数创建:在一个函数(外部函数)中定义另一个函数(内部函数)。 (2)内部函数访问:内部函数可以访问和修改外部函数中的局部变量。 (3)函数…

Spring Cloud Eureka快速搭建:微服务注册中心的配置步骤

Spring Cloud Eureka快速搭建:微服务注册中心的配置步骤 目录 引言Spring Cloud微服务架构概述什么是Eureka?Eureka Server的搭建步骤 4.1 创建Eureka Server项目4.2 配置Eureka Server4.3 启动Eureka Server4.4 多实例Eureka Server的搭建 Eureka Cli…

无人机电池充电器技术详解

随着无人机技术的飞速发展,其作为航拍、物流、农业、监测等多领域的重要工具,对电池续航能力和充电效率提出了更高要求。无人机电池充电器作为保障无人机长时间运行的关键设备,其技术水平的提升直接影响到无人机的使用效率和安全性。本文将从…

牛客网习题——通过C++实现

一、目标 实现下面4道练习题增强C代码能力。 1.求123...n_牛客题霸_牛客网 (nowcoder.com) 2.计算日期到天数转换_牛客题霸_牛客网 (nowcoder.com) 3.日期差值_牛客题霸_牛客网 (nowcoder.com) 4.打印日期_牛客题霸_牛客网 (nowcoder.com) 二、对目标的实现 1.求123...n_…

【Solidity】基础介绍

数据类型 值类型 值类型的变量在赋值或作为函数参数传递时会被复制。 布尔类型:bool整数类型: 无符号:uint8、uint16、…、uint256 (uint256 可简写为 uint)有符号:int8、int16、…、int256 (int256可简写为 int) 地址类型&…

Unity的物理系统

目录 3D 物理系统 主要组件 2D 物理系统 主要组件 物理引擎的选择与应用 物理模拟的控制与优化 Unity中Nvidia PhysX引擎与Box2D引擎在性能和功能上的具体比较是什么? 如何在Unity项目中实现Havok物理引擎,并与PhysX或Box2D引擎结合使用&#xf…

像素尺寸物理尺寸分辨率

同样尺寸的图片(如448448像素)的确会有相同的像素数量,但分辨率的概念不仅仅取决于像素数,还包括图像在物理世界中的显示或打印尺寸。因此,像素尺寸相同的图片在不同的物理尺寸下显示时,分辨率可以不同。 …

UE5.4 用自带OpenCV4.55读取png、MP4、摄像头并在ui中显示的方法

创建c项目,项目build.cs中开启模块: // Copyright Epic Games, Inc. All Rights Reserved.using UnrealBuildTool;public class OpencvT : ModuleRules {public OpencvT(ReadOnlyTargetRules Target) : base(Target){PCHUsage PCHUsageMode.UseExplici…

Kali Linux 命令大全

一、引言 Kali Linux 作为一款专为渗透测试和安全研究设计的操作系统,拥有丰富的命令行工具,熟练掌握这些命令对于高效地进行安全测试和分析至关重要。本文将为您详细介绍 Kali Linux 中常用的命令,涵盖系统信息获取、文件操作、网络分析、用…

Vue3 组件命名

最简单的方式 无须引入插件,可直接命名(缺点,可能就是丑了) // 组件命名 defineOptions({name: Menu}) 优雅的命名方式 安装 vite-plugin-vue-setup-extend 插件 npm i vite-plugin-vue-setup-extend -D vite-plugin-vue-se…

分布式数据库在传统车联网厂商的应用实践 | OceanBase案例

本文作者:慧视通科技,梁君 传统车联网厂商运维百亿级数据的痛点与难点 深圳慧视通科技(简称慧视通)作为专业的位置数据综合运营服务提供商,一直深耕智能交通领域,依托车联网、云计算、大数据处理、无线通信…