Register
 
DoubleCAD XT v5 has released

(PRO only) A Little Script for Pro
Read 2165 times
May 12, 2009, 12:57:18 PM
Here is a little script tah creates an object that is similat to a Datum dimension - except this object gives the coordiante difference between two user defined points instead of between one user point and the origin.

You can control the location of the point with the Edit tool.

Enjoy, and feel free to modify it as needed.



Input(P0, P1, P2,size, arra);
P0 = ParameterPoint(0, 0, 0, 0);
P1 = ParameterPoint(1, 5, 5, 0);
R2 = ParameterPoint(2, 8, 8, 0);
size = Parameter("size", 1, LINEAR);
arra = Parameter("arrow angle", 45, ANGULAR);

x0 = PointX(P0); y0 = PointY(P0);
x1 = PointX(P1); y1 = PointY(P1); z1 = PointZ(P1);
x2 = PointX(R2); y2 = PointY(R2); z2 = PointZ(R2);
angle = atan(y1-y0, x1-x0);

px = size*sin(arra/2);
py = size*cos(arra/2);

Xvalue = x2-x1
Yvalue = y2-y1

Fnt = TextFont(0,1,0,"Arial");
Fsty = TextStyle(CENTER, MIDDLE);
Note = Text("X="+Xvalue+", Y="+Yvalue, Fnt, Fsty);



dy_note = ExtentsY1(Note);
dx_note = ExtentsX1(Note);

A = IF(x1>x0,-dx_note, dx_note);
B = IF(y1>y0,-dy_note, dy_note);

Note2 = Move(Note, -A, -B);
Note3 = Move(Note2, x0, y0);

VR = Polyline(Point(x2+1,y2),Point(x2-1,y2));
HR = Polyline(Point(x2,y2+1),Point(x2,y2-1));


T0 = Polyline(
Point(-px, 0),
Point(0, py),
Point(px, 0),
Point(-px, 0)
);
CR = Circle(0.5,x2,y2);


T1 = RotateZ(T0, angle-90, 0, py);
T2 = Move(T1, x1, y1-py);
T3 = SetProperties(T2, "BrushStyle" = "SOLID");

line = Polyline(P0, P1);

Output(T3, line, VR,HR, Note3, CR);
« Last Edit: May 12, 2009, 02:41:51 PM by thebrian »

Logged


May 12, 2009, 02:14:18 PM
#1
I added a modification that tracks Z as well as X, and Y and the ability to set the color of the reference marks.


CirCol = Parameter("Circle Color",(0x0000FF), COLOR);
CrossCol = Parameter("Cross Color",(0xFF0000), COLOR);
P0 = ParameterPoint(0, 0,0,0);
P1 = ParameterPoint(1, 5, 5, 0);
R2 = ParameterPoint(2, 8, 8, 0);
size = Parameter("size", 1, LINEAR);
arra = Parameter("arrow angle", 45, ANGULAR);

x0 = PointX(P0); y0 = PointY(P0);
x1 = PointX(P1); y1 = PointY(P1); z1 = PointZ(P1);
x2 = PointX(R2); y2 = PointY(R2); z2 = PointZ(R2);
angle = atan(y1-y0, x1-x0);

px = size*sin(arra/2);
py = size*cos(arra/2);

Xvalue = x1-x2
Yvalue = y1-y2
Zvalue = z2-z1

Fnt = TextFont(0,1,0,"Verdana");
Fsty = TextStyle(CENTER, MIDDLE);
Note = Text("X="+Xvalue+", Y="+Yvalue+", Z="+Zvalue, Fnt, Fsty);

dy_note = ExtentsY1(Note);
dx_note = ExtentsX1(Note);

A = IF(x1>x0,-dx_note, dx_note);
B = IF(y1>y0,-dy_note, dy_note);

Note2 = Move(Note, -A, -B);
Note3 = Move(Note2, x0, y0);

VR = Polyline(Point(x2+1,y2),Point(x2-1,y2));
HR = Polyline(Point(x2,y2+1),Point(x2,y2-1));
VR2 = Move(VR,0,0,z2);
HR2 = Move(HR,0,0,z2);
VR3 = SetProperties(VR2, "PenColor" = CrossCol);
HR3 = SetProperties(HR2, "PenColor" = CrossCol);

CR = Circle(0.5,x2,y2,z2);
CR2 = Move(CR,0,0,z2);
CR3 = SetProperties(CR2, "PenColor" = CirCol);

FVR = Polyline(Point(x1+1,y1),Point(x1-1,y1));
FHR = Polyline(Point(x1,y1+1),Point(x1,y1-1));
FVR2 = Move(FVR,0,0,z1);
FHR2 = Move(FHR,0,0,z1);
FVR3 = SetProperties(FVR2, "PenColor" = CrossCol);
FHR3 = SetProperties(FHR2, "PenColor" = CrossCol);


FCR = Circle(0.5,x1,y1);
FCR2 = Move(FCR,0,0,z1);
FCR3 = SetProperties(FCR2, "PenColor" = CirCol);

line = Polyline(P0, P1);

Output(line, VR3, HR3, FVR3, FHR3, Note3, CR3, FCR3);
« Last Edit: May 12, 2009, 02:24:54 PM by thebrian »

Logged