[Revit二次开发] [Revit二次开发] Ribbon菜单的创建 [课程编码3921]

[复制链接] []
发表于 2023-1-21 16:10:53| 字数 7,170 | 显示全部楼层 |阅读模式
修改字体大小 16px
10px 25px

https://blog.csdn.net/qq_40416052/article/details/85010831

vijvpztcdzxmzvfdufxlhdtutmybrknghyqgxhitnyjn

llzxytypfdtpfjvnpwybwjdkspaxbcyan

  • gwticslkeeyfnnbqj
  • (1)项目完整代码:mpxaugqkqnqpizqbmkthjqlufrhxzvjolrzlszojhdawqvp

    1. using System;
      wrevgklxazszxtfldua

    2. using System.Collections.Generic;fdpdaukqxj
    3. using System.Linq;
      gnrdpmjbsrzudfsqwegnqqlblcgudiwqfohgwlclwbadsvhbt

    4. using System.Text;
      tndjrajyipazfpnfhotgbhhmdpccxupqcwdcflzquflh

    5. using System.Threading.Tasks;
      eanoeygsexutqudahtenazyquoxxldtnqxwxxahww

    6. using Autodesk.Revit.DB;mzaoymujfpdqwytljyowfxasgxplciwke
    7. using Autodesk.Revit.UI;ujlboarmzzyamnxdbepgirmhtwffkynjsvewrmr
    8. using Autodesk.Revit.Attributes;hflwafauxydhkmxrghuyvtuukkkzylvagg
    9. wlutriffpsfrsjb
    10. using System.Windows.Media.Imaging;//需要添加引用:PresentationCore、System.Xaml、WindowsBasetepiuahcibzjkvnfnwhmdszbklzrqryrag
    11. using Autodesk.Revit.UI.Events;mzaoymujfpdqwytljyowfxasgxplciwke
    12. kofykgdlbrvdnnzrztsklyjrslpwx
    13. namespace Ribbonggqtaooydzsyvihjkcyujoxoxaetjbpweqguelak
    14. {
      ermrtfelzpidgr

    15.     [TransactionAttribute(TransactionMode.Manual)]fwbekkvhtlchhreyzdfvtnwvbzoyvtpszkpxnycbxphuavqd
    16.     [RegenerationAttribute(RegenerationOption.Manual)]
    17. bxzqpzeixbjfqsytciwd

    18.     public class Class1 : IExternalApplication
      rkdhdcklbxasxanucvxfhmrdxzphl

    19.     {rxsadtjpmy
    20.         public Result OnShutdown(UIControlledApplication application)vxkvssdkgjtotetmhefmqsturmweafcvtlu
    21.         {
      lqwmxghsjmetmkulrfbapjg

    22.             return Result.Succeeded;kcbaedarjywwearidwiyfhszukwuacgmugwkytbebq
    23.         }udgrujxuvtgmurozmfmdcvedxcrkvklbdznhowtrditgtbi
    24. llgfleebpwuwysquvakmbjkftsbtyngxq
    25.         public Result OnStartup(UIControlledApplication application)kofykgdlbrvdnnzrztsklyjrslpwx
    26.         {
      fkdshrkjwnqfkmlwrkkznvzihto

    27.             application.CreateRibbonTab("我的工具");//创建选型卡页名称vxkvssdkgjtotetmhefmqsturmweafcvtlu
    28.             RibbonPanel panel1 = application.CreateRibbonPanel("我的工具", "欢迎页");//创建选项卡面板vlatpbwegumcb
    29.             PushButtonData pdb = new PushButtonData("我的工具", "欢迎使用", @"E:\27.Revit development\HelloWorld\HelloWorld\bin\Debug\HelloRevit.dll", "HelloRevit.Class1");//此处为我编写的HelloWorld程序,,相关链接在文章最后
    30. idzdazfqxrxvbuiwtojzyhebqextsnfezh

    31.             PushButton pb = panel1.AddItem(pdb) as PushButton;jomtojeybptdenomueeswtrvlaf
    32. yffkpcnybbvwvrhmdxhnrwfsmrtevexggpgscozdw

    33.             RibbonPanel panel2 = application.CreateRibbonPanel("我的工具", "工具");//创建面板hdcmwfptgyfunblpdo
    34.             SplitButtonData splitData = new SplitButtonData("我的集合", "创建工具");//创建记忆下拉按钮azvdhxcxoiif
    35.             SplitButton sb = panel2.AddItem(splitData) as SplitButton;ywonecrtmgpjkruwjkempwr
    36. nagfmctvhoinehfxgqbdynydmztyjklwipkn

    37.             PushButtonData spd = new PushButtonData("我的工具", "创建", @"E:\27.Revit development\BasicCreation\BasicCreation\bin\Debug\BasicCreation.dll", "BasicCreation.Class1");//此处的插件是:创建墙体并实现墙体的复制、移动和镜像,相关链接在文章最后icgszpcmgcyaqeidbcerb
    38.             //为按钮添加图片
      lqwmxghsjmetmkulrfbapjg

    39.             spd.LargeImage = new BitmapImage(new Uri(@"E:\27.Revit development\Bitmap.png"));//添加位图的地址poqlgvbszqgcuexcycfqinkgxrotqkumwnvkjmqyyqkqag
    40.             sb.AddPushButton(spd);//完成添加
      froxqdsknxnkflstlcnmiamcgovtqrnduoelvpilsgpfbrye

    41. ksbskfurbstrhqmasmqbphu
    42.             //添加分隔符qezvcryjuibuccbxyieaxcvjhesnzcqdcxtgxlwmbmmefj
    43.             panel2.AddSeparator();lpjziucjzcfpkidgeyz
    44.             PulldownButtonData pdbd = new PulldownButtonData("我的工具", "检查");icgszpcmgcyaqeidbcerb
    45.             PushButtonData pushbtn = new PushButtonData("我的工具", "碰撞检查", @"E:\27.Revit development\Collision\Collision\bin\Debug\Collision.dll", "Collision.Class1");//这是我写的一个碰撞检查插件,相关链接在文章最后
      eanoeygsexutqudahtenazyquoxxldtnqxwxxahww

    46.             PulldownButton btn = panel2.AddItem(pdbd) as PulldownButton;ackdcsqkhskmyytipcsugpqpjfdz
    47.             btn.LongDescription = "检查当前物体是否碰撞";xijzlhmhkzmpbgcvavvl
    48.             btn.AddPushButton(pushbtn);
      zppibqoyhsgbnzdf

    49. vypsarhqmlneyltwueko

      vaecwlgulvarqcmfizzdglcrb


    50.             //创建下拉组合框eiddhlszrwuphowfuuetsrzgmvmjrysjq
    51.             RibbonPanel panel3 = application.CreateRibbonPanel("我的工具", "文件");
    52. eggxomtddopxwewvhtupietktnvuhqswqrigpogsyvcueir

    53.             ComboBoxData cbd = new ComboBoxData("选项");
      tndjrajyipazfpnfhotgbhhmdpccxupqcwdcflzquflh

    54.             ComboBox cBox = panel3.AddItem(cbd) as ComboBox;xijzlhmhkzmpbgcvavvl
    55. ywonecrtmgpjkruwjkempwr
    56.             if(cBox != null)ggqtaooydzsyvihjkcyujoxoxaetjbpweqguelak
    57.             {czafpkdmexxiexschf
    58.                 cBox.ItemText = "选择操作";czafpkdmexxiexschf
    59.                 cBox.ToolTip = "请选择想要进行的操作";tojafqlatvotzsuailtns
    60.                 cBox.LongDescription = "选择一直接关闭,选择二关闭并修改";
    61. idzdazfqxrxvbuiwtojzyhebqextsnfezh

    62. czafpkdmexxiexschf
    63.                 ComboBoxMemberData cbmd = new ComboBoxMemberData("A", "关闭");mzaoymujfpdqwytljyowfxasgxplciwke
    64.                 ComboBoxMemberData cbmd2 = new ComboBoxMemberData("B", "关闭并修改");
    65. lzlrlmuvwgjzxiwmtbvqqzrvztpklzdkfyuea

    66. tbxdheicxodhmcqcvvdobpqrypljqonbrlrtpzwouvauybwdhgtmzfta


    67.                 cbmd.GroupName = "编辑操作";
      uabzdimrpvpiouopvkyjriuoeo

    68.                 cBox.AddItem(cbmd);
      uabzdimrpvpiouopvkyjriuoeo

    69.                 cBox.AddItem(cbmd2); poqlgvbszqgcuexcycfqinkgxrotqkumwnvkjmqyyqkqag
    70.             }
    71. aiudouwkefwahspxyjtwhyrtehryvay

    72.             cBox.CurrentChanged += change;
      lqwmxghsjmetmkulrfbapjg

    73.             cBox.DropDownClosed += closed;
    74. idzdazfqxrxvbuiwtojzyhebqextsnfezh

    75. gqhpmwecascmkjpgfsuhlgkvdlpb

    76. scqopgldnukcfrrkaxnrtqeaeafehxkse
    77.             return Result.Succeeded;czafpkdmexxiexschf
    78.         }
      yffkpcnybbvwvrhmdxhnrwfsmrtevexggpgscozdw

    79. toxaowbrda
    80.         private void closed(object sender, ComboBoxDropDownClosedEventArgs e)
    81. dwqodvpixouefzofnuvrmreweazmzu

    82.         {

      xmucunnahguxpdpbkfgqvsxoiyiwvphzdhp

      uhmcjgqhwpnvdhrefrnyzdwumrv


    83.             TaskDialog.Show("关闭", "已关闭");
    84. lzlrlmuvwgjzxiwmtbvqqzrvztpklzdkfyuea

    85.         }
      cusbbchqffekukapqhsvdeknhsbwteaknfiwjojslxrya

    86. nphpmohwwicwhlyhuetwoypeifujqanelulsahlktz

    87.         private void change(object sender, ComboBoxCurrentChangedEventArgs e)tepiuahcibzjkvnfnwhmdszbklzrqryrag
    88.         {xsscrnebyuhcaicrauzgahdfahbnnmweaflifg
    89.             TaskDialog.Show("修改", "已修改");

      upbgyegluembrkvroobomdaphdgssjybrtxnzhzmeppfzwxyxketxoqcwwmjrwkfahwmojev


    90.         }wlutriffpsfrsjb
    91.     }icgszpcmgcyaqeidbcerb
    92. }
    voevtpnhovqwwiuwcd
    复制代码zpnhhflryglbirpo

    Ribbon菜单插件介绍:mkqrjbrktnoawnhwxoxojtilojnlawmcvnwyviywmhcd

    [Revit二次开发] Ribbon菜单的创建zhhxptvjwluvwtazlmpzytfvtllejqfwrssedcco

    [Revit二次开发] Ribbon菜单的创建 fbwymmaztuddzmddaofwnqdhmeysecpjzgs

    [Revit二次开发] Ribbon菜单的创建qufhohekznwxeqkqmct

    [Revit二次开发] Ribbon菜单的创建 vlsehbxaakgdalkzexsnuividveziumurvqsjagepvhfdne

    ryukpofgqphihfkioyawlmsnhd
    (2)项目代码中用到的插件:
  • jmbbuprvjsyydxxriylrntiucoubwscpycbgjargnx

  • ypteppailnvfxbqgmfxnfsbwbjhu
    [Revit二次开发] 创建墙体并实现墙体的复制、移动和镜像
    tndjrajyipazfpnfhotgbhhmdpccxupqcwdcflzquflh

    rxsadtjpmy
    [Revit二次开发] 使用ElementIntersectFilter进行冲突检查fwbekkvhtlchhreyzdfvtnwvbzoyvtpszkpxnycbxphuavqd
    hdcmwfptgyfunblpdo
    (3)面板中制作位图需要添加的引用resentationCore、System.Xaml、WindowsBasekofykgdlbrvdnnzrztsklyjrslpwx

    [Revit二次开发] Ribbon菜单的创建otqrmlcipzgoeeddxxjjxsgeoswcjd

    [Revit二次开发] Ribbon菜单的创建

    tbxdheicxodhmcqcvmayjdtfzmcyuwnlkupxvxb


    [Revit二次开发] Ribbon菜单的创建fellxlaazlbkjzsvnqgqxloolnodmuouwqke

    [Revit二次开发] Ribbon菜单的创建

    vypsarhqmlneyltwuekoeezkiskiuzvvvvelahegkibt


    (4)代码编写完成后,将Revit2018.exe的路径设置外“启动外部程序” deyrzhhstilebtfvydzdm

    [Revit二次开发] Ribbon菜单的创建

    sgxogcbhnmbdgggvnywamnoyufofdwxckkcij

    [Revit二次开发] Ribbon菜单的创建
    vlatpbwegumcb

    [Revit二次开发] Ribbon菜单的创建xgnioxpupjal

    [Revit二次开发] Ribbon菜单的创建
    lpjziucjzcfpkidgeyz

    [Revit二次开发] Ribbon菜单的创建acyyiyzecsgcbgcveccgmeevjbaidgsmjyvf

    [Revit二次开发] Ribbon菜单的创建
    eanoeygsexutqudahtenazyquoxxldtnqxwxxahww

    ayktwvetjmzxyfwqhczvlfumuttoklkoiqcfyjfvavjaguen


    [Revit二次开发] Ribbon菜单的创建xikvpfxbxtwkzgdxlvvsuadngjygypytbcjnc

    [Revit二次开发] Ribbon菜单的创建
    stpniupawozndycjsztgqtjdetgypefvzmdbtsj

    (5)在Revit2018中加载应用程序 :eezkiskiuzvvvvelahegkibt

    [Revit二次开发] Ribbon菜单的创建dalosrmmxlksxvdswanqyxupugvyejctjwhm

    [Revit二次开发] Ribbon菜单的创建 fellxlaazlbkjzsvnqgqxloolnodmuouwqke

    [Revit二次开发] Ribbon菜单的创建eezkiskiuzvvvvelahegkibt

    [Revit二次开发] Ribbon菜单的创建
    rkifmaaczdqtffypyno

    将Addins\2014下的Ribbon.addin 文件复制到Addins\2018文件夹下: xjagshwtymvipbpyuhfncntups

    [Revit二次开发] Ribbon菜单的创建

    uhmcjgqhwpnvdhrefrnyzdwumrv

    [Revit二次开发] Ribbon菜单的创建

    sgxogcbhnmbdgggvnywamnoyufofdwxckkcij

    [Revit二次开发] Ribbon菜单的创建mayjdtfzmcyuwnlkupxvxb

    [Revit二次开发] Ribbon菜单的创建
  • uyglmnnqilsiej
  • 加载应用程序:xikvpfxbxtwkzgdxlvvsuadngjygypytbcjnc

    [Revit二次开发] Ribbon菜单的创建qcfyjfvavjaguen

    [Revit二次开发] Ribbon菜单的创建 tkxummubfagcwzbhc

    [Revit二次开发] Ribbon菜单的创建

    xtcdvniqgyprtuauqcityhbkcoizqkpkccwzcpbvdnladinat

    [Revit二次开发] Ribbon菜单的创建
    vijvpztcdzxmzvfdufxlhdtutmybrknghyqgxhitnyjn

    效果:

    ghldxwoyqmtgadbshgpjbpugbagiao

    [Revit二次开发] Ribbon菜单的创建sorirclsecmpxyssdyawq

    [Revit二次开发] Ribbon菜单的创建 qhmpifkudgojfneqoucvryhksghungxwxnq

    参考文献:acyyiyzecsgcbgcveccgmeevjbaidgsmjyvf

      周婧祎《Autodesk Revit 2016二次开发入门教程》

    uhmcjgqhwpnvdhrefrnyzdwumrv

    ywonecrtmgpjkruwjkempwr
    zpnhhflryglbirpo
    crlxeyfgekteidzqfpbjkizidfrssrmrsmk
    qlyzvybrzptwjxbvfzggtavthg
    kvnirgrvldrpsgqxv

    dpxjctxhknfunxsqawfxezwtuibfrervvrhysah

    回复 申请删帖

    使用道具 举报

    • 联系我们
    • 邮箱:837005074#qq.com(请把#改成@)
    • 电话:18810188033
    • QQ客服 837005074
    • 人工客服:周一至周日(晚6点至11点)
    • 扫描加客服QQ

    • 扫描加客服微信

    QQ|关于我们|Archiver|手机版|小黑屋|找最好·学BIM网(zhaozuihao.com;xuebim.com) ( 京ICP备2024101289号-1 )

    GMT+8, 2025-4-7 07:35 , Processed in 0.315149 second(s), 60 queries .

    Powered by 找最好 X3.4

    © 2015至今 zhaozuihao.com