使用NSIS打包revit插件安装包

**

使用NSIS打包revit插件安装包

**
1、首先准备好
软件NSIS v2.51 集成增强版
https://pan.baidu.com/s/15O_bCNx8p_lyLUo9zEq6mg
已经编译的addin文件、插件、安装时所提示的帮助文档格式为txt放在一个文件夹里面

2、打开nsis软件
在这里插入图片描述
文件——新建脚本向导——下一步
在这里插入图片描述
在这里插入图片描述
下一步
在这里插入图片描述

在这里插入图片描述

以revit201x为例,目的目录为C:\ProgramData\Autodesk\Revit\Addins\201x
在这里插入图片描述
一直下一步
在这里插入图片描述

接着会出现下面这个界面
在这里插入图片描述
#修改addin文件
Section change
StrCpy $1 “”
StrCpy $1 “ 1 1 1INSTDIR”
StrCpy $1 “$1\CrtFloor.dll”
Push path #要替换的字符串
Push $1 #用来替换的字符串
Push all #replace all occurrences
Push all #replace all occurrences
Push C:\ProgramData\Autodesk\Revit\Addins\2016\CrtFloor.addin #所替换的文件目录
Call AdvReplaceInFile
SectionEnd

在该文档的最后面加入代码
![在这里插入图片描述](https://img-blog.csdnimg.cn/20181026194136326.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjgwODEzNw==,size_27,color_FFFFFF,t_70)

Function AdvReplaceInFile
Exch $0 ;file to replace in
Exch
Exch $1 ;number to replace after
Exch
Exch 2
Exch $2 ;replace and onwards
Exch 2
Exch 3
Exch $3 ;replace with
Exch 3
Exch 4
Exch $4 ;to replace
Exch 4
Push $5 ;minus count
Push $6 ;universal
Push $7 ;end string
Push $8 ;left string
Push $9 ;right string
Push $R0 ;file1
Push $R1 ;file2
Push $R2 ;read
Push $R3 ;universal
Push $R4 ;count (onwards)
Push $R5 ;count (after)
Push $R6 ;temp file name

GetTempFileName $R6
FileOpen $R1 $0 r ;file to search in
FileOpen $R0 $R6 w ;temp file
StrLen $R3 $4
StrCpy $R4 -1
StrCpy $R5 -1

loop_read:
ClearErrors
FileRead $R1 $R2 ;read line
IfErrors exit

StrCpy $5 0
StrCpy $7 $R2

loop_filter:
IntOp $5 $5 - 1
StrCpy $6 $7 $R3 $5 ;search
StrCmp $6 “” file_write1
StrCmp $6 $4 0 loop_filter

StrCpy $8 $7 $5 ;left part
IntOp $6 $5 + $R3
IntCmp $6 0 is0 not0
is0:
StrCpy $9 “”
Goto done
not0:
StrCpy $9 $7 “” $6 ;right part
done:
StrCpy $7 $8$3$9 ;re-join

IntOp $R4 $R4 + 1
StrCmp $2 all loop_filter
StrCmp $R4 $2 0 file_write2
IntOp $R4 $R4 - 1

IntOp $R5 $R5 + 1
StrCmp $1 all loop_filter
StrCmp $R5 $1 0 file_write1
IntOp $R5 $R5 - 1
Goto file_write2

file_write1:
FileWrite $R0 $7 ;write modified line
Goto loop_read

file_write2:
FileWrite $R0 $R2 ;write unmodified line
Goto loop_read

exit:
FileClose $R0
FileClose $R1

SetDetailsPrint none
Delete $0
Rename $R6 $0
Delete $R6
SetDetailsPrint both

Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $0
Pop $1
Pop $2
Pop $3
Pop $4
FunctionEnd



编译并运行
这个时候在原本的文件夹里面会生成setup.exe文件
完成!!!
//**特别提示:安装脚本的路径不可以带有中文,否则一定程度内会出现addin文件无法识别路径,导致revit加载失败!**
本文章做法来源于小火车:revit二次开发教程
视频链接:http://www.tuituisoft.com/view/149.html
视频链接: http://v.iarch.cn/my/course/259
欢迎大家交流!
  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值