找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 839|回复: 0

Acad.lsp/acaddoc.lsp fail to load when using command new/open

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-7 17:51:52 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
问题:
Why don't acad.lsp and acaddoc.lsp not load in AutoCAD 2000 when a new document
is started using (command "NEW" ..) and (command "OPEN" ...)?

This is a known problem in AutoCAD 2000 and occurs when these conditions exist:

ACADLSPASDOC is set to 1
LISPINIT is set to 1
SDI is set to 1

To replicate how AutoCAD R14 behaves when SDI is set to 1 (the Single Document
Interface is set to be active) in AutoCAD 2000, the following variables need to
be set as shown:

ACADLSPASDOC is set to 0
DBMOD is set to a value greater than 0

If the present drawing has never been modified (for example, when DBMOD is set
to 0), AutoCAD 2000 will not load and initialize user LSP files. The solution in
this case is to temporarily set LISPINIT to 0. That leaves the current
ACADDOC.LSP and MNL code to load in a New or Opened drawing.

Because ACADLSPASDOC is set to 0, you'll need use only the Acaddoc.lsp for your
autoloaded user files, and not the acad.lsp file, in order to implement this


解答:
The following code shows a combination of the following VBA code (saved into
file "MyNewOpen.dvb"):


  1. Public Sub My_Ac_New()

  2. Dim objacad As AcadApplication
  3. Set objacad = ThisDrawing.Application
  4. Dim theSDIVar As Integer
  5. theSDIVar = objacad.ActiveDocument.GetVariable("SDI")

  6. If theSDIVar = 0 Then
  7. ' If SDI = 0
  8.   objacad.Documents.Add ("acad")
  9. Else
  10. ' If SDI = 1
  11.   objacad.ActiveDocument.New ("acad")
  12. End If

  13. End Sub

  14. Public Sub My_Ac_Open()

  15. Dim objacad As AcadApplication
  16. Set objacad = ThisDrawing.Application
  17. Dim theSDIVar As Integer
  18. theSDIVar = objacad.ActiveDocument.GetVariable("SDI")
  19. Dim dwgNameVar As String
  20. dwgNameVar = objacad.ActiveDocument.GetVariable("USERS1")

  21. If theSDIVar = 0 Then
  22. ' If SDI = 0
  23.   objacad.Documents.Open dwgNameVar, False
  24. Else
  25. ' If SDI = 1
  26.   objacad.ActiveDocument.Open dwgNameVar
  27. End If

  28. End Sub


and the following lisp code:

  1. (defun RunNewOpen ()
  2.   (vl-load-com)
  3. ;;; Set LISPINIT OFF when in an Unmodified New drawing and LISPINIT = 1
  4. (if (= (getvar "DBMOD") 0) (setvar "LISPINIT" 0) (setvar "LISPINIT" 1) )
  5. (initget 1 "New Open")
  6. (setq option (getkword "\nStart a New Drawing or Open an Existing one <N/O>: ?
  7. "))
  8. (if (equal option "New")
  9.       (NewOpenWorkarround option)
  10.       (progn
  11.              (setq aDWGfile (getfiled "Open a Drawing File" "" "DWG" 0))
  12.              (if aDWGfile
  13.                   (progn
  14.                         (setvar "USERS1" aDWGfile)
  15.                         (NewOpenWorkarround option)
  16.                   )
  17.              )
  18.       )
  19. )
  20. )

  21. (defun NewOpenWorkarround (tog)
  22. (if (findfile "MyNewOpen.dvb")
  23.       (progn
  24.             (vl-vbaload "MyNewOpen.dvb")
  25.             (if (equal tog "New")
  26.                  (vl-vbarun "My_Ac_New")
  27.                  (if (equal tog "Open")
  28.                           (vl-vbarun "My_Ac_Open")
  29.                           (princ "\nNeither NEW or OPEN was specified.")
  30.                  )
  31.             )
  32.       )
  33. )
  34. (princ)
  35. )


Whenever the function (RunNewOpen) is run from your current document, the user
acaddoc.LSP amd MNL files should either load into the document as it previously
did, or still be available because LISPINT was set temporarily to 0.

For another approach to this problem using script files, see DevNote #45180.

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-21 17:39 , Processed in 0.165919 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表