是的,这在Visual lisp中是可能的。您可以这样定义函数:
- (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
和定义用户命令的短函数。例如:
- (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
用于TMPL1和TMPL2命令。作为参数,您必须使用short*。dwt文件名(无完整路径)。 |