Sunday, August 10, 2008

A Fancy Line Command Using DIESEL

This is just meant for fun. Infact, there is nothing much fancy inside the command as the title indicates. All that does is drawing continuous line segments with diffrent colours. Let's have a look at the macro.

*^c^c$M=$(if,$(eq,$(getvar,modemacro),""),_id;\setvar;modemacro;Fancy Line Command - reset the sysvars USERI1 and MODEMACRO before next use;)$(if,$(and,$(<,$(getvar,useri1),255),$(!=,$(getvar,useri1),0)),setvar;useri1;$(+,$(getvar,useri1),1);_-color;$(getvar,useri1);_Line;$(getvar,lastpoint);\,setvar;useri1;1)


The program flow is as described below.

  • First check whether the modemacro system variable is empty - $(eq,$(getvar,modemacro),"").

  • If it's empty then prompt for a starting point for the line and set the mode macro system variable - _id;\setvar;modemacro;Fancy Line Command - reset the sysvars USERI1 and MODEMACRO before next use;

  • If it is not empty, then the first point has already been selected, now we have to check for the ACI color index limits stored inside the useri1 system variable - $(and,$(<,$(getvar,useri1),255),$(!=,$(getvar,useri1),0))
  • If everything is ok, then increment the color index value by 1, set the color value and draw a line with that color - setvar;useri1;$(+,$(getvar,useri1),1);_-color;$(getvar,useri1);_Line;$(getvar,lastpoint);\

  • If the color index is not within the ACI limits, then skip the previous step and set the color index value inside useri1 to 1 (Red color) - setvar;useri1;1

  • Continue the above steps until the user press escape button - *^c^c
You will have to reset the system variables before using the command next time (Though, I don't see anybody using it for the second time ;-) . Here goes the reset macro.

^c^c_setvar;modemacro;.;;useri1;0

Shown below is an output image of the command.




No comments: