FileOptions = 'НастройкиFasadExpert.xml';
MakeProperties();
Action.Properties.Load(FileOptions);
system.log(failMacrosa.Value)
if (system.fileExists(failMacrosa.Value)) {
readParametry()
}
Action.OnFinish = function() {
Action.Properties.Save(FileOptions);
}
BtnMake = NewButtonInput('Закончить');
BtnMake.OnChange = function() {
Make(); //Вызываем функцию построения всех панелей
Action.Finish();
}
//Make();
Action.OnStart = function() {
Prop.OnChange = Make;
Make();
}
Action.Continue();
true;
function Make() {
}
function MakeProperties() {
Prop = Action.Properties;
//Prop.
Image = Prop.NewImage('Схема изделия', 'Прямоугольный.jpg');
Image.MaxHeight = 700;
H = Prop.NewNumber('Высота Фасада', 768)
W = Prop.NewNumber('Ширина Фасада', 398)
failMacrosa = Prop.NewSelector('Файл Макроса Fasad expert');
Par = Prop.NewGroup('Параметры')
Calc = Prop.NewGroup('Расчёты')
failMacrosa.OnClick = function() {
failMacrosa.Value = system.askFileName('fes');
if (system.fileExists(failMacrosa.Value)) {
readParametry()
}
};
TipContura = Prop.NewCombo('Тип контура', 'Прямоугольный\nАрка\nЭлипс\nАнтик\n6-ти Угольник');
FrezaSkrugl = Prop.NewSelector('Фреза Скругление');
FrezaSkrugl.OnClick = function() {
FrezaSkrugl.Value = system.askFileName('frw');
};
FrezaFigurnaya = Prop.NewSelector('Фреза Фигурная');
FrezaFigurnaya.OnClick = function() {
FrezaFigurnaya.Value = system.askFileName('frw');
};
Calc.Expanded = false
}
function readParametry()
{
DeleteNewObjects();
tm = system.readTextFile(failMacrosa.Value)
//alert(tm)
var arr = tm.split('\n');
// header = arr.indexOf(searchElement, [fromIndex])
i = 0
ar2 = []
s = ''
while (arr[i]) {
if ((arr[i].length > 1) && (arr[i].indexOf('//') < 0)) {
// system.log(arr[i] + ' -- ' + arr[i].length + ' -- ' + arr[i].indexOf('//'))
ar2.push(arr[i].replace('\r', ''))
s = s + arr[i] + '\n'
//i--
}
i++
}
//alert(ar2.length)
head = ar2.indexOf('[Header]')
init = ar2.indexOf('[Init]')
calc = ar2.indexOf('[Calculations]')
tpath = ar2.indexOf('[ToolPath]')
vdem = 'FS_VertDimension'
hdem = 'FS_HorDimension'
rdem = 'FS_RadialDimension'
for (i = tpath; i < ar2.length; i++) {
if ((ar2[i].indexOf(vdem) == 0) || (ar2[i].indexOf(hdem) == 0) || (ar2[i].indexOf(rdem) == 0)) {
dem = i
break;
}
}
//alert(dem+'\n'+s)
doppar = []
for (i = head + 1; i < init; i++) {
doppar.push(ar2[i])
}
par = []
for (i = init + 1; i < calc; i++) {
par.push(ar2[i])
}
vych = []
for (i = calc + 1; i < tpath; i++) {
vych.push(ar2[i])
}
ris = []
for (i = tpath + 1; i < dem; i++) {
ris.push(ar2[i])
}
razm = []
for (i = dem + 1; i < ar2.length; i++) {
razm.push(ar2[i])
}
zapolnitParametry()
}
function zapolnitParametry() {
Par.Clear()
for (i = 0; i < doppar.length; i++) {
eval(doppar[i])
}
for (i = 0; i < par.length; i++) {
ps = par[i].split(',')
n = ps[0].split('(')[1]
tzn = ps[2].split(')')[0]
zn = parseInt(tzn)
if (isNaN(zn)) {
zn = parseInt(eval(tzn))
}
strev = "parr" + n.toString() + " = Par.NewNumber(ps[1],zn)"
eval(strev)
}
arPer = []
for (i = 0; i < vych.length; i++) {
system.log('')
system.log(vych[i])
system.log('Переводим на язык Базис скрипта:')
vs = vych[i].split('=')
Per = vs[0]
rasch = vs[1].toString()
var re = /FS_GetHeight\(\)/gi;
rasch = rasch.replace(re, "H.Value")
var re = /FS_GetWidth\(\)/gi;
rasch = rasch.replace(re, 'W.Value')
//////////////////////////////////////////////
poisk = 'FS_GetEditValue('
if (rasch.indexOf(poisk) > -1) {
retip = rasch.split(poisk)
r2 = []
r2.push(retip[0])
/////////////////// ------------
//retip = vsevhojdeniya( rasch,poisk)
for (ir = 1; ir < retip.length; ir++) {
podstr = retip[ir]
// system.log(podstr podstr )
//i1 = retip[ir]+ poisk.length
i1 = podstr.indexOf(')')
if ((i1 == 1) || (i1 == 2)) {
n = podstr.substring(0, i1)
podstr = "parr" + n + '.Value' + podstr.substring(i1 + 1, podstr.length)
}
r2.push(podstr)
}
//////////////--------------
rasch = ''
for (ir = 0; ir < r2.length; ir++) {
rasch = rasch + r2[ir]
}
}
/////////////////////////////////////// FS_Fillet2Lines_1(
rasch = Scrugl(rasch)
/////////// СЧИТАЕМ
arPerRazd = Per.toString().split('.') //делим переменную точкой
if (arPerRazd.length > 1) { // если поделилась
if (arPer.indexOf(arPerRazd[0]) == -1) {
arPer.push(arPerRazd[0])
estrP = arPerRazd[0] + ' = NewPoint(0,0)'
eval(estrP)
system.log(estrP + ' ')
}
if (arPerRazd[1] == 'X') {
arPerRazd[1] = 'x'
Per = arPerRazd[0] + '.' + arPerRazd[1]
// system.log(arPerRazd[1])
} else if (arPerRazd[1] == 'Y') {
arPerRazd[1] = 'y'
Per = arPerRazd[0] + '.' + arPerRazd[1]
// system.log(arPerRazd[1])
} else if (arPerRazd[1] == 'Z') {
//arPerRazd[1]='y'
Per = "Z"
// system.log(arPerRazd[1])
}
}
estr = '' + Per + '=' + rasch
system.log(estr)
eval(estr)
// nprop++
strev = "calcc" + n.toString() + " = Calc.NewString(estr)"
eval(strev)
}
cRis = NewContour()
for (i = 0; i < ris.length; i++) {
str = ris[i].toString()
system.log('')
system.log(str)
system.log('Переводим РИСУНОК на язык Базис скрипта:')
poisk = 'FS_MoveToPoint('
poisk2 = 'FS_LineToPoint('
poisk3 = 'FS_ArcToPoint('
poisk4 = 'FS_Arc3PointToPoint('
if (str.indexOf(poisk) == 0) {
str = 'p1 = ' + str.substring(poisk.length, str.length - 2)
} else if (str.indexOf(poisk2) == 0) {
str = 'p2 = ' + str.substring(poisk2.length, str.length - 2) + '; \n' +
'cRis.AddLine(p1,p2); \n' +
'p1 = p2; \n'
} else if (str.indexOf(poisk3) == 0) {
arstr2 = (str.substring(poisk3.length, str.length - 2)).split(',')
if (arstr2[2].toString().trim() == 1) {
napr = false
} else {
napr = true
}
str = 'p2 = ' + arstr2[0] + '; \n' +
'coba=center2(p1, p2, ' + arstr2[1] + ') ; \n' +
' centre = TestC(coba,p1, p2, ' + arstr2[1] + ',napr) ; \n' +
'cRis.AddArc(p1, p2, centre, napr); \n' +
'p1 = p2; \n'
// system.log(str2)
}else if (str.indexOf(poisk4) == 0) {
arstr3 = (str.substring(poisk4.length, str.length - 2)).split(',')
str = 'p2 = ' + arstr3[0] + '; \n' +
'p3 = ' + arstr3[1] + '; \n' +
'cRis.AddArc(p1, p2,p3); \n' +
'p1 = p3; \n'
// system.log(str2)
}
// cRis = NewContour()
system.log(str )
eval(str)
// fp = AddFrontPanel(0, 0, W.Value, H.Value, 0)
// fp.Name = str.toString()
// Frezerovka(fp, cRis, FrezaFigurnaya.Value, 'Фигурная')
//system.log
}
fp = AddFrontPanel(0, 0, W.Value, H.Value, 0)
Frezerovka(fp, cRis, FrezaFigurnaya.Value, 'Фигурная')
// fp = AddFrontPanel(-999990, -9999990, 999999999,9999999, 0)
//fp.Contour.Free()
// fp.Contour.Subtraction(cRis)
}
function Scrugl(rasch) {
poisk = 'FS_Fillet2Lines_1('
if (rasch.indexOf(poisk) > -1) {
retip = rasch.split(poisk)
//разбили всю строку Расчётов именем команды
// осталось собрать всё назад ?с заменой на команду базиса?
// ?и удалением скобки после переменных?
// !!!!! ПРЕДПОЛОГАЕМ ЧТО В ВЫЧИСЛЕНИИ ТОЛЬКО ЭТА КОМАНДА
// ТО ЕСТЬ РЕЗУЛЬАТОМ БУДЕТ ТОЧКА 1 ИЛИ 2
r2 = []
r2.push(retip[0])
system.log(retip[0] + ' -- retip[0]')
/////////////////// ------------
//retip = vsevhojdeniya( rasch,poisk)
// ? ДОРАБОТАТЬ
// ar_p1_ir =[]
for (ir = 1; ir < retip.length; ir++) {
podstr = retip[ir]
// system.log(podstr podstr )
//i1 = retip[ir]+ poisk.length
i1 = podstr.indexOf(')')
n4 = podstr.substring(0, i1)
an4 = n4.split(',')
testc = NewContour()
pr1 = eval(an4[0])
pr2 = eval(an4[1])
pr3 = eval(an4[2])
rr = parseInt(eval(an4[3]))
system.log(pr1 + ' -- ' + pr2.x + ' -- ' + pr3 + ' -- ' + rr + ' -- ' + an4[3])
l1 = testc.AddLine(pr1, pr2)
l2 = testc.AddLine(pr2, pr3)
testc.RoundingEx(l1, l2, (pr1.x + pr3.x) / 2, (pr1.y + pr3.y) / 2, rr)
// ? ДОРАБОТАТЬ
// ar_p1_ir.push( testc[2].Pos1)
p_1 = testc[2].Pos1
rasch = 'p_1'
}
}
poisk = 'FS_Fillet2Lines_2('
if (rasch.indexOf(poisk) > -1) {
retip = rasch.split(poisk)
//разбили всю строку Расчётов именем команды
// осталось собрать всё назад ?с заменой на команду базиса?
// ?и удалением скобки после переменных?
// !!!!! ПРЕДПОЛОГАЕМ ЧТО В ВЫЧИСЛЕНИИ ТОЛЬКО ЭТА КОМАНДА
// ТО ЕСТЬ РЕЗУЛЬАТОМ БУДЕТ ТОЧКА 1 ИЛИ 2 , ИЛИ НАПРАВЛЕНИЕ
r2 = []
r2.push(retip[0])
system.log(retip[0] + ' -- retip[0]')
/////////////////// ------------
//retip = vsevhojdeniya( rasch,poisk)
// ? ДОРАБОТАТЬ
// ar_p1_ir =[]
for (ir = 1; ir < retip.length; ir++) {
podstr = retip[ir]
// system.log(podstr podstr )
//i1 = retip[ir]+ poisk.length
i1 = podstr.indexOf(')')
n4 = podstr.substring(0, i1)
an4 = n4.split(',')
testc = NewContour()
pr1 = eval(an4[0])
pr2 = eval(an4[1])
pr3 = eval(an4[2])
rr = parseInt(eval(an4[3]))
fp = AddFrontPanel(0, 0, W.Value, H.Value, 0)
fpc = fp.GCenter
system.log(pr1 + ' -- ' + pr2.x + ' -- ' + pr3 + ' -- ' + rr + ' -- ' + an4[3])
l1 = testc.AddLine(pr1, pr2)
l2 = testc.AddLine(pr2, pr3)
testc.RoundingEx(l1, l2, (pr1.x + pr3.x) / 2, (pr1.y + pr3.y) / 2, rr)
// ? ДОРАБОТАТЬ
// ar_p1_ir.push( testc[2].Pos1)
p_2 = testc[2].Pos2
rasch = 'p_2'
}
}
poisk = 'FS_Fillet2Lines_Dir('
if (rasch.indexOf(poisk) > -1) {
// !!!!! ПРЕДПОЛОГАЕМ ЧТО В ВЫЧИСЛЕНИИ ТОЛЬКО ЭТА КОМАНДА
// ТО ЕСТЬ РЕЗУЛЬАТОМ БУДЕТ ТОЧКА 1 ИЛИ 2 , ИЛИ НАПРАВЛЕНИЕ
rasch = '1'
}
return rasch
}
function TestC(coba, p1, p2, r, napr) {
test = NewContour()
l1 = test.AddArc(p1, p2, coba[0], napr).ObjLength()
l2 = test.AddArc(p1, p2, coba[1], napr).ObjLength()
if (l1 > l2) {
return coba[1]
} else {
return coba[0]
}
}
function center2(p1, p2, r) {
x1 = p1.x
x2 = p2.x
y1 = p1.y
y2 = p2.y
system.log(x1 + ' -- ' + x2 + ' -- ' + y1 + ' -- ' + y2 + ' -- ' + r)
d = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
h = Math.sqrt(r * r - (d / 2) * (d / 2));
x01 = x1 + (x2 - x1) / 2 + h * (y2 - y1) / d;
y01 = y1 + (y2 - y1) / 2 - h * (x2 - x1) / d;
x02 = x1 + (x2 - x1) / 2 - h * (y2 - y1) / d
y02 = y1 + (y2 - y1) / 2 + h * (x2 - x1) / d;
c1 = NewPoint(x01, y01)
c2 = NewPoint(x02, y02)
coba = []
coba.push(c1, c2)
return coba
}
function vsevhojdeniya(str, poisk) {
retip = []
var i = 0;
while (x != -1) {
var x = str.indexOf(poisk, i);
i = x + 1;
if (x != -1) {
retip.push(x)
}
}
return retip
}
function Frezerovka(Obj, Contur, FileFreza, CutName) {
//FileFreza = 'Фреза1.frw';
if (system.fileExists(FileFreza)) {
// Obj = Obj.AsPanel;
StartEditing(Obj);
Cut = Obj.AddCut(CutName);
Traj = Cut.Trajectory;
Traj.AddList(Contur.MakeCopy());
//L1 = Traj.AddLine(100, 100, 200, 200);
Cut.Contour.Load(FileFreza);
//Cut.CutMode=0;
//Cut.CutType=0;
//Cut.IndexOfPanelElem=-1;
Cut.Contour.Move(0, Obj.Thickness);
Obj.Build();
}
}
[свернуть]