Create toolbar

Create toolbar

Anonymous
Not applicable
2,947 Views
15 Replies
Message 1 of 16

Create toolbar

Anonymous
Not applicable
Hi,

I was wondering if is possible to create a toolbar with combos and other controls using .net. I don't want to create a toolpalette, I want a toolbar to do docking.


thanks in advance for your attention,
Filipe Marcelino
0 Likes
2,948 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable
As I know you can create toolbars only with standard combos and controls (like layer). And it will be possible with help of AutoCAD ActiveX interface.
0 Likes
Message 3 of 16

Anonymous
Not applicable
Hi,

thanks for your answer. Can you teach me how to do it? A simple sample is enough for me.

Thanks in advance,
Filipe Marcelino
0 Likes
Message 4 of 16

Anonymous
Not applicable
[code]
// Add Reference to:
// 1) AutoCAD 200X Type Library
// 2) AutoCAD/ObjectDBX Common 1X.0 Type Library
// X = 6 or 7

using System ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;

[assembly: CommandClass(typeof(Rivilis.ToolbarSample))]

namespace Rivilis
{
public class ToolbarSample
{
// Define Command "TS"
[CommandMethod("TS")]
static public void TSample()
{
try
{
IAcadApplication app =
(IAcadApplication) Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
IAcadMenuGroups groups = app.MenuGroups;
IAcadMenuGroup group = groups.Item(0);
IAcadToolbars toolbars = group.Toolbars;
// Adding new toolbar
IAcadToolbar toolbar = toolbars.Add("My toolbar");
// Adding button to toolbar
IAcadToolbarItem button = toolbar.AddToolbarButton(
0, // Index of button
"My button", // Name of button
"Helpstring button", // Helpstring of button
"\x1b\x1b_.OPTIONS\n", // Macro command
false // Flyout
);
// Setting path to small and large icons
button.SetBitmaps("C:\\SmallIcon.bmp","C:\\LargeIcon.bmp");
// Center toolbar on AutoCAD Window
int x = app.WindowLeft + (app.Width - toolbar.Width)/2,
y = app.WindowTop + (app.Height - toolbar.Height)/2;
toolbar.Float(y,x,1);
}
catch (System.Exception e)
{
}
}
}
}
[/code]
0 Likes
Message 5 of 16

Anonymous
Not applicable
You also have to add references to:

acdbmgd.dll
acmdg.dll

from the AutoCAD 200X folder. Works great!

Sean Campbell
0 Likes
Message 6 of 16

Anonymous
Not applicable
> You also have to add references to:
> acdbmgd.dll
> acmdg.dll
> from the AutoCAD 200X folder. Works great!
Yes. But I bore in mind that this project created with AutoCAD Managed CS Project Wizard, which add this dlls as default.
Best Regards,
Alexander Rivilis
0 Likes
Message 7 of 16

Anonymous
Not applicable
Thanks guys, for your help. I'll try to do that. Thanks very much.

Regards,
Filipe Marcelino
0 Likes
Message 8 of 16

Anonymous
Not applicable
Hi all,

I was wondering if is possible to create a toolbar using .net in cad 2007. create a toolbar CAD 2005 is succes but it not work in cad 2007.


thanks in advance for your attention,
Tran Anh Binh
Ha Noi, Viet Nam
0 Likes
Message 9 of 16

Anonymous
Not applicable
Hi Rivilis,
I have tried your code. It is working well. But now i have two problems , plz help me.
1. I want to add a textbox in the newly created toolbar.
2. I want to give shortcut keys to added buttons.(Their macros).

Thanks.. In advance
0 Likes
Message 10 of 16

Anonymous
Not applicable
Hi, aslam!
a> 1. I want to add a textbox in the newly created toolbar.
a> 2. I want to give shortcut keys to added buttons.(Their macros).

As I know it is impossible.

Best Regards,
Alexander Rivilis.
0 Likes
Message 11 of 16

Anonymous
Not applicable
Why it is impossible? Actually i have seen in autocad toolbars that they have buttons, comboboxes etc. So we can not attach a textbox. The second thing is that , if it is impossible to give shorcut key to toolbar buttons. So the another way is to give shortcut key of their macro, what they are assign to? Isn't it?. So can you tell me how to assign shortcut keys to macros.
Thanks
0 Likes
Message 12 of 16

Anonymous
Not applicable
Hi, aslam!
a> Why it is impossible?
AutoCAD COM-interface allow only adding buttons and separators to toolbar.
Best Regards,
Alexander Rivilis.
0 Likes
Message 13 of 16

Anonymous
Not applicable
Thanks for let me know.
But how can i achive my goal now. I really needed a toolbar with 2 buttons and 1 textbox. and i aslo make them work with shortcut keys. Can anybody help me plz.
0 Likes
Message 14 of 16

Anonymous
Not applicable
It seems you're looking for your own personal help desk! Get an
ADN membership.

wrote in message news:5324205@discussion.autodesk.com...
Thanks for let me know.
But how can i achive my goal now. I really needed a toolbar with 2 buttons
and 1 textbox. and i aslo make them work with shortcut keys. Can anybody
help me plz.
0 Likes
Message 15 of 16

Anonymous
Not applicable
It is very interestiing idea! 😄
0 Likes
Message 16 of 16

Anonymous
Not applicable
brains, patients and sense of humor... 🙂
wrote in message news:5324382@discussion.autodesk.com...
It is very interestiing idea! 😄
0 Likes