最近開始用Macro,就去翻以前的信件,看到網友的這個問題,於是想著想著就把code寫出來。不過我不太好意思跟那網友說,欸,可以這樣作囉。
畢竟都是那麼久了,五年前是研究生,如果現在還需要這個功能的話,那......。
老樣子,底下影片是操作方式,最底下有code,複製貼上就可以。
macro "DrawVertical" {
requires("1.37rk");
if(selectionType!=5) showMessage("Selection Must be staight Line");
Dialog.create("Setting");
Dialog.addNumber("line Width:", 10);
Dialog.addChoice("Base Line Color:", newArray("cyan", "red", "green", "magenta", "blue", "yellow", "orange", "black", "white"),"yellow");
Dialog.addChoice("Vertical Line Color:", newArray("cyan", "red", "green", "magenta", "blue", "yellow", "orange", "black", "white"),"red");
Dialog.show();
LineWid=Dialog.getNumber();
Bcolor = Dialog.getChoice();
Vcolor = Dialog.getChoice();
getPixelSize(scale, pixelSize, trash);
getSelectionCoordinates(x, y);
setColor(Bcolor);
setLineWidth(LineWid);
drawLine(x[0], y[0], x[1], y[1]);
leftButton=16;
x2=-1;
y2=-1;
z2=-1;
flags2=-1;
logOpened = false;
print("start");
while (!logOpened || isOpen("Log")) {
getCursorLoc(seleX, seleY, z, flags);
if (flags!=flags2) {
s = " ";
if (flags&leftButton!=0) {
s = "<left>";
m1=(y[1]-y[0])/(x[1]-x[0]);
m2=-1/m1;
interX=(m2*seleX-m1*x[1]+y[1]-seleY)/(m2-m1);
interY=m2*(interX-seleX)+seleY;
setColor(Vcolor);
setLineWidth(LineWid);
moveTo(seleX,seleY);
lineTo(interX,interY);
lineLeng=pow((pow((interX-seleX),2)+pow((interY-seleY),2)),1/2);
lineLeng=lineLeng*pixelSize;
print("Length:","\t", lineLeng,"\t",scale);
logOpened = true;
startTime = getTime();
}
}
x2=x;
y2=y;
z2=z;
flags2=flags;
wait(10);
}
}