comcu Posted December 5, 2008 Posted December 5, 2008 Hi, Is it possible to create commands ith autocad? i am currentyl creating drop down menus for inserting our standard block. i do like tool palettes but we have a hundreds of standard blocks and these will neve change so creating custom menus seems the best solution. i have looked in help and i have found how to create the menus but not the actual commands? Many thanks for any help. col Quote
matthewrussell Posted December 5, 2008 Posted December 5, 2008 Hey, If you are trying to link a button to a lisp file which is used to load a certain block you have created use this. ^C^C(load "insert-block");insert-detcall-block Basically the (load "insert-block") is it loading the lisp routine. Then the second part is the actual command within the lisp that will run the code you have for the block for it to be inserted. Are you using a lisp for it? and what version of autocad are you using. I have made special menus for certain block I use all the time and have found that a lisp is the easiest way to do it. Because you can copy and paste the code for each one and just change the command line and the block it is searching for. I have attached a the code I use for mine (autocad 09) ;---DETAIL BUBBLE--- (defun c:insert-detbub-block (/ layerset) (setq layerset (getvar "clayer")) (setvar "clayer" "35") (setq scaleset(/ 1 (getvar "cannoscalevalue"))) (setvar "ATTDIA" 0) (setq ins-pt (getpoint "\nSelect Insertion Point: <0,0>")) (if (= nil ins-pt) (setq ins-pt (list 805 553)) ) (command "-insert" "detail bubble" ins-pt scaleset scaleset "0") (command "explode" (entlast)) (setvar "ATTDIA" 1) (setvar "clayer" layerset) (princ) ) ;defun I have used it this way and made seperate files for each block. Quote
rocheey Posted December 5, 2008 Posted December 5, 2008 Hi, i have looked in help and i have found how to create the menus but not the actual commands? col Here is some VBA boilerplate code. It creates a few menus, and attaches a VBA macro to be called when the menu item is selected. You might just wish to create an "Insert": type subroutine, and just pass it different parameters Sub Main() Dim retMenu As AcadPopupMenu Dim retMenuItem As AcadPopupMenuItem Const MainMenuName As String = "My&Menu" ' add an Ampersand in front of letter to make it a Hotkey Const SubMenuName As String = "My&SubMenu" ' either add new, or return existing main menu Item Set retMenu = AddMainMenu(MainMenuName) '' add (or GET) main menu item ' add some sub menu item to our main menu For I% = 1 To 4 Set retMenuItem = AddMainMenuItem(retMenu, SubMenuName & Str$(I%), "TestSub") Next ' End Sub Private Function AddMainMenu(strMenuName As String) As AcadPopupMenu ' adds a main menu to acad menus, or returns an existing menu with the same name Dim currMenuGroup As AcadMenuGroup Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("ACAD") For I = 0 To currMenuGroup.Menus.Count - 1 If currMenuGroup.Menus(I).Name = strMenuName Then Set AddMainMenu = currMenuGroup.Menus(I) Exit Function End If Next ' if we're still here, we didnt find the menu, so we'll add one Set AddMainMenu = currMenuGroup.Menus.Add(strMenuName) ' Display the menu on the menu bar AddMainMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.Count + 1) End Function Private Function AddMainMenuItem(objMenu As AcadPopupMenu, strMenuItem As String, strMacroName As String) As AcadPopupMenuItem ' adds a sub menu item to the passed menu object ' the "strMenuIte" param is the name of ther menu, per VB xconvention, embed an ampersand "&" ' before the letter you want to be a hotkey ' The "strMacroName" is the name of the Subroutine you want called when the menu is selected Dim openMacro As String openMacro = "-VBARUN " & strMacroName & " " ' add a space to enmnu item to emulate the ENTER key]' Set AddMainMenuItem = objMenu.AddMenuItem(objMenu.Count + 1, strMenuItem, openMacro) End Function Sub TestSub() ' name of routine to call when menu item is selected MsgBox "your menu was just selected" End Sub Quote
BIGAL Posted December 5, 2008 Posted December 5, 2008 You can create your own menus and use slides this is like tool palettes but you write the code, A good example is the hatch pattern which pop up and you choose from the picture or the name Serach here for "Insert blocks via toolbars" is the same question your asking there is an example picture. Quote
comcu Posted December 7, 2008 Author Posted December 7, 2008 thank you everyone, i have thought about this a bit and instead of making 10 or so menus/sub menus which i was intending to do and possible loading and unloading of menus depending on the aluminium system we are using at the time i think i will set 1 macro to insert all blocks, pausing for user input for the block name and rotation only and then set up the support paths in options. thanks for everybodys help col. Quote
Recommended Posts
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.