-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_att_value.ulp
156 lines (146 loc) · 3.28 KB
/
change_att_value.ulp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Author: sansil, [email protected]
// Date: 24/04/18
/*
* Description:
* Change the all values with the "MPN" attribute .
* Helpful for example when you need to change the MPN (manufacturer part number)
* of one component for a new one (out of stock for example).
*/
// TODO: make name of attribute variable.
#usage "Desde la linea de comandos se ejecuta: run show_v <Valor_a_buscar> "
int count = 0;
int count_cambios = 0;
string c = "0";
string s = "";
string att = "";
string valor = "";
string input_text = "";
string input_MPN_aremplazar = "";
string info = "";
string commandstring = ";WINDOW FIT;SHOW @ ";
//Control de entrada. se pasa el valor ingresado a lowercase. y se quitan los espacios. A los espacios los toma como un argc
string valorlow = "";
string inputString = "";
int j = 0;
char ch;
//output("C:log.txt","wt") {
for (int i = 1; i <= argc; i++)
{
inputString = argv[i];
j = 0;
valorlow = "";
while (inputString[j])
{
if (isalpha(inputString[j]))
{
ch = inputString[j];
valorlow[j] = tolower(ch);
}
else
{
valorlow[j] = inputString[j];
}
j++;
}
//printf("%s ",valorlow);
valor = valor + valorlow;
}
//printf("%s ",valor);
//}
//valor = valorlow;
if (argc <= 1)
{ // no ingreso el valor a buscar
dlgDialog("Info sansil"){
dlgVBoxLayout{
dlgLabel("&Ingrese el valor del MPN a remplazar");
dlgStringEdit(input_text);
dlgLabel("&Ingrese el valor del nuevo MPN ");
dlgStringEdit(input_MPN_aremplazar);
dlgPushButton("+OK") dlgAccept();
//dlgPushButton("Cancel") dlgReject();
}
}
;
}
if (sheet)
{
sheet(S)
{
output("C:\Users\Gonzalo\Documents\MARKRobots\PCB\Shield\log.txt", "wt")
{
if (input_text != "")
valor = input_text;
S.parts(P)
{
P.attributes(A)
{
if (A.name == "MPN")
{
if (A.value == input_text)
{
att = att + "ATTRIBUTE " + P.name + " MPN " + "'" + input_MPN_aremplazar + "'" + ";";
count_cambios = count_cambios + 1;
printf("%s ", P.name);
s = s + P.name + " ";
count++;
}
}
}
// if (P.value == valor){
// printf("%s ", P.name);
// s = s + P.name + " ";
// count++;
// //printf(input_text);
// }
}
dlgDialog("Info sansil")
{
sprintf(c, "%d", count_cambios);
string info = "Numero de componentes actualizados: " + c;
dlgLabel(info);
dlgPushButton("+OK") dlgAccept();
};
commandstring = att + commandstring + s;
exit(commandstring);
}
}
}
else if (board)
{
if (input_text != "")
valor = input_text;
board(B)
{
//output("C:log.txt","wt") {
B.elements(E)
{
//printf("%s ", E.value);
if (E.value == valor)
{
//printf("%s ", E.name);
s = s + E.name + " ";
count++;
//printf(input_text);
}
}
//}
dlgDialog("Info sansil")
{
sprintf(c, "%d", count_cambios);
string info = "Numero de componentes actualizados: " + c;
dlgLabel(info);
dlgPushButton("+OK") dlgAccept();
};
commandstring = commandstring + s + att;
exit(commandstring);
}
}
else
{
int Result = dlgDialog("Info sansil")
{
info = "Debe ejecutar el ULP dentro de un .SCH o .BRD";
dlgLabel(info);
dlgPushButton("+OK") dlgAccept();
};
}