Creating a menu in solidworks 08

234 views
Skip to first unread message

sundarland

unread,
Apr 21, 2009, 1:19:56 PM4/21/09
to SolidWorks-API
Hi,
I have developed a API in solidworks using macro and Visual Basic. I
would like to know if I can add this macro program in the menubar of
solidworks.

stephan...@googlemail.com

unread,
Apr 21, 2009, 5:20:35 PM4/21/09
to SolidWorks-API
Hey sundarland,

yes you can do this. It's explained pretty well in the SolidWorks Api.
Just search for "Assign SolidWorks Macro to Button" and you should be
able to find the article.

Stephan

Vinay CAD 1 GMail

unread,
Jul 20, 2009, 3:46:49 AM7/20/09
to SolidWorks API
Hi,

I want to add a new Menu at particular position. I.e. before "Help"

CommandManager::CreateCommandGroup() function takes position{long} as an
argument.
e.g.
hres =
iCmdMgr->CreateCommandGroup(1,title,tooltiple,hint,position,&icmdGroup);

I tried to get the position of 'Help' menu by following 2 approaches

// Approach 1
1. Get Command Group for HELP menu - Couldn't succeed here
2. Get Menu position for the command group

// Approach 2
1. Get All command groups from Command manager. - I get Command
Group count as 0. I think the CommandManager::NumberOfGroups() function
returns 0
2. Iterate through them and find the 'Help' menu group by name
3. Get the position


Can any body help here ?

Or is there another approach for this ?

Thanks.

regards,

Vinay

Vinay CAD 1 GMail

unread,
Jul 20, 2009, 10:27:41 PM7/20/09
to SolidWorks API
Hi ,

I think my approaches were wrong.

Command manager and command groups are only applicable for custom add-in
menus added by user.

But still remains the main question.
How to get a position of a particular menu ( Menu group) in SolidWorks so
that we can add/position a new custom menu before or after it ?
e.g. how to position a new custom command group before 'Help' menu ?

Thanks.

Vinay

--------------------------------------------------
From: "Vinay CAD 1 GMail" <vjirga...@gmail.com>
Sent: Monday, July 20, 2009 3:46 PM
To: "SolidWorks API" <SolidWo...@googlegroups.com>
Subject: Adding a menu at particular position

swpwrpk

unread,
Jul 25, 2009, 12:11:32 AM7/25/09
to SolidWorks-API
Try this in C#
IFrame MainFrame = iSwApp.Frame() as IFrame;
int DocNonePos = MainFrame.GetSubMenuCount((int)
swDocumentTypes_e.swDocNONE, "Main") -1;
int DocDrwPos = MainFrame.GetSubMenuCount((int)
swDocumentTypes_e.swDocDRAWING, "Main") -2;
int DocPartPos = MainFrame.GetSubMenuCount((int)
swDocumentTypes_e.swDocPART, "Main") -2;
int DocAssPos = MainFrame.GetSubMenuCount((int)
swDocumentTypes_e.swDocASSEMBLY, "Main") -2;

cmdGroup.set_MenuPosition((int)
swDocTemplateTypes_e.swDocTemplateTypeNONE, DocNonePos);
cmdGroup.set_MenuPosition((int)
swDocTemplateTypes_e.swDocTemplateTypeDRAWING, DocDrwPos);
cmdGroup.set_MenuPosition((int)
swDocTemplateTypes_e.swDocTemplateTypePART, DocPartPos);
cmdGroup.set_MenuPosition((int)
swDocTemplateTypes_e.swDocTemplateTypeASSEMBLY, DocAssPos);

On Jul 20, 10:27 pm, "Vinay CAD 1 GMail" <vjirgale....@gmail.com>
wrote:
> Hi ,
>
> I think my approaches were wrong.
>
> Command manager and command groups are only applicable for custom add-in
> menus added by user.
>
> But still remains the main question.
> How to get a position of a particular menu ( Menu group) in SolidWorks so
> that we can add/position a new custom menu before or after it ?
> e.g. how to position a new custom command group before 'Help' menu ?
>
> Thanks.
>
> Vinay
>
> --------------------------------------------------
> From: "Vinay CAD 1 GMail" <vjirgale....@gmail.com>
> Sent: Monday, July 20, 2009 3:46 PM
> To: "SolidWorks API" <SolidWo...@googlegroups.com>
> Subject: Adding a menu at particular position
>
>
>
> > Hi,
>
> > I want to add a new Menu at particular position. I.e. before "Help"
>
> > CommandManager::CreateCommandGroup() function takes position{long} as an
> > argument.
> > e.g.
> > hres =
> > iCmdMgr->CreateCommandGroup(1,title,tooltiple,hint,position,&icmdGroup);
>
> > I tried to get the position of 'Help' menu by following 2 approaches
>
> > // Approach 1
> > 1. Get Command Group for HELP menu - Couldn't succeed here
> > 2. Get Menu position for the command group
>
> > // Approach 2
> >            1. Get All command groups from Command manager. - I get Command
> > Group count as 0. I think the CommandManager::NumberOfGroups() function
> > returns 0
> >            2. Iterate through them and find the 'Help' menu group by name
> >            3. Get the position
>
> > Can any body help here ?
>
> > Or is there another approach for this ?
>
> > Thanks.
>
> > regards,
>
> > Vinay- Hide quoted text -
>
> - Show quoted text -

Eduardo

unread,
Sep 2, 2009, 4:30:23 AM9/2/09
to SolidWorks-API
The position is specified in SolidWorks AddMenu method:

iSwApp.AddMenu(docType, menu_text, POSITION)
iSwApp.AddMenuItem3(...)
iSwApp.AddMenuItem3(...)
iSwApp.AddMenuItem3(...)
.
.
.
iSwApp.AddMenuItem3(...)



On 21 Jul, 03:27, "Vinay CAD 1 GMail" <vjirgale....@gmail.com> wrote:
> Hi ,
>
> I think my approaches were wrong.
>
> Command manager and command groups are only applicable for custom add-in
> menus added by user.
>
> But still remains the main question.
> How to get a position of a particular menu ( Menu group) in SolidWorks so
> that we can add/position a new custom menu before or after it ?
> e.g. how to position a new custom command group before 'Help' menu ?
>
> Thanks.
>
> Vinay
>
> --------------------------------------------------
> From: "Vinay CAD 1 GMail" <vjirgale....@gmail.com>
> Sent: Monday, July 20, 2009 3:46 PM
> To: "SolidWorks API" <SolidWo...@googlegroups.com>
> Subject: Adding a menu at particular position
>
>
>
> > Hi,
>
> > I want to add a new Menu at particular position. I.e. before "Help"
>
> > CommandManager::CreateCommandGroup() function takes position{long} as an
> > argument.
> > e.g.
> > hres =
> > iCmdMgr->CreateCommandGroup(1,title,tooltiple,hint,position,&icmdGroup);
>
> > I tried to get the position of 'Help' menu by following 2 approaches
>
> > // Approach 1
> > 1. Get Command Group for HELP menu - Couldn't succeed here
> > 2. Get Menu position for the command group
>
> > // Approach 2
> >            1. Get All command groups from Command manager. - I get Command
> > Group count as 0. I think the CommandManager::NumberOfGroups() function
> > returns 0
> >            2. Iterate through them and find the 'Help' menu group by name
> >            3. Get the position
>
> > Can any body help here ?
>
> > Or is there another approach for this ?
>
> > Thanks.
>
> > regards,
>
> > Vinay- Ocultar texto citado -
>
> - Mostrar texto citado -
Reply all
Reply to author
Forward
0 new messages