Chris Thoms Posted July 22, 2014 Share Posted July 22, 2014 Long time lurker, first time poster. I've been working on this macro a bit lately off and on, and I just can't seem to get it right. I've run into some difficulty in the way the DIESEL interpreter recalls variables and have been trying to use nesting to make my code work. ^C^C^C_setvar;userr1;$m=$(if,$(=,$(getvar,cvport),1),1/96,1); _setvar;userr2;$(if,$(=,$(getvar,cvport),1),0.125,$(*,0.125,$(getvar,dimscale))); -INSERT;2x2_r_n;\"$m=$(getvar,userr1)";;\\ -attedit;;;;;L;A;0;H;""$m=$(getvar,userr2)"";; The first line cancels then sets the variable userr1 to be 1/96 in paperspace and 1 in model space. The second line sets the variable userr2 to be 0.125 in paperspace and dimscale*0.125 in drawing space. The third line inserts my block (a 2'x2' recessed normal power light, drawn to scale with a descriptor attribute) and then scales it to the value defined by userr1. The last line edits the attribute the inserted block to have an angle of 0 and to have a height as defined by the variable userr2. What I've learned in working with this is that DIESEL does not evaluate the way I would like... I have nested the final variable calls (userr1 once; userr2 twice), with the intent of passing the new values to them prior to their evaluation, but it isn't working quite right and I'm becoming a bit frustrated. Currently, when I use the macro it works correctly on the second call if I have not changed the cvport or the dimscale between uses. I think this tells me that, despite my attempts at nesting, the variables are still not being updated properly by the conditional statements prior to block insertion and attribute editing. I would greatly appreciate any assistance in both getting this to function properly and in better understanding DIESEL evaluation logic (I've found good material here {http://www.crlf.de/Dokumente/Diesel/Diesel1.html}, but I still have gaps in my understanding, apparently). Quote Link to comment Share on other sites More sharing options...
Chris Thoms Posted July 28, 2014 Author Share Posted July 28, 2014 Well, I figured it out on my own. The working code is below: ^C^C^C_setvar;userr1;$m=$(if,$(=,$(getvar,cvport),1),1/96,1); _setvar;userr2;$(if,$(=,$(getvar,cvport),1),0.125,$(*,0.125,$(getvar,dimscale))); -INSERT;2x2_r_n;\"$m=$(getvar,userr1)";;\\ -attedit;;;;;L;A;0;H;"$m=$(getvar,userr2)";; Quote Link to comment Share on other sites More sharing options...
YZ Posted July 31, 2014 Share Posted July 31, 2014 Great work Chris! What an excellent macro. Took me a long time to find what was different between the 2! I take my hat off to you for solving this. I have never been able to define and return a user variable inside the one macro. It seemed to me that it would not the records until after the macro had finished, renderring the getvar useless. I even tried setvar, then put call a script for the getvar but to no avail. But you seem to have it working well somehow. I'm going to check it out again. Thanks also for the Diesel link. Quote Link to comment Share on other sites More sharing options...
Chris Thoms Posted July 31, 2014 Author Share Posted July 31, 2014 I'm glad that my solution is helpful to someone else. It was aggravating to solve. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.