I added this to my acaddoc.lsp:
(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:
(setq *TEST* "YES")(vl-propagate '*TEST)
Finally at the end of the load_dwg_props.lsp, I reset the *TEST* variable to nil:
(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:
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 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:
(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. Thanks Lee.I will try out your suggestion later tonight and let you know tomorrow. Thanks Lee, your suggestion to use a registry key as the test works the way I want.I added this to my acaddoc.lsp:
(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:
(vl-registry-write reg_key "TEST" "YES")
Finally, in the load_dwg_props.lsp I added this line to the top of the code:
(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. Glad it works Lonnie!
There may have been some confusion over my earlier post, you could replace:
(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:
(getenv "TEST")Similarly:
(vl-registry-write reg_key "TEST" "YES")With:
(setenv "TEST" "YES")In my earlier post, I was noting that these functions (getenv/setenv) will read/write the key to this location:
(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 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 Now you have a few more tools in your toolbox
页:
1
[2]