CAD2009以上有选项卡,如何加载局部菜单中的选项卡?
CAD2009以上有选项卡,如何加载局部菜单中的选项卡?在局部菜单中已经定义了选项卡,但加载后在CAD中仍然无法显示,是需要一个命令来激活吗?
http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 NetBee的微博 本帖最后由 NetBee 于 2012-5-2 21:38 编辑
貌似.net才行呀。
1- Using VS2005 for AutoCAD 2009:
-- In stdafx.h add this lines:
#using <mscorlib.dll>
#using <System.dll>
#using <acdbmgd.dll>
#using <acmgd.dll>
#using <AcRibbon.dll>
#using <AdWindows.dll>
#using <PresentationCore.dll>
#using <PresentationFramework.dll>
#using <WindowsBase.dll>
--- MyRibbonTabProxy.h
#pragma once
#include "StdAfx.h"
using namespace System;
using namespace Autodesk::Windows;
using namespace Autodesk::AutoCAD::Ribbon;
void MakeIt(void);
public __gc class MyRibbonTabProxy
{
private:
RibbonTab*m_RibTab;
public:
MyRibbonTabProxy(String* title, String* id );
protected:
void OnButtonClick(Object* sender, Windows::RoutedEventArgs * ea);
};
--- MyRibbonTabProxy.cpp
#include "StdAfx.h"
#include "MyRibbonTabProxy.h"
void MakeIt()
{
MyRibbonTabProxy* rb = new MyRibbonTabProxy( S"CadOfiTec", S"CadOfiTecTab" );
}
MyRibbonTabProxy::MyRibbonTabProxy(String* title, String* id )
{
RibbonControl* ribCtrl = Autodesk::AutoCAD::Ribbon::RibbonServices::RibbonPaletteSet->RibbonControl;
if( ribCtrl == NULL )
return;
m_RibTab =ribCtrl->FindTab( id );
if( m_RibTab != NULL )
return;
m_RibTab = new RibbonTab();
m_RibTab->Title = title;
m_RibTab->Id = id;
ribCtrl->Tabs->Add( m_RibTab );
m_RibTab->IsActive = true;
// Create the panel source
RibbonPanelSource* ribSourcePanel = new RibbonPanelSource();
ribSourcePanel->Title = "Bloques";
RibbonPanel* ribPanel = new RibbonPanel;
ribPanel->Source = ribSourcePanel;
m_RibTab->Panels->Add( ribPanel );
// Create a button
RibbonButton* ribButton1 = new RibbonButton();
ribButton1->Text = S"AddTE";
ribButton1->Click += new Windows::RoutedEventHandler(this, &MyRibbonTabProxy:: OnAddTEClick);
ribButton1->ShowText = true;
RibbonRow* row = new RibbonRow();
row->Items->Add(ribButton1);
ribSourcePanel->Rows->Add( row );
}
void MyRibbonTabProxy:: OnAddTEClick(Object* sender, Windows::RoutedEventArgs *ea)
{
Autodesk::AutoCAD::ApplicationServices::Application:: DocumentManager
->MdiActiveDocument->SendStringToExecute(S"_AddTE ",false, false, false );
}
2 - Using VS2008 for AutoCAD 2011:
-- In stdafx.h add this lines:
#using <mscorlib.dll>
#using <System.dll>
#using <acdbmgd.dll>
#using <acmgd.dll>
#using <AcCui.dll>
#using <AdWindows.dll>
#using <PresentationCore.dll>
#using <PresentationFramework.dll>
#using <WindowsBase.dll>
#pragma once
#include "StdAfx.h"
using namespace System;
using namespace Autodesk::Windows;
void MakeIt(void);
// The new implementation uses ICommand instead RoutedEventHandler
public __gc class AutoCADCommandHandler: public ICommand
{
public:
void remove_CanExecuteChanged(System::EventHandler* eh){};
void add_CanExecuteChanged(System::EventHandler* eh){};
AutoCADCommandHandler(){};
bool CanExecute(Object* parameter);
void Execute(Object* parameter);
};
public __gc class MyRibbonTabProxy
{
private:
RibbonTab*m_RibTab;
public:
MyRibbonTabProxy(String* title, String* id );
};
void MakeIt()
{
MyRibbonTabProxy* rb = new MyRibbonTabProxy( S"CadOfiTec", S"CadOfiTecTab" );
}
bool AutoCADCommandHandler::CanExecute(Object* parameter)
{
return true;
}
void AutoCADCommandHandler::Execute(Object* parameter)
{
RibbonButton* ribBtn =
static_cast<Autodesk::Windows::RibbonButton*> (parameter);
Autodesk::AutoCAD::ApplicationServices::Application:: DocumentManager
->MdiActiveDocument->SendStringToExecute(
static_cast<System:tring*>(ribBtn->CommandParameter), false, false, false );
}
MyRibbonTabProxy::MyRibbonTabProxy(String* title, String* id )
{
RibbonControl* ribCtrl = Autodesk::Windows::ComponentManager::Ribbon;
if( ribCtrl == NULL )
return;
m_RibTab =ribCtrl->FindTab( id );
if( m_RibTab != NULL )
return;
m_RibTab = new RibbonTab();
m_RibTab->Title = title;
m_RibTab->Id = id;
ribCtrl->Tabs->Add( m_RibTab );
m_RibTab->IsActive = true;
// Create the panel source
RibbonPanelSource* ribSourcePanel = new RibbonPanelSource();
ribSourcePanel->Title = "Bloques";
RibbonPanel* ribPanel = new RibbonPanel;
ribPanel->Source = ribSourcePanel;
m_RibTab->Panels->Add( ribPanel );
// Create a button
RibbonButton* ribButton1 = new RibbonButton();
ribButton1->Text = S"AddTE";
ribButton1->ShowText = true;
AutoCADCommandHandler* ch = new AutoCADCommandHandler();
ribButton1->CommandHandler = ch;
ribSourcePanel->Items->Add( ribButton1 );
}
不知vla-GetInterfaceObject 能否搞定。 本帖最后由 alan_cmh 于 2012-5-2 07:54 编辑
CUI命令,选择一个左上角界面方案,点击右侧的自定义工作空间按钮
然后找到自己想显示的选项卡,打勾,再点右上角的完成,依次对各个方案分别操作,最后点确定
呵,主要是需要用程序实现。 NetBee 发表于 2012-5-2 20:52
貌似.net才行呀。不知vla-GetInterfaceObject 能否搞定。
怎么使用?
页:
[1]