eric_monceaux 发表于 2022-7-6 12:13:09

定制acaddoc。lsp

大家好!
 
因此,我正在努力最终开始找出AutoCAD的编码和变量。我当前的项目是创建一个启动lisp,用于设置新图形和/或现有图形的所有值。我已经正确配置了所有命令,但是,有没有办法不让它输出它更改的设置?基本上,当您启动图形(新/旧)时,它会实现所有更改,但命令行不会显示该过程。
 
其次,在阿卡多克内部。lsp,我希望最后一个命令在用户继续之前调用自定义LISP:
(command "DWG")
在阿卡多克结束的时候,我一直收到一个错误。lsp:
Enter new value for SPLINESEGS <20>: 20 FACETRES
Enter new value for FACETRES <10.0000>: 10 ISOLINES
Enter new value for ISOLINES <10>: 20 DWG Unknown command "DWG".Press F1 for
help.
我不知道在《阿卡多克》结束时调用LISP缺少了什么。LSP。
 
这是整个阿卡多克。lsp:
;
;
;North American Stone Drawing Set Up
;
;
;---------------------
;LISP Loads
;
(autoload "autoDPROP" '("autoDPROP"))
(autoload "nasc_props" '("nasc_props" "dwg"))
;ENVIRONMENT
(command "base" "0,0,0")
(setvar "osmode" 6255)
(command "-INSERT" "Z_STD_SETUP" "0,0" "1" "" "0")
(command "ERASE" "L" "")
(command "-STYLE" "SHEET" "tahoma.TTF" "0" "1" "0" "N" "N")
(command "-LAYER" "S" "0-STONE" "")
(command "-DIMSTYLE" "R" "16")
(command "LTSCALE" "6")
(command "PDMODE" "3")
(command "PDSIZE" "0")
(command "-HATCH" "P" "AR-SAND" "0.25" "0" "")
(command "-UNITS" "4" "16" "1" "0" "0" "N")
(command "VIEWRES" "Y""20000")
(command "SPLINESEGS" "20")
(command "FACETRES" "10")
(command "ISOLINES" "20")
(c:dwg)
 
我至少走对了吗???

dbroada 发表于 2022-7-6 12:17:43

它告诉您,AutoCAD没有已知的名为“DWG”的命令
 
我假设您正在尝试启动一个名为dwg的lisp文件,在这种情况下,您需要先加载它。我在这里猜测,但尝试一下(类似)
 

(load "DWG")
DWG

eric_monceaux 发表于 2022-7-6 12:21:35

我的道歉。。。是的,我正在尝试加载自定义LISP。我应该解释一下,我在命令集中有这个功能。
(autoload "nasc_props" '("nasc_props"))
 
nasc_props是使用DWG命令的lisp:
(defun C:DWG ()

rkmcswain 发表于 2022-7-6 12:23:55

首先,通常不能*调用这样的外部定义的lisp命令(命令“dwg”)[*例外情况是使用(vlax add cmd)]
 
其次,如果要自动加载“nasc_props”,并且该文件包含“Dwg”函数,则需要将“Dwg”添加到(autoload)调用的第二个参数中,如下所示:
 

(autoload "nasc_props" '("nasc_props" "dwg"))

 
最后,要调用此函数,可以执行以下操作:
 

(c:dwg)

eric_monceaux 发表于 2022-7-6 12:26:08

我将代码更改为您显示的代码,并编辑了我的原始帖子以反映这些更改。现在我得到以下信息:
Job Number:*Cancel*

Job Number:
Command: *Cancel*
Function cancelled
 
进一步讨论我试图自动调用的lisp的描述,我附上下面的代码。此lisp旨在要求用户在命令行上输入自定义DWGPROPS信息。阿卡多克之后。lsp完成,nasc_道具。lsp工作正常。
 
这是从属lisp(在acaddoc.lsp中命名为AutoDPROP.lsp)
;;; *********************************************** *************************
;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group
;;; *
;;; * _dwgru-Dwgprops-get-all-prop
;;; *
;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA)
;;; *********************************************** *************************

(defun _dwgru-dwgprops-get-all-prop (Doc / si ret nc key value)
;;; Returns the file's properties, set the team _dwgprops
;;; Returns an associative list, where the key is:
;; - For properties created by the user (tab OTHER)
;;; Property name
;; - For standard properties (tab PAPER)
;;; Key field
;;; NAME - *TITLE*
;;; AUTHOR - *AUTHOR*
;;; TOPIC - *SUBJECT*
;;; KEY WORDS - *KEYWORDS*
;;; NOTES - *COMMENTS*
;;; Hyperlink Base - *HYPERLINK*
;;;!! Key fields are converted to uppercase
;;; Doc - a pointer to the PDF document, nil - the current

;;; Example
;;; (_dwgru-dwgprops-get-all-prop nil) ;;;(("* AUTHOR * "" VVA ") (" * COMMENTS * "" Memo ") (" * HYPERLINK * "" Base ")
                               ;;;("* KEYWORDS * "" Key ") (" * TITLE * "" named ") (" * SUBJECT * "" R ") (" UNIQKEY "" Key "))

(and
(or Doc
   (setq Doc (vla-get-activeDocument (vlax-get-acad-object)))
   )
(setq si (vla-get-SummaryInfo Doc))
(setq ret (list
    (list "*AUTHOR*" (vla-get-author si))
    (list "*COMMENTS*" (vla-get-comments si))
         (list "*HYPERLINK*" (vla-get-HyperlinkBase si))
    (list "*KEYWORDS*" (vla-get-keywords si))
         (list "*TITLE*" (vla-get-Title si))
    (list "*SUBJECT*" (vla-get-Subject si))
    )
)
(setq nc (vla-numcustominfo si))
(while (> nc 0)
(vla-GetCustomByIndex si (- nc 1) 'key 'value)
(setq ret (append ret (list(list (strcase key) value))))
(setq nc (1- nc))
)
(vlax-release-object si)
)
ret
)   
;;; *********************************************** *************************
;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group
;;; *
;;; * _dwgru-Dwgprops-get-custom-prop
;;; *
;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA)
;;; *********************************************** *************************


(defun _dwgru-dwgprops-get-custom-prop (key Doc / app counter counter2 counter3 doc dwgprops kv)
;;; Returns the value of the property created by the user (team _dwgprops)
;;; Returns an associative list, where the key is:
;; - For properties created by the user (tab OTHER)
;;; Key - a string property name (tab OTHER)
;; - For standard properties (tab PAPER)
;;; Key field
;;; NAME - *TITLE*
;;; AUTHOR - *AUTHOR*
;;; TOPIC - *SUBJECT*
;;; KEY WORDS - *KEYWORDS*
;;; NOTES - *COMMENTS*
;;; Hyperlink Base - *HYPERLINK*
;;;
;;; Uses the library
;;; _dwgru-Dwgprops-get-all-prop
;;; _dwgru-Assoc (_dwgru-assoc-multi)

;;; Doc - a pointer to the PDF document, nil - the current

(cadr (_dwgru-assoc key (_dwgru-dwgprops-get-all-prop Doc)))
)
;;; *********************************************** *************************
;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group
;;; *
;;; * _dwgru-Dwgprops-set-custom-prop
;;; *
;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA)
;;; *********************************************** *************************

(defun _dwgru-dwgprops-set-custom-prop (key value Doc / si)
;;, Create in the properties of the figure (team _dwgprops bookmark OTHER)
;;; Property with key and value value
;;; If the property was not, it is created, otherwise the changes
;;; Key - a string property name (tab OTHER)
;;; Value - a string (string) - value of property
;;; Uses the library
;;; _dwgru-Dwgprops-get-custom-prop
;;; Doc - a pointer to the PDF document, nil - the current
;;; Returns - nil
;;; Example
;;; (_dwgru-dwgprops-set-custom-prop "dwgru" "dwgru-dwgprops-set-custom-prop" nil)

(or Doc
(setq Doc (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
    )
(setq si (vla-Get-SummaryInfo Doc))
(if (_dwgru-dwgprops-get-custom-prop key Doc)
    (vla-SetCustomByKey si key value)
    (vla-AddCustomInfo si key value)
)
)



(defun _dwgru-assoc-multi (key lst)
(if (= (type key) 'str)
    (setq key (strcase key))
    ); _ End of if
(vl-remove-if-not
    (function
      (lambda (a / b)
      (and (setq b (car a))
             (or (and (= (type b) 'str) (= (strcase b) key)) (equal b key))
             ); _ End of and
      ); _ End of lambda
      ); _ End of function
    lst
    ); _ End of vl-remove-if-not
); _ End of defun
(defun _dwgru-assoc (key lst)
(car (_dwgru-assoc-multi key lst))
); _ End of defun
 
这是nasc_的道具。lsp
;;; *********************************************** *************************
;;; * NASC Field Properties*
;;; *
;;*Allows user to type in job info in command bar*
;;*for use with the FIELDS in the titleblock*
;;; *
;;*For North American Stone Company*
;;; *
;;; * 11/09/2009 Version 0001. Vladimir Azarko (VVA)
;;; *********************************************** *************************
(defun C:DWG ()
(vl-load-com) ;;; Do not forget to add
(setq str (getstring t "\nJob Number:"))
(_dwgru-dwgprops-set-custom-prop "Job Number" str nil)
(setq str (getstring "\nCustomer:"))
(_dwgru-dwgprops-set-custom-prop "Customer" str nil)
(setq str (getstring t "\nAddress:"))
(_dwgru-dwgprops-set-custom-prop "Address" str nil)
(setq str (getstring t "\nCity St:"))
(_dwgru-dwgprops-set-custom-prop "City St" str nil)
(setq str (getstring t "\nColor:"))
(_dwgru-dwgprops-set-custom-prop "Color" str nil)
(setq str (getstring t "\nDrawn By:"))
(_dwgru-dwgprops-set-custom-prop "Drawn By" str nil)
(setq str (getstring t "\nDelivery Date:"))
(_dwgru-dwgprops-set-custom-prop "Delivery Date" str nil)
(setq str (getstring t "\nDrawing Date:"))
(_dwgru-dwgprops-set-custom-prop "Drawing Date" str nil)
(setq str (getstring t "\nFinish:"))
(_dwgru-dwgprops-set-custom-prop "Finish" str nil)
)

eric_monceaux 发表于 2022-7-6 12:31:50

 
有没有更好的方法可以在打开或新建图形时自动调用Lisp?

tzframpton 发表于 2022-7-6 12:34:23

是的,只需加载LSP文件本身的路径,使用双反斜杠而不是单反斜杠来分隔目录层次结构。例如:
这是一个名为“fixblock.lsp”的Lisp文件,我们都在我的办公室使用。它位于联网的K驱动器上。只需像加载每个Lisp文件一样输入这段代码,然后每次打开或创建新图形时,它都会出现。

rkmcswain 发表于 2022-7-6 12:37:24

 
调用(运行),还是仅仅加载?

alanjt 发表于 2022-7-6 12:38:57

 
 
Tannar,您应该始终在所有加载函数的末尾添加nil或“Some Message”。如果在上面的代码中找不到该文件,它将出错并且不会继续(在您的情况下,您只有一件事,但仍然)。
 
例子:
Command: (load "asldkfj")

Error: LOAD failed: "asldkfj"
Command: (load "asldkfj" nil)
nil

Command: (load "asldkfj" "")
""

tzframpton 发表于 2022-7-6 12:42:46

是的,我肯定把我所有的东西都修好了,这是肯定的,哈哈。我会这么做,因为你说,但我不是程序员。当然,如果某个东西加载不正确,显然我知道该去哪里找到它。。。。不过谢谢你的提示。总是受到像你这样的专业人士的赞赏。
页: [1] 2
查看完整版本: 定制acaddoc。lsp