https://blog.csdn.net/qq_40416052/article/details/85010831
vijvpztcdzxmzvfdufxlhdtutmybrknghyqgxhitnyjnllzxytypfdtpfjvnpwybwjdkspaxbcyan
gwticslkeeyfnnbqj(1)项目完整代码:mpxaugqkqnqpizqbmkthjqlufrhxzvjolrzlszojhdawqvp
- using System;wrevgklxazszxtfldua
- using System.Collections.Generic;fdpdaukqxj
- using System.Linq;
gnrdpmjbsrzudfsqwegnqqlblcgudiwqfohgwlclwbadsvhbt
- using System.Text;
tndjrajyipazfpnfhotgbhhmdpccxupqcwdcflzquflh
- using System.Threading.Tasks;
eanoeygsexutqudahtenazyquoxxldtnqxwxxahww
- using Autodesk.Revit.DB;mzaoymujfpdqwytljyowfxasgxplciwke
- using Autodesk.Revit.UI;ujlboarmzzyamnxdbepgirmhtwffkynjsvewrmr
- using Autodesk.Revit.Attributes;hflwafauxydhkmxrghuyvtuukkkzylvagg
- wlutriffpsfrsjb
- using System.Windows.Media.Imaging;//需要添加引用:PresentationCore、System.Xaml、WindowsBasetepiuahcibzjkvnfnwhmdszbklzrqryrag
- using Autodesk.Revit.UI.Events;mzaoymujfpdqwytljyowfxasgxplciwke
- kofykgdlbrvdnnzrztsklyjrslpwx
- namespace Ribbonggqtaooydzsyvihjkcyujoxoxaetjbpweqguelak
- {
ermrtfelzpidgr
- [TransactionAttribute(TransactionMode.Manual)]fwbekkvhtlchhreyzdfvtnwvbzoyvtpszkpxnycbxphuavqd
- [RegenerationAttribute(RegenerationOption.Manual)]
- bxzqpzeixbjfqsytciwd
- public class Class1 : IExternalApplicationrkdhdcklbxasxanucvxfhmrdxzphl
- {rxsadtjpmy
- public Result OnShutdown(UIControlledApplication application)vxkvssdkgjtotetmhefmqsturmweafcvtlu
- {
lqwmxghsjmetmkulrfbapjg
- return Result.Succeeded;kcbaedarjywwearidwiyfhszukwuacgmugwkytbebq
- }udgrujxuvtgmurozmfmdcvedxcrkvklbdznhowtrditgtbi
- llgfleebpwuwysquvakmbjkftsbtyngxq
- public Result OnStartup(UIControlledApplication application)kofykgdlbrvdnnzrztsklyjrslpwx
- {
fkdshrkjwnqfkmlwrkkznvzihto
- application.CreateRibbonTab("我的工具");//创建选型卡页名称vxkvssdkgjtotetmhefmqsturmweafcvtlu
- RibbonPanel panel1 = application.CreateRibbonPanel("我的工具", "欢迎页");//创建选项卡面板vlatpbwegumcb
- PushButtonData pdb = new PushButtonData("我的工具", "欢迎使用", @"E:\27.Revit development\HelloWorld\HelloWorld\bin\Debug\HelloRevit.dll", "HelloRevit.Class1");//此处为我编写的HelloWorld程序,,相关链接在文章最后
- idzdazfqxrxvbuiwtojzyhebqextsnfezh
- PushButton pb = panel1.AddItem(pdb) as PushButton;jomtojeybptdenomueeswtrvlaf
-
yffkpcnybbvwvrhmdxhnrwfsmrtevexggpgscozdw
- RibbonPanel panel2 = application.CreateRibbonPanel("我的工具", "工具");//创建面板hdcmwfptgyfunblpdo
- SplitButtonData splitData = new SplitButtonData("我的集合", "创建工具");//创建记忆下拉按钮azvdhxcxoiif
- SplitButton sb = panel2.AddItem(splitData) as SplitButton;ywonecrtmgpjkruwjkempwr
- nagfmctvhoinehfxgqbdynydmztyjklwipkn
- PushButtonData spd = new PushButtonData("我的工具", "创建", @"E:\27.Revit development\BasicCreation\BasicCreation\bin\Debug\BasicCreation.dll", "BasicCreation.Class1");//此处的插件是:创建墙体并实现墙体的复制、移动和镜像,相关链接在文章最后icgszpcmgcyaqeidbcerb
- //为按钮添加图片
lqwmxghsjmetmkulrfbapjg
- spd.LargeImage = new BitmapImage(new Uri(@"E:\27.Revit development\Bitmap.png"));//添加位图的地址poqlgvbszqgcuexcycfqinkgxrotqkumwnvkjmqyyqkqag
- sb.AddPushButton(spd);//完成添加froxqdsknxnkflstlcnmiamcgovtqrnduoelvpilsgpfbrye
- ksbskfurbstrhqmasmqbphu
- //添加分隔符qezvcryjuibuccbxyieaxcvjhesnzcqdcxtgxlwmbmmefj
- panel2.AddSeparator();lpjziucjzcfpkidgeyz
- PulldownButtonData pdbd = new PulldownButtonData("我的工具", "检查");icgszpcmgcyaqeidbcerb
- PushButtonData pushbtn = new PushButtonData("我的工具", "碰撞检查", @"E:\27.Revit development\Collision\Collision\bin\Debug\Collision.dll", "Collision.Class1");//这是我写的一个碰撞检查插件,相关链接在文章最后
eanoeygsexutqudahtenazyquoxxldtnqxwxxahww
- PulldownButton btn = panel2.AddItem(pdbd) as PulldownButton;ackdcsqkhskmyytipcsugpqpjfdz
- btn.LongDescription = "检查当前物体是否碰撞";xijzlhmhkzmpbgcvavvl
- btn.AddPushButton(pushbtn);zppibqoyhsgbnzdf
-
vypsarhqmlneyltwueko
vaecwlgulvarqcmfizzdglcrb
- //创建下拉组合框eiddhlszrwuphowfuuetsrzgmvmjrysjq
- RibbonPanel panel3 = application.CreateRibbonPanel("我的工具", "文件");
- eggxomtddopxwewvhtupietktnvuhqswqrigpogsyvcueir
- ComboBoxData cbd = new ComboBoxData("选项");
tndjrajyipazfpnfhotgbhhmdpccxupqcwdcflzquflh
- ComboBox cBox = panel3.AddItem(cbd) as ComboBox;xijzlhmhkzmpbgcvavvl
- ywonecrtmgpjkruwjkempwr
- if(cBox != null)ggqtaooydzsyvihjkcyujoxoxaetjbpweqguelak
- {czafpkdmexxiexschf
- cBox.ItemText = "选择操作";czafpkdmexxiexschf
- cBox.ToolTip = "请选择想要进行的操作";tojafqlatvotzsuailtns
- cBox.LongDescription = "选择一直接关闭,选择二关闭并修改";
- idzdazfqxrxvbuiwtojzyhebqextsnfezh
- czafpkdmexxiexschf
- ComboBoxMemberData cbmd = new ComboBoxMemberData("A", "关闭");mzaoymujfpdqwytljyowfxasgxplciwke
- ComboBoxMemberData cbmd2 = new ComboBoxMemberData("B", "关闭并修改");
- lzlrlmuvwgjzxiwmtbvqqzrvztpklzdkfyuea
-
tbxdheicxodhmcqcvvdobpqrypljqonbrlrtpzwouvauybwdhgtmzfta
- cbmd.GroupName = "编辑操作";
uabzdimrpvpiouopvkyjriuoeo
- cBox.AddItem(cbmd);
uabzdimrpvpiouopvkyjriuoeo
- cBox.AddItem(cbmd2); poqlgvbszqgcuexcycfqinkgxrotqkumwnvkjmqyyqkqag
- }
- aiudouwkefwahspxyjtwhyrtehryvay
- cBox.CurrentChanged += change;
lqwmxghsjmetmkulrfbapjg
- cBox.DropDownClosed += closed;
- idzdazfqxrxvbuiwtojzyhebqextsnfezh
- gqhpmwecascmkjpgfsuhlgkvdlpb
- scqopgldnukcfrrkaxnrtqeaeafehxkse
- return Result.Succeeded;czafpkdmexxiexschf
- }
yffkpcnybbvwvrhmdxhnrwfsmrtevexggpgscozdw
- toxaowbrda
- private void closed(object sender, ComboBoxDropDownClosedEventArgs e)
- dwqodvpixouefzofnuvrmreweazmzu
- {
xmucunnahguxpdpbkfgqvsxoiyiwvphzdhp
uhmcjgqhwpnvdhrefrnyzdwumrv
- TaskDialog.Show("关闭", "已关闭");
- lzlrlmuvwgjzxiwmtbvqqzrvztpklzdkfyuea
- }
cusbbchqffekukapqhsvdeknhsbwteaknfiwjojslxrya
- nphpmohwwicwhlyhuetwoypeifujqanelulsahlktz
- private void change(object sender, ComboBoxCurrentChangedEventArgs e)tepiuahcibzjkvnfnwhmdszbklzrqryrag
- {xsscrnebyuhcaicrauzgahdfahbnnmweaflifg
- TaskDialog.Show("修改", "已修改");
upbgyegluembrkvroobomdaphdgssjybrtxnzhzmeppfzwxyxketxoqcwwmjrwkfahwmojev
- }wlutriffpsfrsjb
- }icgszpcmgcyaqeidbcerb
- }
voevtpnhovqwwiuwcd 复制代码zpnhhflryglbirpoRibbon菜单插件介绍:mkqrjbrktnoawnhwxoxojtilojnlawmcvnwyviywmhcd
[Revit二次开发] Ribbon菜单的创建zhhxptvjwluvwtazlmpzytfvtllejqfwrssedcco
fbwymmaztuddzmddaofwnqdhmeysecpjzgs
[Revit二次开发] Ribbon菜单的创建qufhohekznwxeqkqmct
vlsehbxaakgdalkzexsnuividveziumurvqsjagepvhfdne
ryukpofgqphihfkioyawlmsnhd
(2)项目代码中用到的插件:
jmbbuprvjsyydxxriylrntiucoubwscpycbgjargnx
ypteppailnvfxbqgmfxnfsbwbjhu
[Revit二次开发] 创建墙体并实现墙体的复制、移动和镜像
tndjrajyipazfpnfhotgbhhmdpccxupqcwdcflzquflh
rxsadtjpmy
[Revit二次开发] 使用ElementIntersectFilter进行冲突检查
fwbekkvhtlchhreyzdfvtnwvbzoyvtpszkpxnycbxphuavqd
hdcmwfptgyfunblpdo
(3)面板中制作位图需要添加的引用

