Jump to content

Help? Block Insertion Macro with scale / attribute manipulation...


Chris Thoms

Recommended Posts

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).

Link to comment
Share on other sites

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)";;

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...