www.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2016/01/04/16:22:00

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Date: Mon, 4 Jan 2016 22:21:44 +0100 (CET)
From: Roland Lutz <rlutz AT hedmen DOT org>
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] Howto make a script in gaf (Was should we broaden
scope of libgeda)
In-Reply-To: <568AC643.10807@ecosensory.com>
Message-ID: <alpine.DEB.2.11.1601042155190.12463@newt>
References: <20160102091556 DOT BBC6D809D79B AT turkos DOT aspodata DOT se> <CAMvDHVAoAnt3g6JBvgbnrR53LG6KpzWKBTmQgo1j+7ERvbESpg AT mail DOT gmail DOT com> <20160103192006 DOT 1FBFE809D79B AT turkos DOT aspodata DOT se> <alpine DOT DEB DOT 2 DOT 11 DOT 1601032244500 DOT 1697 AT newt> <568AC643 DOT 10807 AT ecosensory DOT com>
User-Agent: Alpine 2.11 (DEB 23 2013-08-11)
MIME-Version: 1.0
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019