#usage "Copies the Placement from parts to other parts
\n"
" \nThis program can only work in the board editor.");
exit(1);
}
///////////////////////////////////////////
// Create layer list
///////////////////////////////////////////
board(B)
{
B.layers(L)
{
if (L.used || L.number == iLayerRef || L.number == iLayerCopy)
{
if (L.number == iLayerRef) iLayerRefSel = iLayerCount;
if (L.number == iLayerCopy) iLayerCopySel = iLayerCount;
layer_number[iLayerCount] = L.number;
sprintf (layer_name[iLayerCount++], "%d - %s", L.number, L.name);
}
}
}
///////////////////////////////////////////
// First Dialog
///////////////////////////////////////////
iResult = dlgDialog("Copy placement (Step 1 of 2)")
{
dlgGroup("Reference Elements")
{
dlgLabel("Rectangles which contains the reference elements are on Layer:");
dlgComboBox (layer_name, iLayerRefSel);
}
dlgGroup("Candidate preselection for copied placement")
{
dlgCheckBox ("Run auto selection", iAutoSelection);
dlgLabel(" You should draw a rectangle (RECT) on layer '" + layer_name[iLayerRefSel] + "' around the elements whitch are the placement reference.");
exit(1);
}
if (iRefCount == 0)
{
dlgMessageBox ("Error! No elements found! There are no reference elements inside the rectangle(s) on layer '" + layer_name[iLayerRefSel] + "'.");
exit(2);
}
AutoSelection();
///////////////////////////////////////////
// Second Dialog
///////////////////////////////////////////
iResult = dlgDialog ("Copy placement (Step 2 of 2)")
{
/* dlgGroup("Offset")
{
dlgGridLayout
{
dlgCell(0, 0) dlgHBoxLayout { dlgLabel("Unit:"); dlgSpacing(10); }
dlgCell(0, 1) dlgHBoxLayout
{
dlgRadioButton("&inch", iUnit);
dlgRadioButton("&mil", iUnit);
dlgRadioButton("&mm", iUnit);
dlgRadioButton("&mic", iUnit);
dlgStretch(1);
}
dlgCell(1, 0) dlgLabel("X:");
dlgCell(1, 1) dlgHBoxLayout { dlgStringEdit(strOffsetX); dlgStretch(1); }
dlgCell(2, 0) dlgLabel("Y:");
dlgCell(2, 1) dlgHBoxLayout { dlgStringEdit(strOffsetY); dlgStretch(1); }
}
}
*/
dlgGroup("Placement")
{
dlgGridLayout
{
dlgCell (1,0) dlgRadioButton("Left", iPlacement);
dlgCell (0,1) dlgRadioButton("Top", iPlacement);
dlgCell (1,2) dlgRadioButton("Right", iPlacement);
dlgCell (2,1) dlgRadioButton("Bottom", iPlacement);
}
}
dlgGroup("Elements")
{
dlgLabel ("Double click on an item to change the copyied element.\nUse the options above preselect the candidates.");
dlgListView("Reference Placement\tCopy to", lines, iListSel) EditPlacement();
}
dlgGroup("Candidate preselection")
{
dlgRadioButton("All elements", iPlaceSelection);
dlgRadioButton("Only elements with negative coordinates", iPlaceSelection);
dlgHBoxLayout { dlgRadioButton("Only elements in rectangles on layer", iPlaceSelection); dlgComboBox (layer_name, iLayerCopySel) UpdateCopyRectElements(); }
dlgCheckBox ("Only elements with greater number", iOnlyGreaterNumber);
dlgCheckBox ("Only elements with same package", iOnlySamePackage);
dlgHBoxLayout { dlgCheckBox ("Only elements with the same ", iOnlyLastDigit); dlgSpinBox(iLastDigits, 0, 5); dlgLabel (" last digits."); dlgStretch(1); }
}
dlgSpacing(10);
dlgHBoxLayout
{
dlgStretch(1);
dlgPushButton("Start") dlgAccept();
dlgPushButton("Cancel") dlgReject();
dlgStretch(1);
}
};
if (iResult == 0) exit(0);
int dX=0, dY=0;
if (iPlacement == 0)
{
dX = -iDiffX;
dY = 0;
}
else if (iPlacement == 1)
{
dX = 0;
dY = iDiffY;
}
else if (iPlacement == 2)
{
dX = iDiffX;
dY = 0;
}
else if (iPlacement == 3)
{
dX = 0;
dY = -iDiffY;
}
/*
///////////////////////////////////////////
// Copy old places, layers to the arrays
///////////////////////////////////////////
board(B)
{
B.elements(E)
{
for (i=0; i
");
dlgRadioButton("All elements", iPlaceSelection);
dlgRadioButton("Only elements with negative coordinates", iPlaceSelection);
dlgHBoxLayout { dlgRadioButton("Only elements in rectangles on layer", iPlaceSelection); dlgComboBox (layer_name, iLayerCopySel); }
dlgCheckBox ("Only elements with greater number", iOnlyGreaterNumber);
dlgCheckBox ("Only elements with same package", iOnlySamePackage);
dlgHBoxLayout { dlgCheckBox ("Only elements with the same ", iOnlyLastDigit); dlgSpinBox(iLastDigits, 1, 5); dlgLabel (" last digits."); dlgStretch(1); }
}
dlgHBoxLayout
{
dlgStretch(1);
dlgPushButton("+Next >>") dlgAccept();
dlgPushButton("-Cancel") dlgReject();
}
};
if (iResult == 0) exit(0);
iLayerRef = layer_number[iLayerRefSel];
UpdateCopyRectElements();
///////////////////////////////////////////
// Find reference Elements
// (inside rectangles on layer 49)
///////////////////////////////////////////
board(B)
{
B.rectangles(R)
{
if (R.layer == iLayerRef)
{
B.elements(E)
{
if (isElementInRectangle(E, R))
{
ref_x[iRefCount] = E.x;
ref_y[iRefCount] = E.y;
ref_angle[iRefCount] = E.angle;
ref_mirror[iRefCount] = E.mirror;
eleRef[iRefCount] = E.name;
pac[iRefCount] = E.package.name;
RebuildListLine(iRefCount);
iRefCount++;
}
}
iRectCount++;
if (R.x2 - R.x1 > iDiffX) iDiffX = R.x2 - R.x1;
if (R.y2 - R.y1 > iDiffY) iDiffY = R.y2 - R.y1;
}
}
strRefElements = " " + strjoin (eleRef, ' ') + " ";
}
if (iRectCount == 0)
{
dlgMessageBox ("Error! No reference rectangle found!