// Sean's Dial Ticks // Written By Sean Moyer // // // This plugin cannot be redistributed for commercial gain // // www.geocities.com/Area51/Cavern/2468 // www.tiac.net/users/seanmyr // Updated for LW7.5 by Gary Hartenstein - June 2002 @warnings @script modeler main { limb = 3; spoon[1] = " X "; spoon[2] = " Y "; spoon[3] = " Z "; chooser = 1; choose[1] = " Outside "; choose[2] = " Inside "; choose[3] = " None "; inst = 2; instruct[1] = " Yes "; instruct[2] = " No "; method = 1; methopt[1] = "Use a Font"; methopt[2] = "Use Centered Object"; lowrange = 1; countby = 1; tickstep = 12; clockwise = 1; clockopt[1] = " CW "; clockopt[2] = " CCW "; leadzero = 0; trailzero = 0; irshow = 1; iropt[1] = " Yes "; iropt[2] = " No "; itshow = 1; itopt[1] = " Yes "; itopt[2] = " No "; orshow = 1; oropt[1] = " Yes "; oropt[2] = " No "; otshow = 1; otopt[1] = " Yes "; otopt[2] = " No "; subticks = 5; inrad = 1.0; outrad = 1.1; tickrad = 1.2; offSet = 0; offwise = 1; offopt[1] = " CW "; offopt[2] = " CCW "; rotval = 0.0; radiuz = 2.0; ticks = 10; raxis = "X"; fonthi = .2; selmode(USER); //_____________________________________________________________________Get User Info reqbegin("Sean's Dial Ticks"); ctltext(" "," "); e1 = ctlchoice("Method",method,methopt,1); ctltext(" "," "); e2 = ctlinteger("Start At",lowrange); e3 = ctlinteger("Count By",countby); e6 = ctlinteger("# of Ticks",tickstep); e7 = ctlchoice("Direction",clockwise,clockopt); e4 = ctlinteger("Zero Padding",leadzero); e5 = ctlchoice("Justify",chooser,choose,1); ctltext(" "," "); ctltext("","____________________________"); e10 = ctlchoice(" Help me, Obi Wan!",inst,instruct); ctltext(" "," "); if(reqpost()) { method = getvalue(e1); lowrange = getvalue(e2); countby = getvalue(e3); leadzero = getvalue(e4); chooser = getvalue(e5); tickstep = getvalue(e6); clockwise = getvalue(e7); inst = getvalue(e10); } else return; reqend(); //___________________________________________________________________Instructions if(inst == 1) { info ("Just before he died Obi said, 'The instructions are as follows.........'"); return(0); } else { //----------------------------------------------------------------------- Error Checking and Handling if (method == 1 && fontcount() == 0) { error ("You chose to use a font, but you have no fonts loaded in Modeler."); return(0); } if (method == 2 && !pointcount()) { error ("You chose to use an object, but the layer is empty."); return(0); } reqbegin("Sean's Dial Ticks"); ctltext(" "," "); e8 = ctlinteger(" Offset First Number",offSet); e9 = ctlchoice("Direction",offwise,offopt); ctltext(" "," "); c1 = ctlchoice("Axis",limb,spoon); c2 = ctldistance("Radius",radiuz); ctltext(" "," "); if(reqpost()) { limb = getvalue(c1); radiuz = getvalue(c2); offset = getvalue(e8); offwise = getvalue(e9); } else return; reqend(); //____________________________________________Calculate Best Guess Ring Radii based on Justification if(chooser != 2) { inrad = (radiuz * .91); outrad = (radiuz * .94); tickrad = (radiuz * .97); } else { inrad = (radiuz * 1.09); outrad = (radiuz * 1.06); tickrad = (radiuz * 1.03); } reqbegin("Sean's Dial Ticks"); ctltext(" "," "); c2 = ctlinteger("# of Subticks",subticks); r3 = ctlchoice("Show Ring One",orshow,oropt); r1 = ctlchoice("Show Ring Two",irshow,iropt); r4 = ctlchoice("Show Major Ticks",otshow,otopt); r2 = ctlchoice("Show Minor Ticks",itshow,itopt); ctltext(" "," "); c4 = ctlnumber("Ring One Radius",outrad); c3 = ctlnumber("Ring Two Radius",inrad); c5 = ctlnumber("Tick Mark Radius",tickrad); if(reqpost()) { subticks = getvalue(c2); inrad = getvalue(c3); outrad = getvalue(c4); tickrad = getvalue(c5); irshow = getvalue(r1); itshow = getvalue(r2); orshow = getvalue(r3); otshow = getvalue(r4); } else return; reqend(); //_________________________________________________________Calculate Best Guess FontSize //_________________________________________________________Based on radius, & number magnitude fonthi = (radiuz * .1); if((countby*tickstep) >= 100 || (leadzero >= 3)) { if((countby*tickstep) >= 1000 || (leadzero >= 4)) { fonthi = (fonthi * .25); } else { fonthi = (fonthi * .5); } } /******************************************************************************************************** Using getfile() to load fonts was removed from the code below. Didn't work. Now the user must add fonts using Modelers "Edit Font List" option beforehand. The fonts they have loaded are the fonts they are presented with in a popup menu. Error checking for zero fonts loaded is handled above. Update June 2002. GH */ if(method == 1) { reqbegin("Sean's Dial Ticks"); reqsize(300,150); c1 = ctltext("","Choose Font For Dial",""); ctlposition(c1,90,5); for (i = 1; i <= fontcount(); i++) //Get the list of fonts loaded in Modeler. fontlist += fontname(i); f1 = ctlpopup("Choose a Font", 1, fontlist); //Load that list into a popup. ctlposition(f1,10,50); f2 = ctldistance("Font Height",fonthi); ctlposition(f2,10,90); if(reqpost()) { findex = getvalue(f1); // Get the font the user chose from the popup. fonthi = getvalue(f2); // Get the font height. } else return; reqend(); } //___________________________________________________________________Getting Closer if(limb == 1) raxis = "X"; if(limb == 2) raxis = "Y"; if(limb == 3) raxis = "Z"; cent = center(boundingbox()); //_________Layer Management__________________________ hot = lyrfg(); allempty = lyrempty(); if(size(allempty) < 3) { info("Plugin needs at least 2 empty layers to work."); return; } //__________The Meat___________________________________ setsurface("SDT-Font"); for(i = 0;i < tickstep;++i) { // maketext("0123456789",findex,SHARP,0,1.25,raxis);-------------Scaled to Approx 1 m (1.25) switch (method) { case 1 : lyrsetfg(allempty[1]); tempstrn = string(lowrange); while(size(tempstrn) < leadzero) { tempstrn = string("0",tempstrn); } texsize = (1.25 * fonthi); maketext(tempstrn,findex,SHARP,0,texsize,raxis); //_________CENTER TEXT_______________________ cent = center(boundingbox()); centstng = string(cent); centarray = parse(" ",centstng); numarray[1] = - number(centarray[1]); numarray[2] = - number(centarray[2]); numarray[3] = - number(centarray[3]); move(numarray[1],numarray[2],numarray[3]); lowrange = lowrange + countby; break; case 2 : lyrsetfg(hot); copy(); lyrsetfg(allempty[1]); paste(); break; default: break; } currentrot = -((360/tickstep)*i); if(raxis == "Z") currentrot = -currentrot; if(clockwise == 2) currentrot = (-currentrot); offsetter = -offset; if(raxis == "Z") offsetter = -offsetter; if(offwise == 2) offsetter = (-offset); currentoff = ((360/tickstep)*offsetter); currentrot = (currentrot + currentoff); //____Correctional Rotaion______________________ rotate(-currentrot,raxis,0); //________________________________________________________________________JUSTIFY if(chooser != 3) { (low,hi) = boundingbox(); if (low == nil || hi == nil) // Some elaborate fonts just don't work in Modeler. { error ("That font is troublesome. Please try another."); return(0); } if(chooser == 1) { zlow = -low.z; ylow = -low.y; } else { zlow = -hi.z; ylow = -hi.y; } if(limb == 2) move(0,0,zlow); else move(0,ylow,0); } //____Placement_________________________________ if(raxis == "Y") move(0,0,radiuz); else move(0,radiuz,0); rotate(currentrot,raxis,0); //____Cut & Paste________________________________ cut(); lyrsetfg(allempty[2]); paste(); changesurface("SDT-Font"); } } //_______________________________________________________________________Make The Ring //________________________________________________Make the Points if(makering != 1) { ++subticks; if(subticks <= 0) subticks = 1; lyrsetfg(allempty[1]); newstep = (tickstep * subticks); currentrot = ((360/newstep)); for(j = 1;j <= newstep;++j) { if(raxis == "Y") { origin[1] = 0.0; origin[2] = 0.0; origin[3] = outrad; inorigin[1] = 0.0; inorigin[2] = 0.0; inorigin[3] = inrad; outorigin[1] = 0.0; outorigin[2] = 0.0; outorigin[3] = tickrad; } else { origin[1] = 0.0; origin[2] = outrad; origin[3] = 0.0; inorigin[1] = 0.0; inorigin[2] = inrad; inorigin[3] = 0.0; outorigin[1] = 0.0; outorigin[2] = tickrad; outorigin[3] = 0.0; } editbegin(); idmatrix[j] = addpoint(origin); outermatrix[j] = addpoint(outorigin); innermatrix[j] = addpoint(inorigin); editend(); rotate(currentrot,raxis,0); } //____________________________________________________Connect The Dots setsurface("SDT-Ring"); for(k = 1;k <= newstep;++k) { tempcount = k+1; if(tempcount > newstep) tempcount = 1; editbegin(); //________________________________________Make Outer Ring if(orshow == 1) { ringtrix[1] = idmatrix[k]; ringtrix[2] = idmatrix[tempcount]; addpolygon(ringtrix); } //_________________________________________Make Major Ticks if((k/subticks) == integer(k/subticks)) { if(otshow == 1) { ringtrix[1] = idmatrix[k]; ringtrix[2] = outermatrix[k]; addpolygon(ringtrix); } } //_________________________________________Make Minor Ticks--Connect Rings if(irshow == 1) { intrix[1] = innermatrix[k]; intrix[2] = innermatrix[tempcount]; addpolygon(intrix); } if(itshow == 1) { intrix[1] = innermatrix[k]; intrix[2] = idmatrix[k]; addpolygon(intrix); } editend(); } rotate(-currentrot,raxis,0); selpoint(SET,NPEQ,0); cut(); } //____Cut & Paste________________________________ cut(); lyrsetfg(allempty[2]); paste(); }