lisplost Posted September 29, 2008 Posted September 29, 2008 I am looking to open a new drawing from an existing template. I know I have seen how to do this on here but an totally not finding it. Does anyone have a sugestion. I just want a simple command that will open a new drawing and then I can save it. I have tried the open with the file path but I would really like something a little more simple. Thanks. Quote
CmdrDuh Posted September 29, 2008 Posted September 29, 2008 Assuming you have your templates in place, are you looking for code or a command macro? If code, LISP or VBA or .Net? Quote
lisplost Posted September 29, 2008 Author Posted September 29, 2008 Yes, I have my templates in place. Either a Macro or a Lisp would be fine. something as simple as nE05 would be perfect. Quote
CmdrDuh Posted September 29, 2008 Posted September 29, 2008 OK, Im thinking LISP is what you want, as that is the simplest to make a command with Quote
CmdrDuh Posted September 29, 2008 Posted September 29, 2008 I am not a LISP guru, so there may be a way to do all of this in LISP, but I dont know it. I do know you can do this though, which is create a template.dvb file, with LISP shortcuts to call the macros. Sub Example_New() ' This example creates a new drawing based on the template ansi-a.dwt. ' Note: The path to the template file is included with its name. Adjust ' this path for your installation location before running this example. Dim templateFileName As String templateFileName = "c:\AutoCAD\template\ansi-a.dwt" ThisDrawing.New templateFileName End Sub and that could be called with (defun c:nE05() (command "-vbarun" "Example_New") ) of course, substitute your template name and path. If you have a few names you want, we can knock thouse out real quick Quote
ASMI Posted September 29, 2008 Posted September 29, 2008 Yes it possible in Visual lisp. You can define function like this: (defun NewFromTemplate(Template / tmplPat cTmpl) (vl-load-com) ; retrieve standard Template folder (setq tmplPat (vla-get-TemplateDWGPath (vla-get-Files (vla-get-Preferences (vlax-get-acad-object))))) ; if template found (if(setq cTmpl (findfile (strcat tmplPat "\\" Template))) ; create and activate drawing (vla-Activate (vla-Add (vla-get-Documents (vlax-get-acad-object)) cTmpl ) ) (alert(strcat "Can't to find template: " Template )) ) ); end of NewFromTemplate And short functions to define user commnads. For example: (defun c:tmpl1() (NewFromTemplate "acadiso.dwt") (princ) ); end of c:tmpl1 (defun c:tmpl2() (NewFromTemplate "acadISO -Named Plot Styles3D.dwt") (princ) ); end of c:tmpl2 for TMPL1 and TMPL2 commands. As argument you must to use short *.dwt file name (without full path). Quote
lisplost Posted October 6, 2008 Author Posted October 6, 2008 Thanks these were what I was looking for! 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.