乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: lfe011969

[编程交流] vlr-dwg-reactor or vlr-docmana

[复制链接]

17

主题

127

帖子

110

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 10:41:02 | 显示全部楼层
Ok so nothing I do works
 
I added this to my acaddoc.lsp:
  1. (if (and c:load_dwg_props (= *TEST* "YES")) (c:load_dwg_props))
 
 
I also added these two lines to the new_project.lsp right before the command is invoked to open the selected template:
  1. (setq *TEST* "YES")(vl-propagate '*TEST)
 
 
Finally at the end of the load_dwg_props.lsp, I reset the *TEST* variable to nil:
  1. (setq *TEST* nil)(vl-propagate '*TEST)
 
 
So after the new template is loaded, the load_dwg_props.lsp doesn't execute. However when I type:
  1. Command: load_dwg_props
 
at the command line, the routine runs. I tested for the value of my test variable both before and after running the load_dwg_props.lsp and the values are as they should be: "YES" before running the lisp and "nil" after.
 
Now my head hurts
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:43:37 | 显示全部楼层
I wouldn't use the Global, as the namespace is wiped when the drawing is closed and the global won't appear in the new drawing namespace (I know you have used vl-propagate, but this won't work as the drawing is opened when it is executed).
 
Perhaps using setenv/getenv to store the value in the registry under:
 
  1. (strcat "HKEY_CURRENT_USER\" (vlax-product-key) "\\FixedProfile\\General")
 
I would rely on the Globals keeping their value between drawings with so many codes running at different times.
回复

使用道具 举报

17

主题

127

帖子

110

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 10:45:45 | 显示全部楼层
Thanks Lee.  I will try out your suggestion later tonight and let you know tomorrow.
回复

使用道具 举报

17

主题

127

帖子

110

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 10:49:26 | 显示全部楼层
Thanks Lee, your suggestion to use a registry key as the test works the way I want.  I added this to my acaddoc.lsp:
 
  1. (setq reg_key (strcat "HKEY_CURRENT_USER\" (vlax-product-key) \\Fixed Profile\\General"))(setq read_reg_key (vl-registry-read reg_key "TEST"))(if (= read_reg_key "YES")   (c:load_dwg_props))
 
 
Then in my new_project.lsp, right before the command to open the template, I added:
  1. (vl-registry-write reg_key "TEST" "YES")
 
 
Finally, in the load_dwg_props.lsp I added this line to the top of the code:
  1. (vl-registry-write reg_key "TEST" "NO")
 
 
I've tested this over and over and it works now but I'm sure there will be some situation or configuration where this code might not work.  Is there anything you would suggest to improve this code?
 
Thanks again.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:53:53 | 显示全部楼层
Glad it works Lonnie!
 
There may have been some confusion over my earlier post, you could replace:
 
  1. (setq reg_key (strcat "HKEY_CURRENT_USER\" (vlax-product-key) \\Fixed Profile\\General"))(setq read_reg_key (vl-registry-read reg_key "TEST"))
With just:
 
  1. (getenv "TEST")
Similarly:
 
  1. (vl-registry-write reg_key "TEST" "YES")
With:
 
  1. (setenv "TEST" "YES")
In my earlier post, I was noting that these functions (getenv/setenv) will read/write the key to this location:
 
  1. (strcat "HKEY_CURRENT_USER\" (vlax-product-key) \\Fixed Profile\\General")
Apologies for the confusion - of course, both solutions would function identically.
 
I would suggest that you use a little more unique registry key (instead of "TEST"), such as "IFE_Test" or something that would be less likely to already appear in the registry - since, there is the slight chance that existing entries could be overwritten.
 
Other than that, good job!
 
Lee
回复

使用道具 举报

17

主题

127

帖子

110

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 10:58:33 | 显示全部楼层
Ahhh...."I see," said the code-blind man....
 
I had read about reading and writing to the registry through vlisp but I don't remember seeing anything about getenv / setenv.  So thanks for the tip.   I've found the hardest thing for me is not knowing what all the available options are to code any one thing so I find myself stuck in one or two mindsets on trying to accomplish what I'm thinking.  I'm glad we have forums to educate me such as this one, The Swamp, the Autodesk forums and the AUGI....oops.....LOL
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:00:12 | 显示全部楼层
Now you have a few more tools in your toolbox
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-6 23:58 , Processed in 0.320343 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表