More scripts: C A D
Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# text.sml
# demonstrate creating and reading a text CAD element
clear();
string format$ = "%7d %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f \n";
# create a new file or open existing file
cad C;
GetOutputCAD(C);
# write some text
numeric baseX1 = 100, baseY1 = 100, baseX2 = 200, baseY2 = 100, height = 100;
numeric rotation = 0, xScale = 1.0, shear = 0;
# since rotation = 0 we will use both basepoints
string text$ = "CAD text string 1";
CADWriteText(C, 1, text$, baseX1, baseY1, baseX2, baseY2, height, rotation, xScale, shear);
# the elements are always appended to end of block
# so get number of elements - last element will be our text
numeric lastelem = CADNumElements(C, 1);
# now read data for most recently added element
text$ = CADReadText(C, 1, lastelem, baseX1, baseY1, baseX2, baseY2, height, rotation, xScale, shear);
print("write and read CAD text");
print("element baseX1 baseY1 baseX2 baseY2 height ", "rotation xScale shear");
printf(format$, lastelem, baseX1, baseY1, baseX2, baseY2, height, rotation, xScale, shear);
print("Text: ", text$);
# now use rotation and one base point
baseX1 = 100;
baseY1 = 500;
baseX2 = 0; # don't care
baseY2 = 0; # don't care
height = 100;
rotation = 45;
xScale = 1.0;
shear = -40; # angle text backwards
text$ = "CAD text string 2 - rotated and sheared";
CADWriteText(C, 1, text$, baseX1, baseY1, baseX2, baseY2, height, rotation, xScale, shear);
lastelem = CADNumElements(C, 1);
# now read data for most recently added element
text$ = CADReadText(C, 1, lastelem, baseX1, baseY1, baseX2, baseY2, height, rotation, xScale, shear);
printf(format$, lastelem, baseX1, baseY1, baseX2, baseY2, height, rotation, xScale, shear);
print("Text: ", text$);
CloseCAD(C);