You need to use Visual LISP.
Look into the vla-Add , and vla-Activate Methods of the Documents Object, and the resultant Document Object respectively.
Registered forum members do not see this ad.
Ok so to give a little background what is going on I have Autocad 2010 with Rastercad Add on. I want to create a macro that will let me open a new drawing hit enter(for the basic autocad templete) and then run the command gattach which will open a window that will allow me to open my raster image. I can not get the new command to open the dwg templete without asking me. Here is what i have so far:
^C^C_new ;-Gattach![]()
Engineering Technician \ Documentation Manager
www.clydegibson.tk
Solidworks 2010-2012 / AutoCAD 2007-2012 / Inventor 2008-2009 / RasterCAD / Unigrapics NX6 - NX7
"One man with courage is a majority." Thomas Jefferson
You need to use Visual LISP.
Look into the vla-Add , and vla-Activate Methods of the Documents Object, and the resultant Document Object respectively.
"Potential has a shelf life." - Margaret Atwood




put this on a toolbar button:
^c^c filedia 0 _new ; filedia 1 -gattach.
I don't have the rastercad addon you mentioned, but this works when I substitute ._move for -gattach. you may have to play with the gattach command a bit, but the first part will get you around the dialog box
Never try to teach a pig to sing. It wastes your time and annoys the pig. -Robert Heinlein
Example:
Macro:
FOO.lsp code:Code:^C^C(if (not c:FOO)(load "FOO"));FOO
Simply replace all instances of "FOO" with whatever name you want.Code:(defun c:FOO ( / oAcad) (vl-load-com) (vla-activate (vla-add (vla-get-documents (setq oAcad (vlax-get-acad-object))) (vla-get-qnewtemplatefile (vla-get-files (vla-get-preferences oAcad))))) (princ))
"Potential has a shelf life." - Margaret Atwood




Sorry...started that answer, then got a phone call. By the time I finished and got back to it, your answer (which might be the better one) was there. The "filedia 0" part turns that dialog box off, "new" is obvious, the ; after it is an enter of course (causing it to use whatever default template you have set), then "filedia 1" turns the dialog box back on. After that, any command should work in the format you would use if you typed it in on the command line.
Never try to teach a pig to sing. It wastes your time and annoys the pig. -Robert Heinlein
Engineering Technician \ Documentation Manager
www.clydegibson.tk
Solidworks 2010-2012 / AutoCAD 2007-2012 / Inventor 2008-2009 / RasterCAD / Unigrapics NX6 - NX7
"One man with courage is a majority." Thomas Jefferson
Engineering Technician \ Documentation Manager
www.clydegibson.tk
Solidworks 2010-2012 / AutoCAD 2007-2012 / Inventor 2008-2009 / RasterCAD / Unigrapics NX6 - NX7
"One man with courage is a majority." Thomas Jefferson
*blink* *blink*![]()
"Potential has a shelf life." - Margaret Atwood




Registered forum members do not see this ad.
Well, heckydurn as my wife would say. It worked here, several times...but now I can't get it to do it again. Ok...so that apparently don't work after all. Sorry. See Renderman's answer, maybe his will.
This is very annoying. I sat here and ran it several times...each time it opened a new drawing...hmmm. If I get it fixed, I'll post what did. Its probably something pretty obvious that I'm just overlooking. Sitting there waving it's little arms at me I'm sure.
Did find one mistake...there should be no space between the two cancels and the first "filedia".
I will figure this out.
Never try to teach a pig to sing. It wastes your time and annoys the pig. -Robert Heinlein
Bookmarks