Mail Archives: geda-user/2016/01/04/16:22:00
On Mon, 4 Jan 2016, John Griessen wrote:
> On 01/04/2016 12:33 PM, Roland Lutz wrote:
>> >>> sch = xorn.geda.read.read('logo_1.sch')
>>
>> After loading a schematic file, you could, for example, print all objects:
>
> Seems really good. You can sift through all ob.data() for attribs, right?
ob.data() is just a record which contains the object's parameters. For a
component object, it's a xorn.storage.Component instance which is the
Python equivalent of the C struct xornsch_component:
struct xornsch_component {
struct xorn_double2d pos;
bool selectable;
int angle;
bool mirror;
struct xorn_pointer symbol;
};
You can get a list of attributes by calling ob.attached_objects(), or you
can use the high-level attribute functions from the module
"xorn.geda.attrib" to query an attribute:
>>> import xorn.geda.attrib
>>> for ob in sch.toplevel_objects():
... if isinstance(ob.data(), xorn.storage.Component):
... print xorn.geda.attrib.search_attached(ob, 'refdes')
...
['U109']
[]
['U212']
['U211']
['U210']
[]
[]
[]
If you loaded the schematic including the symbols, you could use
"search_all" instead of "search_attached" to search the inherited
attributes, too:
>>> xorn.geda.attrib.search_all(sch.toplevel_objects()[0], 'refdes')
['U109', 'U?']
For a more detailed description of the xorn.geda.attrib module, see:
http://hedmen.org/xorn/doc/api/html/namespacexorn_1_1geda_1_1attrib.html
For a description of the storage API, see:
http://hedmen.org/xorn/doc/api/html/namespacexorn_1_1storage.html
- Raw text -