ObjectARX

Reply
Contributor
1cacalvo
Posts: 13
Registered: ‎06-07-2006
Message 1 of 7 (419 Views)

New ToolBar sample

419 Views, 6 Replies
06-07-2006 06:51 AM
Can anyone give me a hand on creating a toolbar in AutoCAD with arx? I have
looked through the help files but cannot find anything. Where do I need to
begin and what do I need to look out for? If anyone knows where to find a
tutorial or a simple example, I would appreciate it.
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 7 (419 Views)

Re: New ToolBar sample

06-08-2006 03:00 PM in reply to: 1cacalvo
Simplest code without error checking:
[code]
#import "acax16enu.tlb" no_namespace

static void AddToolbar(void)
{
// Add your code for command Toolbar.AddToolbar here
try
{
IAcadApplicationPtr pAcad = acedGetAcadWinApp()->GetIDispatch(TRUE);
IAcadMenuGroupsPtr pMnuGrps = pAcad->MenuGroups;
IAcadMenuGroupPtr pMnuGrp = pMnuGrps->Item(0);
IAcadToolbarsPtr pTlbrs = pMnuGrp->Toolbars;
IAcadToolbarPtr pTlbr = pTlbrs->Add("My toolbar");
IAcadToolbarItemPtr pTlbrItem = pTlbr->AddToolbarButton(
0, // Item number
"MyName", // Item name
"Help string", // Item help string
"\x1b\x1b_.Options " // Item macro string
);
pTlbrItem->SetBitmaps("C:\\SmallIcon.bmp","C:\\LargeIcon.bmp");
}
catch (...)
{

}
}
[/code]
Contributor
1cacalvo
Posts: 13
Registered: ‎06-07-2006
Message 3 of 7 (419 Views)

Re: New ToolBar sample

06-09-2006 03:56 AM in reply to: 1cacalvo
Thanks.... A lot of!! :smileyvery-happy:
Active Contributor
mbasa
Posts: 31
Registered: ‎03-01-2006
Message 4 of 7 (419 Views)

Re: New ToolBar sample

09-26-2006 03:56 AM in reply to: 1cacalvo
It is great thanks but after I create a new toolbar and I close AutoCAD it is not saved with the other AutoCAD toolbars. Everytime I have to recreate and relocate.

How can I save my new toolbar so that everytime AutoCAD opens it will be in its las position????
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 5 of 7 (419 Views)

Re: New ToolBar sample

09-26-2006 04:30 AM in reply to: 1cacalvo
Created with help of ActiveX toolbar cannot be saved such as toolbar from mnu/cui-file. You need to monitor toolbar position (for example in command reactor) save it and after restart AutoCAD create toolbar and set it's position from saved value.
Active Contributor
mbasa
Posts: 31
Registered: ‎03-01-2006
Message 6 of 7 (419 Views)

Re: New ToolBar sample

09-26-2006 11:39 PM in reply to: 1cacalvo
I tries this mnu files those toolbars created with mnu files cannot be saved either.

Can you show me any example or link for creating toolbars with mnu files?

I used the AutoCAD 2004 doumentation from the help of AutoCAD itself.

Thanks anyways:smileyhappy:
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 7 of 7 (419 Views)

Re: New ToolBar sample

09-27-2006 01:49 AM in reply to: 1cacalvo
Read acad.mnu and find **toolbar section. You have to create own mnu-file and load it with help of menuload command.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!