skr = NewFloatInput('Радиус скругления', 50);
skr.Value = 50
butMat = NewButtMaterialInput("Кромка");
butMat.Visible = false
//alert(butMat)
BtnMake = NewButtonInput('Закончить');
BtnMake.OnChange = function() {
// Make(); //Вызываем функцию построения всех панелей
Action.Finish();
}
Action.Continue();
// continue action
i = 0
while (i < 1000) {
th = 0
th2 = 0
pp = GetPoint("Укажите точку скругления")
Obj = Action.Get3DObject();
if (Obj== undefined) {continue}
if (Obj.AsPanel) {
Obj = Obj.AsPanel
p = Obj.ToObject(pp);
pv = p
//p = Obj.Contour.ClosestPoint(p)
elem1 = Obj.Contour.Find(p.x, p.y)
if (elem1.ElType != 3) {
ib = indexKroma(Obj, Obj.Contour.IndexOf(elem1))
if (ib > -1) {
th = Obj.Butts[ib].Thickness;
i_elementakontura_s_spravilnymKromom = ib
// alert(i_elementakontura_s_spravilnymKromom+ ' == ' + th)
// alert(ib + ' -- ' + Obj.Butts[ib].Material)
}
ep1 = elem1.Pos1
ep2 = elem1.Pos2
d1 = Distance(ep1, p)
d2 = Distance(ep2, p)
// alert(d1+ ' -- '+d2)
if (d1 > d2) {
tskr = ep2
} else {
tskr = ep1
}
}
//alert(f)
p = NewPoint(okr(tskr.x), okr(tskr.y))
//alert(p.y)
ck = Obj.Contour.Count;
//var elem1
//var elem2
for (i = 0; i < ck; i++) {
if (Obj.Contour[i].ElType != 3 && !(i == Obj.Contour.IndexOf(elem1))) {
x1 = okr(Obj.Contour[i].Pos1.x)
y1 = okr(Obj.Contour[i].Pos1.y)
x2 = okr(Obj.Contour[i].Pos2.x)
y2 = okr(Obj.Contour[i].Pos2.y)
// alert(p.x+'_--_'+x1+'_--_'+x2+'\n'+p.y+'_--_'+y1+'_--_'+y2)
if ((p.x == x1 && p.y == y1) || (p.x == x2 && p.y == y2)) {
elem2 = Obj.Contour[i];
ib = indexKroma(Obj, i)
if (ib > -1) {
//alert(th+ ' == '+Obj.Butts[ib].Thickness)
if (th < Obj.Butts[ib].Thickness) {
th = Obj.Butts[ib].Thickness;
i_elementakontura_s_spravilnymKromom = ib
// alert(i_elementakontura_s_spravilnymKromom+ ' == ' + th)
}
}
}
}
}
// alert(elem1+'=='+Obj.Contour.IndexOf(elem1)+' _--_ ' +elem2+'=='+Obj.Contour.IndexOf(elem2))
//alert(s + ' -- px' + p.x+ ' -- py' + p.y)
// p = NewPoint(Math.round(p.x * 10) * 0.1,Math.round(p.y * 10) * 0.1 )
Undo.Changing(Obj)
xy = Obj.GCenter;
// alert( xy.x+' - - '+ xy.y)
//xy = OpredelitStorouPaneli2(p, Obj)
//c= NewContour()
//c.AddCircle(xy.x, xy.y, 30)
// r =
r = Obj.Contour.RoundingEx(elem1, elem2, pv.x, pv.y, skr.Value);
// alert(r)
//
//r = Obj.Contour.Find(xy.x, xy.y);
Obj.Build();
//alert(Obj.Contour.IndexOf(r))
// alert(Butt)
if (!(th == 0)) {
//ri = indexElementaKontura(Obj.Contour, r)
Obj.AddButt(butMat, Obj.Contour.IndexOf(r))
ir = indexKroma(Obj, Obj.Contour.IndexOf(r))
ib = i_elementakontura_s_spravilnymKromom
// alert(ib+ ' -- '+ Obj.Butts[ib].Material)
Obj.Butts[ir].Thickness = Obj.Butts[ib].Thickness;
Obj.Butts[ir].Material = Obj.Butts[ib].Material;
Obj.Butts[ir].Sign = Obj.Butts[ib].Sign;
Obj.Butts[ir].ClipPanel = Obj.Butts[ib].ClipPanel;
Obj.Butts[ir].Width = Obj.Butts[ib].Width;
Obj.Butts[ir].Overhung = Obj.Butts[ib].Overhung
Obj.Butts[ir].Allowance = Obj.Butts[ib].Allowance
// alert(Obj.Butts[ir].Material)
//
//ri = indexKroma(Obj, Obj.Contour.IndexOf(r))
//bu = Butt
// alert(ri)
// bb = Obj.Butts.Add(r)
//bb.ElemIndex = r.ElemIndex
//bb.Material = mb
//bb.Sign = sb
//bb.Thickness = th
}
//Obj.Contour.Subtraction(c)
Obj.Build();
}
i++
}
function Distance(p1, p2) {
var dx = p2.x - p1.x;
var dy = p2.y - p1.y;
// var dz = p2.z - p1.z;
return Math.sqrt(dx * dx + dy * dy);
}
function indexKroma(Panel, inexElementaKontura) {
bk = Panel.Butts.Count
for (ib = 0; ib < bk; ib++) {
if (Panel.Butts[ib].ElemIndex == inexElementaKontura) {
return ib
}
}
return -1
}
function indexElementaKontura(kontur, ElementKontura) {
ck = kontur.Count
for (ic = 0; ic < ck; ic++) {
alert(kontur[ic] == ElementKontura)
if (kontur[ic].kontur[ic] == ElementKontura) {
return ic
}
}
}
function OpredelitStorouPaneli2(p, Obj) {
lnpv = GabarityContura(Obj);
p = NewPoint(Math.round(p.x * 10) * 0.1, Math.round(p.y * 10) * 0.1)
ln = lnpv[0];
pv = lnpv[1];
centrContura = NewPoint(ln.x + (pv.x - ln.x) / 2, ln.y + (pv.y - ln.y) / 2)
return centrContura
}
function OpredelitStorouPaneli(p, Obj) {
lnpv = GabarityContura(Obj);
p = NewPoint(Math.round(p.x * 10) * 0.1, Math.round(p.y * 10) * 0.1)
ln = lnpv[0];
pv = lnpv[1];
otXs = 1
otYs = 1
if (p.x == ln.x && p.y == ln.y) {
// alert("1")
return (NewPoint(ln.x + otXs, ln.y + otYs))
}
if (p.x == pv.x && p.y == ln.y) {
//alert("2")
return (NewPoint(pv.x - otXs, ln.y + otYs))
}
if (p.x == pv.x && p.y == pv.y) {
//alert("3")
return (NewPoint(pv.x - otXs, pv.y - otYs))
}
if (p.x == ln.x && p.y == pv.y) {
//alert("4")
return (NewPoint(ln.x + otXs, pv.y - otYs))
}
}
function GabarityContura(Obj)
{
var text = '';
ln = NewPoint(0, 0); //левый низ
lv = NewPoint(0, 0); //левый верх
pn = NewPoint(0, 0); //правый низ
pv = NewPoint(0, 0); //правый верх контура
kontur = Obj.Contour;
kstoron = kontur.Count;
// var k_ne_krugov = 0;
for (i = 0; i < kstoron; i++) {
if (kontur[i].ElType != 3) { //k_ne_krugov = k_ne_krugov+1
ln = NewPoint(Math.round(kontur[i].Pos1.x * 10) / 10, Math.round(kontur[i].Pos1.y * 10) / 10);
lv = NewPoint(Math.round(kontur[i].Pos1.x * 10) / 10, Math.round(kontur[i].Pos1.y * 10) / 10);
pn = NewPoint(Math.round(kontur[i].Pos1.x * 10) / 10, Math.round(kontur[i].Pos1.y * 10) / 10);
pv = NewPoint(Math.round(kontur[i].Pos1.x * 10) / 10, Math.round(kontur[i].Pos1.y * 10) / 10);
}
};
for (i = 0; i < kstoron; i++) {
if (kontur[i].ElType != 3) {
Pos1x = Math.round(kontur[i].Pos1.x * 10) / 10;
Pos1y = Math.round(kontur[i].Pos1.y * 10) / 10;
Pos2x = Math.round(kontur[i].Pos2.x * 10) / 10;
Pos2y = Math.round(kontur[i].Pos2.y * 10) / 10;
if (ln.x > Pos1x) {
ln.x = Pos1x
};
if (ln.x > Pos2x) {
ln.x = Pos2x
};
if (ln.y > Pos1y) {
ln.y = Pos1y
};
if (ln.y > Pos2y) {
ln.y = Pos2y
};
if (lv.x > Pos1x) {
lv.x = Pos1x
};
if (lv.x > Pos2x) {
lv.x = Pos2x
};
if (lv.y < Pos1y) {
lv.y = Pos1y
};
if (lv.y < Pos2y) {
lv.y = Pos2y
};
if (pn.x < Pos1x) {
pn.x = Pos1x
};
if (pn.x < Pos2x) {
pn.x = Pos2x
};
if (pn.y > Pos1y) {
pn.y = Pos1y
};
if (pn.y > Pos2y) {
pn.y = Pos2y
};
if (pv.x < Pos1x) {
pv.x = Pos1x
};
if (pv.x < Pos2x) {
pv.x = Pos2x
};
if (pv.y < Pos1y) {
pv.y = Pos1y
};
if (pv.y < Pos2y) {
pv.y = Pos2y
};
}
};
text4 = ('ln ---- ' + ln.x + ' - ' + ln.y + '\n' +
'lv ---- ' + lv.x + ' - ' + lv.y + '\n' +
'pn ---- ' + pn.x + ' - ' + pn.y + '\n' +
'pv ---- ' + pv.x + ' - ' + pv.y + '\n');
// alert(text4);
ln_v = ln; //левый низ выреза
pv_v = pv; //правый верх выреза
if (ln_v.x < lv.x) {
ln_v.x = lv.x
};
if (ln_v.y < pn.y) {
ln_v.y = pn.y
};
if (pv_v.x > pn.x) {
pv_v.x = pn.x
};
if (pv_v.y > lv.y) {
pv_v.y = lv.y
};
SeredinaVisotiPaneli = (pv_v.y - ln_v.y) * 0.5;
SeredinaShiriniPaneli = (pv_v.x - ln_v.x) * 0.5;
lnpv = []
lnpv.push(ln_v);
lnpv.push(pv_v);
return lnpv
}
function okr(chislo) {
return Math.round(chislo * 10) / 10
}
[свернуть]