本帖最后由 dcl1214 于 2024-4-15 10:28 编辑
全局变量慎用
- (SETQ *ACAD* (vlax-get-acad-object)
- *DOC* (vla-get-ActiveDocument *ACAD*)
- *MS* (vla-get-modelSpace *DOC*)
- *PS* (vla-get-paperSpace *DOC*)
- )
- ;改成以下写法:
- (SETQ ACAD (vlax-get-acad-object))
- (SETQ DOC (vla-get-ActiveDocument (vlax-get-acad-object)))
- (SETQ MS (vla-get-modelSpace
- (vla-get-ActiveDocument (vlax-get-acad-object))
- )
- )
- (SETQ PS (vla-get-paperSpace
- (vla-get-modelSpace
- (vla-get-ActiveDocument (vlax-get-acad-object))
- )
- )
- )
- ;如果以上全局变量被很多地方引用,建议在每一个defun函数内部单独输入,且添加到 / 后面做成局部变量,编译后,cad可能会改成流水码,连cad自己的函数都可能变成流水码
|