robwell Posted February 22, 2018 Share Posted February 22, 2018 Is there a way to create a macro button to open a specific file? I have the qnew to open a specific template, but there is another file that I reference a lot that I would like to create a button for to open easily. What would be the macro code for that? I have looked many places online, but am coming up short to something working properly. Thanks Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 22, 2018 Share Posted February 22, 2018 You could just as easily open the drawing using a script file as long as you have one other drawing open at the time as you run the script from the command line. To do it with a macro try.... ^C^CFiledia;0;Open;"C:/path_to_your_drawing_here/myreference.dwg";Filedia;1; Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 22, 2018 Share Posted February 22, 2018 I have moved your thread to the The CUI, Hatches, Linetypes, Scripts & Macros Forum. Quote Link to comment Share on other sites More sharing options...
robwell Posted February 22, 2018 Author Share Posted February 22, 2018 I tried using that exact macro ReMark, but it doesn't work properly for me. I am using a full version of AutoCAD 2018. Maybe it's the filepath messing up for me because the directory I am trying to nav to is in our T: drive. I have even tried changing the slashes forward and backward, removing the quotation marks and other variations, but it won't open the direct file. I don't know much about script files, so I might need a little guidance on how to do that. Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 22, 2018 Share Posted February 22, 2018 The script file would require a working path to the drawing. Quote Link to comment Share on other sites More sharing options...
robwell Posted February 22, 2018 Author Share Posted February 22, 2018 The path to the drawing is fine. T:\02_Standards\03_Block_Library\CYNERGY\PENDING\CYN_DETAILS_GENERAL.dwg Unless there are characters not registering when reading it. I have tried other file paths to other drawings, but the drawings are not opening directly from the button click. Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 22, 2018 Share Posted February 22, 2018 Use Notepad to write the script. Should look something like this: OPEN {insert path to file here} Save as MyRef.scr While in a drawing that is already open invoke the SCRIPT command, browse to the script location, select the file to run it. Your reference drawing should then open. Quote Link to comment Share on other sites More sharing options...
steven-g Posted February 22, 2018 Share Posted February 22, 2018 And try quotes around the name as Autocad doesn't like spaces when it is expecting text. also, try replacing the backslashes with forward slashes (another Autocad quirk). If the command is failling post the command line history it might tell us what is going wrong Quote Link to comment Share on other sites More sharing options...
robwell Posted February 22, 2018 Author Share Posted February 22, 2018 I've tried all kinds of variations using those tricks steven, but the open command just will not work to open a file directly through a macro button. However, I did create a script file as suggested by ReMark and then create a macro button to run the script and that worked prefectly. I don't know why the macro with open command will not open a file directly. It works with the script though, so that's all that matters. Thanks ReMark Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 22, 2018 Share Posted February 22, 2018 Glad to hear you got it sorted out. You're entirely welcomed. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 23, 2018 Share Posted February 23, 2018 My version of what your trying to do. These are complete drawings not blocks. Quote Link to comment Share on other sites More sharing options...
robwell Posted February 23, 2018 Author Share Posted February 23, 2018 Is this a lisp program? What is this? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 23, 2018 Share Posted February 23, 2018 (edited) Its an old fashioned menu with slide images, its an in built function within Autocad etc, it has been around since almost the beginning of Autocad. You make or add to a pull down menu. We have around 10 of these and they can be multiple pages. The basic instructions is that you make a menu and have what is known as a image section each image then has an instruction which can be do commands or run a lisp etc. You will need to do a bit of homework about making menu's but if you can use notepad your 1/2 way there. You make MSLIDE which is like the bitmap image of the dwg I have turned off lots of stuff to make the images a bit clearer to see but basicly you can use zoom extents. I scripted the images so made like 50 slides in one go. No cad at moment Vslide views. You can make a SLB slide library so only need 1 file when say copying to another pc. This is an example code for the image just cut down a bit as this menu has numerous options. The "openblk" gets around the problem of spaces in the file names etc. ***MENUGROUP=BIG-Al ***POP19 **CADLIB [LIBRARY] [->Stddwgs] [TRENCH]$I=BIG-Al.TRENCH $I=* [PIPES]$I=BIG-Al.PIPES $I=* [PITS]$I=BIG-Al.PITS $I=* [KERBS]$I=BIG-Al.KERBS $I=* [ROADX]$I=BIG-Al.ROADX $I=* [PAVEMENTS]$I=BIG-Al.PAVEMENT $I=* [MISC]$I=BIG-Al.MISC $I=* [<-] ***image **KERBS [KERBS] [bIG-AlSLD(SD401,B1 KERB)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG401") [bIG-AlSLD(SD402,B2 KERB)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG402") [bIG-AlSLD(SD403,B3 KERB)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG403") [bIG-AlSLD(SD404,LAYBACK B2-3)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG404") [bIG-AlSLD(SD405,SM1 KERB)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG405") (defun openblk (blkname / adocs) (setq acDocs (vla-get-documents (vlax-get-acad-object))) (vla-open acDocs blkname) (vla-activate (vla-item acdocs 1)) ) Lastly can do exactly the same using lisp and dialouges. I have like 2x2 3x2 4x4 image patterns etc. Edited February 23, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
tombu Posted February 24, 2018 Share Posted February 24, 2018 The path to the drawing is fine.T:\02_Standards\03_Block_Library\CYNERGY\PENDING\CYN_DETAILS_GENERAL.dwg Unless there are characters not registering when reading it. I have tried other file paths to other drawings, but the drawings are not opening directly from the button click. The backslash \ symbol is used toPause for User Input in Macros. Just substitute each / (as in a macro that's a pause request) with \\ as in "T://02_Standards//03_Block_Library//CYNERGY//PENDING//C YN_DETAILS_GENERAL.dwg" As steven-g said spaces and semicolons; act as Enter in macros so placing the path in quotes is needed for any path that contains a space. Also (strcat "T:" (chr 92) "02_Standards" (chr 92) "03_Block_Library" (chr 92) "CYNERGY" (chr 92) "PENDING" (chr 92) "C YN_DETAILS_GENERAL.dwg") returns "T:\\02_Standards\\03_Block_Library\\CYNERGY\\PENDING\\C YN_DETAILS_GENERAL.dwg" as well. So ^C^C^P(vl-load-com)(vla-activate(vla-open (vla-get-documents (vlax-get-acad-object))(strcat "T:" (chr 92) "02_Standards" (chr 92) "03_Block_Library" (chr 92) "CYNERGY" (chr 92) "PENDING" (chr 92) "C YN_DETAILS_GENERAL.dwg") :vlax-false)) could be another macro option. Quote Link to comment Share on other sites More sharing options...
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.