1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./style.css" />
6 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./design.css" />
7 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"./print.css" />
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
14 <em>Эта страница доступна также на следующих языках:
</em>
15 <a href=
"geda-guile_scripting.html" class=
"wikilink1" title=
"geda-guile_scripting.html">English
</a>
18 <h2 id=
"скриптыguile">Скрипты Guile
</h2>
22 В gEDA/gaf для обеспечения возможности написания скриптов на Scheme
23 используется Guile Scheme, и в распоряжении
24 разработчика оказываются все возможности языка Guile.
<em>Справочное
25 руководство по Guile
</em> [
<em>Guile Reference Manual
</em>] можно найти либо в
26 формате Info (
<code>info guile
</code> на большинстве систем), либо в
32 Для доступа к объектам и страницам gEDA и для их изменения имеется набор
33 модулей, называемый gEDA Scheme API. Есть и
<em>Справочное руководство по
34 Scheme в gEDA
</em> [
<em>gEDA Scheme Reference Manual
</em>] в формате Info
35 (
<code>info geda-scheme
</code>).
40 <h3 id=
"учебники">Учебники
</h3>
43 <li class=
"level1"><div class=
"li"> <a href=
"geda-gnetlistschemetutorial.ru.html" class=
"wikilink2" title=
"geda-gnetlistschemetutorial.ru.html">Написание скриптов драйверов gnetlist на Scheme
</a> (
<em>John Doty
</em>)
</div>
48 Смотрите также раздел
<a href=
"geda-gschem_ug-extensions.ru.html" class=
"wikilink1" title=
"geda-gschem_ug-extensions.ru.html">Расширение
49 функциональности gschem
</a> <em><a href=
"geda-gschem_ug.ru.html" class=
"wikilink1" title=
"geda-gschem_ug.ru.html">Руководства пользователя
50 gEDA gschem
</a></em> и раздел
<a href=
"geda-gnetlist_ug.ru.html#apiдрайверавscheme" class=
"wikilink1" title=
"geda-gnetlist_ug.ru.html">API драйвера в Scheme
</a>
51 <em><a href=
"geda-gnetlist_ug.ru.html" class=
"wikilink1" title=
"geda-gnetlist_ug.ru.html">Руководства пользователя gEDA gnetlist
</a></em>.
56 <h3 id=
"справочнаяинформация">Справочная информация
</h3>
59 <li class=
"level1"><div class=
"li"> <a href=
"https://www.google.com/search?q=gEDA%3Agnetlist%20Scheme%20primitives&btnI=lucky" class=
"interwiki iw_go" title=
"https://www.google.com/search?q=gEDA%3Agnetlist%20Scheme%20primitives&btnI=lucky">Примитивы Scheme для gnetlist
</a></div>
61 <li class=
"level1"><div class=
"li"> <a href=
"geda-gschemrepl.ru.html" class=
"wikilink2" title=
"geda-gschemrepl.ru.html">Использование REPL в gschem
</a></div>
67 <h3 id=
"примерыскриптов">Примеры скриптов
</h3>
71 Каждый скрипт можно скачать и загрузить в
<strong>gschem
</strong>:
74 <li class=
"level1"><div class=
"li"> нажмите
<kbd>:
</kbd> и введите
<pre class=
"code lisp"><span class=
"br0">(</span>load
<span class=
"st0">"filename.scm
"</span><span class=
"br0">)</span></pre>
77 <li class=
"level1"><div class=
"li"> затем нажмите
<kbd>Enter
</kbd></div>
83 <h4 id=
"удалениеобъектовсзаданнымисвойствами">Удаление объектов с заданными свойствами
</h4>
87 Например, удалим все объекты, являющиеся окружностями или дугами с нулевым
91 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=1" title=
"Download Snippet" class=
"mediafile mf_scm">remove-objects.scm
</a></dt>
92 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>geda page
<span class=
"br0">)</span><span class=
"br0">)</span>
94 <span class=
"co1">; Проверяет, является ли объект OBJECT окружностью (circle)
</span>
95 <span class=
"co1">; или дугой (arc) с нулевым радиусом
</span>
96 <span class=
"br0">(</span>define
<span class=
"br0">(</span>zero-radius-object? object
<span class=
"br0">)</span>
97 <span class=
"br0">(</span><span class=
"kw1">or
</span>
98 <span class=
"br0">(</span><span class=
"kw1">and
</span> <span class=
"br0">(</span>circle? object
<span class=
"br0">)</span> <span class=
"br0">(</span><span class=
"sy0">=
</span> <span class=
"br0">(</span>circle-radius object
<span class=
"br0">)</span> <span class=
"nu0">0</span><span class=
"br0">)</span><span class=
"br0">)</span>
99 <span class=
"br0">(</span><span class=
"kw1">and
</span> <span class=
"br0">(</span>arc? object
<span class=
"br0">)</span> <span class=
"br0">(</span><span class=
"sy0">=
</span> <span class=
"br0">(</span>arc-radius object
<span class=
"br0">)</span> <span class=
"nu0">0</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
101 <span class=
"br0">(</span><span class=
"kw1">apply
</span> page-remove
<span class=
"sy0">!
</span> <span class=
"br0">(</span>active-page
<span class=
"br0">)</span>
102 <span class=
"br0">(</span>filter
104 <span class=
"br0">(</span>page-contents
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
108 Предположим, нам необходимо удалить компонент с известным атрибутом, тогда
109 нам нужно также отделить и удалить все его атрибуты. Функция, определённая
110 ниже делает именно это.
113 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=2" title=
"Download Snippet" class=
"mediafile mf_scm">remove-components-with-attribs.scm
</a></dt>
114 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>geda page
<span class=
"br0">)</span><span class=
"br0">)</span>
115 <span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>geda object
<span class=
"br0">)</span><span class=
"br0">)</span>
116 <span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>geda attrib
<span class=
"br0">)</span><span class=
"br0">)</span>
118 <span class=
"co1">; Удаляет все компоненты, имеющие атрибут NAME=VALUE, со страницы PAGE
</span>
119 <span class=
"br0">(</span>define
<span class=
"br0">(</span>delete-components-by-attrib
<span class=
"sy0">!
</span> page
<span class=
"kw1">name
</span> <span class=
"kw1">value
</span><span class=
"br0">)</span>
120 <span class=
"br0">(</span>for-each
121 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>obj
<span class=
"br0">)</span>
122 <span class=
"br0">(</span><span class=
"kw1">if
</span> <span class=
"br0">(</span>component? obj
<span class=
"br0">)</span>
123 <span class=
"br0">(</span>for-each
124 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>attr
<span class=
"br0">)</span>
125 <span class=
"br0">(</span><span class=
"kw1">and
</span>
126 <span class=
"br0">(</span>string
<span class=
"sy0">=
</span>?
<span class=
"br0">(</span>attrib-name attr
<span class=
"br0">)</span> <span class=
"kw1">name
</span><span class=
"br0">)</span>
127 <span class=
"br0">(</span>string
<span class=
"sy0">=
</span>?
<span class=
"br0">(</span>attrib-value attr
<span class=
"br0">)</span> <span class=
"kw1">value
</span><span class=
"br0">)</span>
128 <span class=
"br0">(</span><span class=
"kw1">let
</span> <span class=
"br0">(</span><span class=
"br0">(</span>attached-attribs
<span class=
"br0">(</span>object-attribs obj
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
129 <span class=
"br0">(</span><span class=
"kw1">apply
</span> detach-attribs
<span class=
"sy0">!
</span> obj attached-attribs
<span class=
"br0">)</span>
130 <span class=
"br0">(</span><span class=
"kw1">apply
</span> page-remove
<span class=
"sy0">!
</span> page obj attached-attribs
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
131 <span class=
"br0">(</span>object-attribs obj
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
132 <span class=
"br0">(</span>page-contents page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
136 После загрузки файла, нажмите
<kbd>:
</kbd> и введите, например,
138 <pre class=
"code lisp"><span class=
"br0">(</span>delete-components-by-attrib
<span class=
"sy0">!
</span> <span class=
"br0">(</span>active-page
<span class=
"br0">)</span> <span class=
"st0">"refdes
"</span> <span class=
"st0">"R1
"</span><span class=
"br0">)</span> </pre>
142 <h4 id=
"процедурыдлявводавывода">Процедуры для ввода/вывода
</h4>
146 Следующий скрипт определяет две процедуры, которые могут использоваться
147 в режиме пакетной обработки с помощью скриптов для
<strong>gaf shell
</strong>:
150 <li class=
"level1"><div class=
"li"> <code>schematic-file-
>page
</code></div>
152 <li class=
"level1"><div class=
"li"> <code>page-
>schematic-file
</code></div>
156 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=4" title=
"Download Snippet" class=
"mediafile mf_scm">geda-io.scm
</a></dt>
157 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>ice-
<span class=
"nu0">9</span> lineio
<span class=
"br0">)</span><span class=
"br0">)</span>
158 <span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>geda page
<span class=
"br0">)</span><span class=
"br0">)</span>
160 <span class=
"co1">; Процедуры ввода/вывода
</span>
161 <span class=
"co1">; Читает файл FILE и выводит строку
</span>
162 <span class=
"br0">(</span>define
<span class=
"br0">(</span>file-
<span class=
"sy0">></span>string file
<span class=
"br0">)</span>
163 <span class=
"br0">(</span><span class=
"kw1">let
</span>*
<span class=
"br0">(</span><span class=
"br0">(</span>port
<span class=
"br0">(</span>make-line-buffering-input-port
<span class=
"br0">(</span>open-file file
<span class=
"st0">"r
"</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
164 <span class=
"br0">(</span><span class=
"kw1">do
</span> <span class=
"br0">(</span><span class=
"br0">(</span>line
<span class=
"st0">""</span> <span class=
"br0">(</span>read-string port
<span class=
"br0">)</span><span class=
"br0">)</span>
165 <span class=
"br0">(</span>s
<span class=
"st0">""</span> <span class=
"br0">(</span>string-append s line
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
166 <span class=
"br0">(</span><span class=
"br0">(</span>eof-object? line
<span class=
"br0">)</span> <span class=
"co1">; тест
</span>
167 <span class=
"br0">(</span>close-port port
<span class=
"br0">)</span> <span class=
"co1">; выражение(я) для вычисления в конце
</span>
168 s
<span class=
"br0">)</span> <span class=
"co1">; возвращаемое значение
</span>
169 <span class=
"co1">; empty body
</span>
170 <span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
172 <span class=
"co1">; читает файл схемы FILE и возвращает объект страницы PAGE
</span>
173 <span class=
"br0">(</span>define
<span class=
"br0">(</span>schematic-file-
<span class=
"sy0">></span>page file
<span class=
"br0">)</span>
174 <span class=
"br0">(</span>string-
<span class=
"sy0">></span>page file
<span class=
"br0">(</span>file-
<span class=
"sy0">></span>string file
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
176 <span class=
"co1">; сохраняет страницу схемы PAGE в файл FILE
</span>
177 <span class=
"br0">(</span>define
<span class=
"br0">(</span>page-
<span class=
"sy0">></span>schematic-file page file
<span class=
"br0">)</span>
178 <span class=
"br0">(</span>with-output-to-file file
179 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span><span class=
"br0">)</span> <span class=
"br0">(</span>display
<span class=
"br0">(</span>page-
<span class=
"sy0">></span>string page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
184 <h4 id=
"копированиеперемещениеивращениеобъектов">Копирование, перемещение и вращение объектов
</h4>
187 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=5" title=
"Download Snippet" class=
"mediafile mf_scm">move-and-rotate.scm
</a></dt>
188 <dd><pre class=
"code file lisp"> <span class=
"co1">; Scripting example by vzh per request of
</span>
189 <span class=
"co1">; Kai-Martin Knaak :-)
</span>
190 <span class=
"co1">; Use at your own risk.
</span>
192 <span class=
"co1">; Основная процедура здесь
</span>
193 <span class=
"co1">; multiple-copy-move-and-rotate-selection, что можно сократить до
</span>
194 <span class=
"co1">; mcmars.
</span>
195 <span class=
"co1">; Использование:
</span>
196 <span class=
"co1">; запустите gschem, чтобы там можно было использовать этот скрипт, например
</span>
197 <span class=
"co1">; gschem -s move-and-rotate.scm
</span>
198 <span class=
"co1">; выделите объекты в gschem, нажмите ':' (двоеточие) и наберите
</span>
199 <span class=
"co1">; (mcmars '(
1000 .
500)
90 10)
</span>
200 <span class=
"co1">; нажмите
<Enter
></span>
201 <span class=
"co1">; Наслаждайтесь!
</span>
204 <span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>gschem selection
<span class=
"br0">)</span><span class=
"br0">)</span>
206 <span class=
"co1">; округление координат по ALIGN
</span>
207 <span class=
"br0">(</span>define
<span class=
"br0">(</span>ceiling-coords vector align
<span class=
"br0">)</span>
208 <span class=
"br0">(</span><span class=
"kw1">cons
</span>
209 <span class=
"br0">(</span>*
<span class=
"br0">(</span>ceiling-quotient
<span class=
"br0">(</span><span class=
"kw1">car
</span> vector
<span class=
"br0">)</span> align
<span class=
"br0">)</span> align
<span class=
"br0">)</span>
210 <span class=
"br0">(</span>*
<span class=
"br0">(</span>ceiling-quotient
<span class=
"br0">(</span><span class=
"kw1">cdr
</span> vector
<span class=
"br0">)</span> align
<span class=
"br0">)</span> align
<span class=
"br0">)</span>
211 <span class=
"br0">)</span><span class=
"br0">)</span>
213 <span class=
"co1">; Получение минимума X и минимума Y двух пар координат
</span>
214 <span class=
"br0">(</span>define
<span class=
"br0">(</span>min-coords coord1 coord2
<span class=
"br0">)</span>
215 <span class=
"br0">(</span><span class=
"kw1">let
</span> <span class=
"br0">(</span><span class=
"br0">(</span>x
<span class=
"br0">(</span><span class=
"kw1">min
</span> <span class=
"br0">(</span><span class=
"kw1">car
</span> coord1
<span class=
"br0">)</span> <span class=
"br0">(</span><span class=
"kw1">car
</span> coord2
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
216 <span class=
"br0">(</span>y
<span class=
"br0">(</span><span class=
"kw1">min
</span> <span class=
"br0">(</span><span class=
"kw1">cdr
</span> coord1
<span class=
"br0">)</span> <span class=
"br0">(</span><span class=
"kw1">cdr
</span> coord2
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
217 <span class=
"co1">; возвращаемое значение
</span>
218 <span class=
"br0">(</span><span class=
"kw1">cons
</span> x y
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
220 <span class=
"co1">; Копирование, перемещение и вращение текущего выделения. Выделенные объекты
</span>
221 <span class=
"co1">; сначала копируются, затем перемещаются на вектор VECTOR и, наконец, вращаются
</span>
222 <span class=
"co1">; на угол ANGLE вокруг центра, который рассчитывается как округлённая до
</span>
223 <span class=
"co1">; множителей
100 левая нижняя координата всех объектов в выделении.
</span>
224 <span class=
"co1">; Если никакие объекты не выделены, открывает диалоговое окно сообщений gschem
</span>
225 <span class=
"co1">; с предупреждением.
</span>
226 <span class=
"co1">; Возвращает скопированные объекты.
</span>
227 <span class=
"br0">(</span>define
<span class=
"br0">(</span>copy-move-and-rotate-selection vector angle
<span class=
"br0">)</span>
228 <span class=
"br0">(</span><span class=
"kw1">let
</span> <span class=
"br0">(</span><span class=
"br0">(</span>objects
<span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
229 <span class=
"br0">(</span><span class=
"kw1">if
</span> <span class=
"br0">(</span><span class=
"kw1">null
</span>? objects
<span class=
"br0">)</span>
230 <span class=
"br0">(</span>gschem-msg
<span class=
"st0">"Select something first!
"</span><span class=
"br0">)</span>
231 <span class=
"co1">; else
</span>
232 <span class=
"br0">(</span><span class=
"kw1">let
</span>*
<span class=
"br0">(</span><span class=
"br0">(</span>copied-objects
<span class=
"br0">(</span>map copy-object objects
<span class=
"br0">)</span><span class=
"br0">)</span>
233 <span class=
"br0">(</span>translated-objects
<span class=
"br0">(</span><span class=
"kw1">apply
</span> translate-objects
<span class=
"sy0">!
</span> vector copied-objects
<span class=
"br0">)</span><span class=
"br0">)</span>
234 <span class=
"br0">(</span>bounds
<span class=
"br0">(</span><span class=
"kw1">apply
</span> object-bounds translated-objects
<span class=
"br0">)</span><span class=
"br0">)</span>
235 <span class=
"br0">(</span>rotation-center
<span class=
"br0">(</span>ceiling-coords
<span class=
"br0">(</span>min-coords
<span class=
"br0">(</span><span class=
"kw1">car
</span> bounds
<span class=
"br0">)</span> <span class=
"br0">(</span><span class=
"kw1">cdr
</span> bounds
<span class=
"br0">)</span><span class=
"br0">)</span> <span class=
"nu0">100</span><span class=
"br0">)</span><span class=
"br0">)</span>
236 <span class=
"br0">(</span>rotated-objects
<span class=
"br0">(</span><span class=
"kw1">apply
</span> rotate-objects
<span class=
"sy0">!
</span> rotation-center angle translated-objects
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
237 <span class=
"br0">(</span><span class=
"kw1">apply
</span> page-append
<span class=
"sy0">!
</span> <span class=
"br0">(</span>active-page
<span class=
"br0">)</span> rotated-objects
<span class=
"br0">)</span>
238 rotated-objects
<span class=
"br0">)</span>
239 <span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
241 <span class=
"co1">; Умножает VECTOR, который должен быть парой, на число NUMBER
</span>
242 <span class=
"br0">(</span>define
<span class=
"br0">(</span>multiply-vector-by vector number
<span class=
"br0">)</span>
243 <span class=
"br0">(</span><span class=
"kw1">cons
</span> <span class=
"br0">(</span>* number
<span class=
"br0">(</span><span class=
"kw1">car
</span> vector
<span class=
"br0">)</span><span class=
"br0">)</span> <span class=
"br0">(</span>* number
<span class=
"br0">(</span><span class=
"kw1">cdr
</span> vector
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
245 <span class=
"co1">; Копирование, перемещение и вращение текущего выделения количество
</span>
246 <span class=
"co1">; раз, указанное аргументом NUMBER. Применяет процедуру
</span>
247 <span class=
"co1">; copy-move-and-rotate-selection несколько раз, каждый раз увеличивая
</span>
248 <span class=
"co1">; вектор и угол на заданные значения VECTOR и ANGLE.
</span>
249 <span class=
"co1">; Если никакие объекты не выделены, открывает gschem message dialog with
</span>
250 <span class=
"co1">; warning.
</span>
251 <span class=
"co1">; Если никакие объекты не выделены, открывает диалоговое окно сообщений gschem
</span>
252 <span class=
"co1">; с предупреждением.
</span>
253 <span class=
"co1">; Возвращаемое значение не определено.
</span>
254 <span class=
"br0">(</span>define
<span class=
"br0">(</span>multiple-copy-move-and-rotate-selection vector angle num
<span class=
"br0">)</span>
255 <span class=
"br0">(</span><span class=
"kw1">if
</span> <span class=
"br0">(</span><span class=
"kw1">null
</span>?
<span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
256 <span class=
"br0">(</span>gschem-msg
<span class=
"st0">"Select something first!
"</span><span class=
"br0">)</span>
257 <span class=
"co1">; else
</span>
258 <span class=
"br0">(</span><span class=
"kw1">do
</span> <span class=
"br0">(</span><span class=
"br0">(</span>i num
<span class=
"br0">(</span><span class=
"nu0">1</span>- i
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
259 <span class=
"br0">(</span><span class=
"br0">(</span><span class=
"sy0">=
</span> i
<span class=
"nu0">0</span><span class=
"br0">)</span><span class=
"br0">)</span>
260 <span class=
"br0">(</span>copy-move-and-rotate-selection
261 <span class=
"br0">(</span>multiply-vector-by vector i
<span class=
"br0">)</span> <span class=
"br0">(</span>* angle i
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
262 <span class=
"br0">)</span><span class=
"br0">)</span>
264 <span class=
"co1">; Сокращение для имени процедуры multiple-copy-move-and-rotate-selection
</span>
265 <span class=
"br0">(</span>define mcmars multiple-copy-move-and-rotate-selection
<span class=
"br0">)</span> </pre>
270 <h4 id=
"редактированиегруппыатрибутов">Редактирование группы атрибутов
</h4>
274 Допустим, вы выделили несколько позиционных обозначений (атрибут refdes)
275 резисторов и хотите переименовать их все сразу, например, если они были
276 скопированы из другого места.
279 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=6" title=
"Download Snippet" class=
"mediafile mf_">set-selected-attribs-value
</a></dt>
280 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>gschem selection
<span class=
"br0">)</span><span class=
"br0">)</span>
282 <span class=
"br0">(</span>define
<span class=
"br0">(</span>set-selected-attribs-value
<span class=
"sy0">!
</span> <span class=
"kw1">value
</span><span class=
"br0">)</span>
283 <span class=
"br0">(</span>for-each
284 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>attrib
<span class=
"br0">)</span>
285 <span class=
"br0">(</span>set-attrib-value
<span class=
"sy0">!
</span> attrib
<span class=
"kw1">value
</span><span class=
"br0">)</span><span class=
"br0">)</span>
286 <span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
290 Использование процедуры в
<strong>gschem
</strong>:
292 <pre class=
"code lisp"><span class=
"br0">(</span>set-selected-attribs-value
<span class=
"sy0">!
</span> <span class=
"st0">"R100.?
"</span><span class=
"br0">)</span> </pre>
295 Теперь, после изменения их номеров с помощью
<kbd>T
</kbd> <kbd>U
</kbd>, вы
296 копируете их все и хотите переименовать эти скопированные резисторы, добавив
300 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=8" title=
"Download Snippet" class=
"mediafile mf_scm">append-selected-attribs-suffix.scm
</a></dt>
301 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>gschem selection
<span class=
"br0">)</span><span class=
"br0">)</span>
303 <span class=
"br0">(</span>define
<span class=
"br0">(</span>append-selected-attribs-suffix
<span class=
"sy0">!
</span> suffix
<span class=
"br0">)</span>
304 <span class=
"br0">(</span>for-each
305 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>attrib
<span class=
"br0">)</span>
306 <span class=
"br0">(</span>set-attrib-value
<span class=
"sy0">!
</span>
308 <span class=
"br0">(</span>string-append
<span class=
"br0">(</span>attrib-value attrib
<span class=
"br0">)</span> suffix
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
309 <span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
313 Использование процедуры в
<strong>gschem
</strong>:
315 <pre class=
"code lisp"><span class=
"br0">(</span>append-selected-attribs-suffix
<span class=
"sy0">!
</span> <span class=
"st0">"-top
"</span><span class=
"br0">)</span> </pre>
318 Теперь переименуем несколько других атрибутов, добавив префикс:
321 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=10" title=
"Download Snippet" class=
"mediafile mf_scm">append-selected-attribs-prefix.scm
</a></dt>
322 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>gschem selection
<span class=
"br0">)</span><span class=
"br0">)</span>
324 <span class=
"br0">(</span>define
<span class=
"br0">(</span>append-selected-attribs-prefix
<span class=
"sy0">!
</span> prefix
<span class=
"br0">)</span>
325 <span class=
"br0">(</span>for-each
326 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>object
<span class=
"br0">)</span>
327 <span class=
"br0">(</span><span class=
"kw1">and
</span> <span class=
"br0">(</span>attribute? object
<span class=
"br0">)</span>
328 <span class=
"br0">(</span>set-attrib-value
<span class=
"sy0">!
</span>
330 <span class=
"br0">(</span>string-append prefix
<span class=
"br0">(</span>attrib-value object
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
331 <span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
335 Использование процедуры в
<strong>gschem
</strong>:
337 <pre class=
"code lisp"><span class=
"br0">(</span>append-selected-attribs-prefix
<span class=
"sy0">!
</span> <span class=
"st0">"A1.
"</span><span class=
"br0">)</span> </pre>
340 Давайте заменим первые буквы выделенных атрибутов префиксом:
343 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=12" title=
"Download Snippet" class=
"mediafile mf_scm">append-selected-attribs-prefix.scm
</a></dt>
344 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>gschem selection
<span class=
"br0">)</span><span class=
"br0">)</span>
346 <span class=
"br0">(</span>define
<span class=
"br0">(</span>replace-selected-attribs-prefix
<span class=
"sy0">!
</span> prefix
<span class=
"br0">)</span>
347 <span class=
"br0">(</span>for-each
348 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>object
<span class=
"br0">)</span>
349 <span class=
"br0">(</span><span class=
"kw1">and
</span> <span class=
"br0">(</span>attribute? object
<span class=
"br0">)</span>
350 <span class=
"br0">(</span>set-attrib-value
<span class=
"sy0">!
</span>
352 <span class=
"br0">(</span>string-append
354 <span class=
"br0">(</span>string-copy
<span class=
"br0">(</span>attrib-value object
<span class=
"br0">)</span> <span class=
"nu0">1</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
355 <span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
359 Использование процедуры в
<strong>gschem
</strong>:
361 <pre class=
"code lisp"><span class=
"br0">(</span>replace-selected-attribs-prefix
<span class=
"sy0">!
</span> <span class=
"st0">"C
"</span><span class=
"br0">)</span> </pre>
364 Давайте переименуем выделенные атрибуты
<code>netname=
</code>, увеличив их значения
365 на определённое число:
368 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=14" title=
"Download Snippet" class=
"mediafile mf_scm">add-selected-attribs-number.scm
</a></dt>
369 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>gschem selection
<span class=
"br0">)</span><span class=
"br0">)</span>
371 <span class=
"br0">(</span>define
<span class=
"br0">(</span>add-selected-attribs-number
<span class=
"sy0">!
</span> number
<span class=
"br0">)</span>
372 <span class=
"br0">(</span>for-each
373 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>object
<span class=
"br0">)</span>
374 <span class=
"br0">(</span><span class=
"kw1">and
</span> <span class=
"br0">(</span>attribute? object
<span class=
"br0">)</span>
375 <span class=
"br0">(</span>set-attrib-value
<span class=
"sy0">!
</span>
377 <span class=
"br0">(</span>number-
<span class=
"sy0">></span>string
378 <span class=
"br0">(</span>+
<span class=
"br0">(</span>string-
<span class=
"sy0">></span>number
<span class=
"br0">(</span>attrib-value object
<span class=
"br0">)</span><span class=
"br0">)</span> number
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
379 <span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
383 Использование процедуры в
<strong>gschem
</strong>:
385 <pre class=
"code lisp"><span class=
"br0">(</span>add-selected-attribs-number
<span class=
"sy0">!
</span> <span class=
"nu0">100</span><span class=
"br0">)</span> </pre>
388 Мы могли бы задать любую функцию вместо
"+
" для номера соединения в этой
392 <dt><a href=
"/./doku.php?do=export_code&id=:geda:guile_scripting.ru.txt&codeblock=16" title=
"Download Snippet" class=
"mediafile mf_scm">use-another-func.scm
</a></dt>
393 <dd><pre class=
"code file lisp"><span class=
"br0">(</span>use-modules
<span class=
"br0">(</span>gschem selection
<span class=
"br0">)</span><span class=
"br0">)</span>
395 <span class=
"br0">(</span>define
<span class=
"br0">(</span>use-another-func
<span class=
"sy0">!
</span> func
<span class=
"br0">)</span>
396 <span class=
"br0">(</span>for-each
397 <span class=
"br0">(</span><span class=
"kw1">lambda
</span> <span class=
"br0">(</span>object
<span class=
"br0">)</span>
398 <span class=
"br0">(</span><span class=
"kw1">and
</span> <span class=
"br0">(</span>attribute? object
<span class=
"br0">)</span>
399 <span class=
"br0">(</span>set-attrib-value
<span class=
"sy0">!
</span>
401 <span class=
"br0">(</span>number-
<span class=
"sy0">></span>string
402 <span class=
"br0">(</span>func
<span class=
"br0">(</span>string-
<span class=
"sy0">></span>number
<span class=
"br0">(</span>attrib-value object
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span>
403 <span class=
"br0">(</span>page-selection
<span class=
"br0">(</span>active-page
<span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"br0">)</span></pre>
407 Использование процедуры в
<strong>gschem
</strong>:
409 <pre class=
"code lisp"><span class=
"br0">(</span>use-another-func
<span class=
"sy0">!
</span> -
<span class=
"br0">)</span>
410 <span class=
"br0">(</span>define
<span class=
"br0">(</span>multiply-by-
<span class=
"nu0">2</span> x
<span class=
"br0">)</span>
411 <span class=
"br0">(</span>*
<span class=
"nu0">2</span> x
<span class=
"br0">)</span><span class=
"br0">)</span>
412 <span class=
"br0">(</span>use-another-func
<span class=
"sy0">!
</span> multiply-by-
<span class=
"nu0">2</span><span class=
"br0">)</span></pre>