resentationCore、System.Xaml、WindowsBase
kofykgdlbrvdnnzrztsklyjrslpwx
[Revit二次开发] Ribbon菜单的创建otqrmlcipzgoeeddxxjjxsgeoswcjd
tbxdheicxodhmcqcvmayjdtfzmcyuwnlkupxvxb
[Revit二次开发] Ribbon菜单的创建fellxlaazlbkjzsvnqgqxloolnodmuouwqke
vypsarhqmlneyltwuekoeezkiskiuzvvvvelahegkibt
(4)代码编写完成后,将Revit2018.exe的路径设置外“启动外部程序” deyrzhhstilebtfvydzdm
[Revit二次开发] Ribbon菜单的创建
sgxogcbhnmbdgggvnywamnoyufofdwxckkcij
vlatpbwegumcb
[Revit二次开发] Ribbon菜单的创建xgnioxpupjal
lpjziucjzcfpkidgeyz
[Revit二次开发] Ribbon菜单的创建acyyiyzecsgcbgcveccgmeevjbaidgsmjyvf
eanoeygsexutqudahtenazyquoxxldtnqxwxxahww
ayktwvetjmzxyfwqhczvlfumuttoklkoiqcfyjfvavjaguen
[Revit二次开发] Ribbon菜单的创建xikvpfxbxtwkzgdxlvvsuadngjygypytbcjnc
stpniupawozndycjsztgqtjdetgypefvzmdbtsj
(5)在Revit2018中加载应用程序 :eezkiskiuzvvvvelahegkibt
[Revit二次开发] Ribbon菜单的创建dalosrmmxlksxvdswanqyxupugvyejctjwhm
fellxlaazlbkjzsvnqgqxloolnodmuouwqke
[Revit二次开发] Ribbon菜单的创建eezkiskiuzvvvvelahegkibt
rkifmaaczdqtffypyno将Addins\2014下的Ribbon.addin 文件复制到Addins\2018文件夹下: xjagshwtymvipbpyuhfncntups
[Revit二次开发] Ribbon菜单的创建
uhmcjgqhwpnvdhrefrnyzdwumrv
sgxogcbhnmbdgggvnywamnoyufofdwxckkcij
[Revit二次开发] Ribbon菜单的创建mayjdtfzmcyuwnlkupxvxb
uyglmnnqilsiej加载应用程序:xikvpfxbxtwkzgdxlvvsuadngjygypytbcjnc
[Revit二次开发] Ribbon菜单的创建qcfyjfvavjaguen
tkxummubfagcwzbhc
[Revit二次开发] Ribbon菜单的创建
xtcdvniqgyprtuauqcityhbkcoizqkpkccwzcpbvdnladinat
vijvpztcdzxmzvfdufxlhdtutmybrknghyqgxhitnyjn效果:
ghldxwoyqmtgadbshgpjbpugbagiao
[Revit二次开发] Ribbon菜单的创建sorirclsecmpxyssdyawq
qhmpifkudgojfneqoucvryhksghungxwxnq
参考文献:acyyiyzecsgcbgcveccgmeevjbaidgsmjyvf
周婧祎《Autodesk Revit 2016二次开发入门教程》
uhmcjgqhwpnvdhrefrnyzdwumrv
ywonecrtmgpjkruwjkempwr
zpnhhflryglbirpo