[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA: Getting pins from components . . . .
Hi Stuart,
>> void
>> traverse_component(TOPLEVEL* pr_current, OBJECT* component)
>> {
>> OBJECT* o_current = component->complex->prim_objs;
This above line is very important.
[snip]
>OK, using this method to find the *first* pin works. HOwever, when do
>I know to terminate the loop? That is, o_current is just a long,
>unstructured list of graphical objects on the schematic, right?
object_head/object_tail is not that completely unstructured.
The list which is component->complex->prim_objs is just the list of
objects which are part of a component, including the pins, text, lines,
etc...
>Therefore, if I just loop to o_current->next, I am just at another
>graphical object on the schematic. Eventually I will find another
>OBJ_PIN, but there is no garuantee that this OBJ_PIN is attached to my
>component, right?
Nope :) There is a guarantee that all objects contained within
complex->prim_objs are part of the component. You will not find other
component's pins in this list (unless something has gone very very
very wrong).
>How do I know when to terminate the loop while looking for pins? Is
When o_current is null.
>there a libgeda fcn which returns a list of pins attached to a complex?
No, there is no such function since the above code should work
just fine. Let me know if it doesn't.
>Maybe I should implement your second suggestion. . . . .
Option #2 is more convoluted, but the only option if you are
starting from the reverse (i.e. from a pin object and need the component).
From what you have told me, you are starting at the component live and
drilling down.
Hope that helps, if not... you know where to find me.
-Ales