明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1990|回复: 4

CAD2009以上有选项卡,如何加载局部菜单中的选项卡?

[复制链接]
发表于 2012-5-1 22:25:11 | 显示全部楼层 |阅读模式
CAD2009以上有选项卡,如何加载局部菜单中的选项卡?
在局部菜单中已经定义了选项卡,但加载后在CAD中仍然无法显示,是需要一个命令来激活吗?


该贴已经同步到 NetBee的微博
"觉得好,就打赏"
还没有人打赏,支持一下
 楼主| 发表于 2012-5-2 20:52:37 | 显示全部楼层
本帖最后由 NetBee 于 2012-5-2 21:38 编辑

貌似.net才行呀。


  1. 1- Using VS2005 for AutoCAD 2009:



  2. -- In stdafx.h add this lines:

  3. #using <mscorlib.dll>
  4. #using <System.dll>

  5. #using <acdbmgd.dll>
  6. #using <acmgd.dll>
  7. #using <AcRibbon.dll>
  8. #using <AdWindows.dll>
  9. #using <PresentationCore.dll>
  10. #using <PresentationFramework.dll>
  11. #using <WindowsBase.dll>



  12. --- MyRibbonTabProxy.h

  13. #pragma once

  14. #include "StdAfx.h"

  15. using namespace System;
  16. using namespace Autodesk::Windows;
  17. using namespace Autodesk::AutoCAD::Ribbon;

  18. void MakeIt(void);

  19. public __gc class MyRibbonTabProxy
  20. {
  21. private:
  22.   RibbonTab*  m_RibTab;
  23. public:
  24.   MyRibbonTabProxy(String* title, String* id );
  25. protected:
  26.   void OnButtonClick(Object* sender, Windows::RoutedEventArgs * ea);

  27. };



  28. --- MyRibbonTabProxy.cpp

  29. #include "StdAfx.h"
  30. #include "MyRibbonTabProxy.h"




  31. void MakeIt()
  32. {
  33. MyRibbonTabProxy* rb = new MyRibbonTabProxy( S"CadOfiTec", S"CadOfiTecTab" );
  34. }


  35. MyRibbonTabProxy::MyRibbonTabProxy(String* title, String* id )
  36. {
  37. RibbonControl* ribCtrl = Autodesk::AutoCAD::Ribbon::RibbonServices::RibbonPaletteSet->RibbonControl;
  38. if( ribCtrl == NULL )
  39.   return;

  40. m_RibTab =  ribCtrl->FindTab( id );
  41. if( m_RibTab != NULL )
  42.   return;

  43. m_RibTab = new RibbonTab();
  44. m_RibTab->Title = title;
  45. m_RibTab->Id = id;
  46. ribCtrl->Tabs->Add( m_RibTab );
  47. m_RibTab->IsActive = true;

  48. // Create the panel source
  49. RibbonPanelSource* ribSourcePanel = new RibbonPanelSource();
  50. ribSourcePanel->Title = "Bloques";

  51. RibbonPanel* ribPanel = new RibbonPanel;
  52. ribPanel->Source = ribSourcePanel;
  53. m_RibTab->Panels->Add( ribPanel );

  54. // Create a button
  55. RibbonButton* ribButton1 = new RibbonButton();
  56. ribButton1->Text = S"AddTE";
  57. ribButton1->Click += new Windows::RoutedEventHandler(this, &MyRibbonTabProxy:: OnAddTEClick);
  58. ribButton1->ShowText = true;

  59. RibbonRow* row = new RibbonRow();
  60. row->Items->Add(ribButton1);
  61. ribSourcePanel->Rows->Add( row );

  62. }

  63. void MyRibbonTabProxy:: OnAddTEClick(Object* sender, Windows::RoutedEventArgs *ea)
  64. {
  65. Autodesk::AutoCAD::ApplicationServices::Application:: DocumentManager
  66.   ->MdiActiveDocument->SendStringToExecute(S"_AddTE ",false, false, false );
  67. }





  68. 2 - Using VS2008 for AutoCAD 2011:



  69. -- In stdafx.h add this lines:

  70. #using <mscorlib.dll>
  71. #using <System.dll>

  72. #using <acdbmgd.dll>
  73. #using <acmgd.dll>
  74. #using <AcCui.dll>
  75. #using <AdWindows.dll>
  76. #using <PresentationCore.dll>
  77. #using <PresentationFramework.dll>
  78. #using <WindowsBase.dll>



  79. #pragma once

  80. #include "StdAfx.h"

  81. using namespace System;
  82. using namespace Autodesk::Windows;

  83. void MakeIt(void);



  84. // The new implementation uses ICommand instead RoutedEventHandler



  85. public __gc class AutoCADCommandHandler: public ICommand
  86. {
  87. public:
  88. void remove_CanExecuteChanged(System::EventHandler* eh){};
  89. void add_CanExecuteChanged(System::EventHandler* eh){};

  90. AutoCADCommandHandler(){};
  91. bool CanExecute(Object* parameter);
  92. void Execute(Object* parameter);
  93. };



  94. public __gc class MyRibbonTabProxy
  95. {
  96. private:
  97.   RibbonTab*  m_RibTab;
  98. public:
  99.   MyRibbonTabProxy(String* title, String* id );

  100. };



  101. void MakeIt()
  102. {
  103. MyRibbonTabProxy* rb = new MyRibbonTabProxy( S"CadOfiTec", S"CadOfiTecTab" );
  104. }



  105. bool AutoCADCommandHandler::CanExecute(Object* parameter)
  106. {
  107. return true;
  108. }

  109. void AutoCADCommandHandler::Execute(Object* parameter)
  110. {
  111. RibbonButton* ribBtn =
  112.   static_cast<Autodesk::Windows::RibbonButton*> (parameter);
  113. Autodesk::AutoCAD::ApplicationServices::Application:: DocumentManager
  114.   ->MdiActiveDocument->SendStringToExecute(
  115.   static_cast<System:tring*>(ribBtn->CommandParameter), false, false, false );
  116. }



  117. MyRibbonTabProxy::MyRibbonTabProxy(String* title, String* id )
  118. {

  119. RibbonControl* ribCtrl = Autodesk::Windows::ComponentManager::Ribbon;
  120. if( ribCtrl == NULL )
  121.   return;

  122. m_RibTab =  ribCtrl->FindTab( id );
  123. if( m_RibTab != NULL )
  124.   return;

  125. m_RibTab = new RibbonTab();
  126. m_RibTab->Title = title;
  127. m_RibTab->Id = id;
  128. ribCtrl->Tabs->Add( m_RibTab );
  129. m_RibTab->IsActive = true;

  130. // Create the panel source
  131. RibbonPanelSource* ribSourcePanel = new RibbonPanelSource();
  132. ribSourcePanel->Title = "Bloques";

  133. RibbonPanel* ribPanel = new RibbonPanel;
  134. ribPanel->Source = ribSourcePanel;
  135. m_RibTab->Panels->Add( ribPanel );

  136. // Create a button
  137. RibbonButton* ribButton1 = new RibbonButton();
  138. ribButton1->Text = S"AddTE";
  139. ribButton1->ShowText = true;
  140. AutoCADCommandHandler* ch = new AutoCADCommandHandler();
  141. ribButton1->CommandHandler = ch;
  142. ribSourcePanel->Items->Add( ribButton1 );

  143. }
不知vla-GetInterfaceObject 能否搞定。
回复 支持 1 反对 0

使用道具 举报

发表于 2012-5-2 07:53:21 | 显示全部楼层
本帖最后由 alan_cmh 于 2012-5-2 07:54 编辑

CUI命令,选择一个左上角界面方案,点击右侧的自定义工作空间按钮


然后找到自己想显示的选项卡,打勾,再点右上角的完成,依次对各个方案分别操作,最后点确定

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2012-5-2 10:19:32 | 显示全部楼层
呵,主要是需要用程序实现。
发表于 2023-5-20 05:00:59 | 显示全部楼层
NetBee 发表于 2012-5-2 20:52
貌似.net才行呀。不知vla-GetInterfaceObject 能否搞定。

怎么使用?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-16 19:05 , Processed in 0.178341 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表