Jump to content

Custom Menu Bar


rajuks

Recommended Posts

Hello to all

 

I am new to autocad. I am doing programming/customization for Microstation for last 4 years. But my new job requires autocad customization. I have a small question. I want to make a custom menu bar so that when operator selects any command from this menu, current layer name should change automatically and activates the desired command.

for example , operator wants to draw a center line, then he will selects "cntrLine" command from my menu, then the active layer should change to "CenterLine" Layer ( which exists already) and simultaneously line command should activate.

 

This is similar to sidebarmenu (sbm file) in Microstation.

 

Can some one help me for this topic.

Reagrds and thanks

satya

Link to comment
Share on other sites

Yea you could do it a few different way I think, a small lisp for each button or as a lisp with all commands, called by each button, or add each command lisp to the acad.lsp , and in the tool pallet also, I use them in both toolbars and pallets, I'm no expert but I use small lisps like this.

 

^C^C(cont) ^P(PROGN (command "layer" "t" "[color=red]centerline[/color]" "s" "[color=#ff0000]centerline[/color]" "f" "*" "t" "0,defpoints" "")(command "line")(princ))

 

and add other commands as well

Link to comment
Share on other sites

Thank you all of you for your suggestions. I don't know anything about auto lisp. I am good in VBA. i will try to work on your suggestions.

Thank you very much

satya

Link to comment
Share on other sites

Thank you all of you for your suggestions. I don't know anything about auto lisp. I am good in VBA. i will try to work on your suggestions.

Thank you very much

satya

 

heres a quick and dirty, half of which was stolen from the help files.

It creates a toolbar on the fly, and attaches VBA subroutines to each of the buttons it adds. Hope it gets you started.

 

 



Sub ToolbarButton()
   
   Dim currMenuGroup As AcadMenuGroup
   Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
   
   ' Create the new toolbar
   Dim newToolBar As AcadToolbar
   Set newToolBar = currMenuGroup.Toolbars.Add("TestToolbar5")
   
   ' Add a button to the new toolbar
   Dim newButton1 As AcadToolbarItem, newButton2 As AcadToolbarItem
   Dim openMacro1 As String, openMacro2 As String
   
   ' Assign the macro string the VB equivalent of "ESC ESC _open "
    openMacro1 = "-VBARUN " & "SampleSub1" & " " ' add a space to enmnu item to emulate the ENTER key]'
    Set newButton1 = newToolBar.AddToolbarButton("", "NewButton1", "Sample Macro 1", openMacro1)
    
    ' Assign the macro string the VB equivalent of "ESC ESC _open "
    openMacro2 = "-VBARUN " & "SampleSub2" & " " ' add a space to enmnu item to emulate the ENTER key]'
    Set newButton2 = newToolBar.AddToolbarButton("", "NewButton2", "Sample Macro 2", openMacro2)
   
   ' Display the toolbar
   newToolBar.Visible = True
   
End Sub

Sub SampleSub1()
   Dim tmpLayer As AcadLayer
   Set tmpLayer = ThisDrawing.Layers.Item("0")
   ThisDrawing.ActiveLayer = tmpLayer
   ThisDrawing.SendCommand "Line "
End Sub
Sub SampleSub2()
   Dim tmpLayer As AcadLayer
   Set tmpLayer = ThisDrawing.Layers.Item("0")
   ThisDrawing.ActiveLayer = tmpLayer
   ThisDrawing.SendCommand "Circle "
End Sub


Link to comment
Share on other sites

Hello to all

 

I am new to autocad. I am doing programming/customization for Microstation for last 4 years. But my new job requires autocad customization. I have a small question. I want to make a custom menu bar so that when operator selects any command from this menu, current layer name should change automatically and activates the desired command.

for example , operator wants to draw a center line, then he will selects "cntrLine" command from my menu, then the active layer should change to "CenterLine" Layer ( which exists already) and simultaneously line command should activate.

 

This is similar to sidebarmenu (sbm file) in Microstation.

 

Can some one help me for this topic.

Reagrds and thanks

satya

 

welcome rajuks, so yet another soul makes it over from the "dark side" :twisted:

congratulations!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...