On Oct 19, 3:57 am, Robert Ross <
robert.2.r...@gmail.com> wrote:
> Excellent, thank you very much Darcy! This works perfectly.
>
> Let me just check I'm understanding what's going on:
> ... ...
> >>> ds.Beams[i].Blocks = Sequence([ds1])
>
> adds a Block Sequence and sets it equal to the dataset which has been
> cast to a sequence
What you said is all correct, except the "dataset cast to a sequence"
is a strange way to say it, so just to make sure it is clear: the last
line creates a python list, with one item in it (a dataset ds1), and
then converts that to a Sequence (which is really just a python list
with a little bit of functionality added).
If there had been two items in the sequence, then there would have
been something like this in addition to the previous lines:
>>> ds2 = Dataset()
>>> ds2.BlockType = '...' etc
>>> ds.Beams[i].Blocks = Sequence([ds1, ds2])
In fact, since this is a nice tidy example, I think I'll add that to
the wiki to show how to do this kind of operation.
By the way, the Sequence above is just an object, and the Blocks data
element is set to it by reference, so any further appending to the
list etc will be reflected in the contents of that sequence. In other
words, you don't have to assign the SQ item fully formed as shown
here; it could be initialized and then items appended as you go.
Cheers,
Darcy