从打开新图形模板
我期待着从现有的模板打开一个新的绘图。我知道我已经看过如何在这里做到这一点,但完全没有找到它。有人有建议吗。我只需要一个简单的命令,将打开一个新的绘图,然后我可以保存它。我已经尝试了打开文件路径,但我真的希望一些更简单的东西。谢谢 假设您已经准备好了模板,您是在寻找代码还是命令宏?如果是代码、LISP或VBA或。网 是的,我有我的模板。宏或Lisp都可以。像nE05这样简单的东西就完美了。 好的,我认为LISP就是你想要的,因为这是最简单的命令 我不是LISP大师,所以可能有一种方法可以在LISP中完成所有这些,但我不知道。我知道你可以做到这一点,那就是创建一个模板。dvb文件,用LISP快捷方式调用宏。
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
这可以称为
(defun c:nE05()
(command "-vbarun" "Example_New")
)
当然,替换模板名称和路径。如果你有几个名字,我们可以很快搞定 是的,这在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文件名(无完整路径)。 谢谢,这就是我要找的!
页:
[1]