Thank you for reaching out and sharing your experience.
I understand your frustration and appreciate your patience. Many of our connectors handle the complex task of translating database graph data into a format usable by various applications. The specifics of what you aim to extract from the raw data will influence the best approach to traverse it.
Given that you’re new to Python, I don’t want to overwhelm you with too much detail at once. Knowing more about what you’re trying to achieve and why would be helpful. This way, I can provide the most relevant and straightforward guidance.
@Jedd gave a great talk at SpeckleCon23 about the nature of data in Speckle, and consequently, it isn’t straightforward to point to the URL and create a table, say.
We include a helper function in every Speckle Automate function template that can get you started.
def flatten_base(base: Base) -> Iterable[Base]:
"""Flatten a base object into an iterable of bases.
This function recursively traverses the
`elements` or `@elements` attribute of the
base object, yielding each nested base object.
Args:
base (Base): The base object to flatten.
Yields:
Base: Each nested base object in the hierarchy.
"""
# Attempt to get the elements attribute,
elements = getattr(base, "elements",
getattr(base, "@elements", None)) # fallback to @elements
if elements is not None:
for element in elements:
yield from flatten_base(element)
yield base
This may not be ideal, and I’m happy to work with you on something more appropriate, but this does give you a flat list of all the Speckle Base objects in a given version commit.
Calling this function will be as simple as following up the transport retrieved from earlier with:
# Receive the object
received_base = operations.receive(obj_id=refObj, remote_transport=transport)
element_list = flatten_base(received_base)
This will give you a flat list of all the Speckle Base objects in the commit. From there, you can filter or manipulate the data as needed. It’s not the end of the story as a Revit dataset can include instances of types and other complications (which we can overcome)
I gave a talk at BILT earlier this month that rapidly goes step-by-step through a Revit dataset that might be interesting to you… but apologies again if this is a Python too far right now: GitHub - specklesystems/automate-function-bilt-workshop