Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I have written a plugin in C# .Net for Autocad, it works well in systems with Windows 10, but it gives this error in Windows 7 :
The codes :
public class EICommands : IExtensionApplication
{
public void createRibbon()
{
RibbonControl ribbon = ComponentManager.Ribbon;
RibbonTab rtab = new RibbonTab();
rtab = new RibbonTab();
rtab.Title = "MyPlugin";
rtab.Id = "Testing";
//Add the Tab
ribbon.Tabs.Add(rtab);
RibbonPanelSource rps = new RibbonPanelSource();
rps.Title = "Test";
RibbonPanel rp = new RibbonPanel();
rp.Source = rps;
rtab.Panels.Add(rp);
RibbonButton btn1 = new RibbonButton();
btn1.Text = "Button1";
btn1.CommandParameter = "_tspp ";
btn1.Id = "TOGGLE1";
btn1.Text = "topo";
btn1.ShowText = true;
btn1.ShowImage = true;
btn1.Image = LoadImage(Properties.Resources.topo);
btn1.LargeImage = LoadImage(Properties.Resources.topo);
btn1.Orientation =
System.Windows.Controls.Orientation.Vertical;
btn1.Size = RibbonItemSize.Large;
btn1.CommandHandler = new RibbonCommandHandler();
rps.Items.Add(btn1);
rps.Items.Add(new RibbonSeparator());
}
public class RibbonCommandHandler : System.Windows.Input.ICommand
{
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
RibbonButton btn = parameter as RibbonButton;
if (btn != null)
{
Document dwg =
Autodesk.AutoCAD.ApplicationServices.Application.
DocumentManager.MdiActiveDocument;
dwg.SendStringToExecute((string)btn.CommandParameter,
true, false, true);
}
}
}
void IExtensionApplication.Initialize()
{
Application.Idle += new EventHandler(Application_Idle);
}
void IExtensionApplication.Terminate()
{
// Do plug-in application clean up here
}
void Application_Idle(object sender, EventArgs e)
{
Application.Idle -= Application_Idle;
EICommands cmd = new EICommands();
cmd.createRibbon();
}
}
I have written it in :
Visual studio 2019
Autocad 2017 api
.Net Framework 4.5
Target system :
Windows 7 64 bit
Autocad 2017
Solved! Go to Solution.