hi i am trying to add an element to an assembly.
but am failing to create an ICollection.
how do i create one?
<div class=“comment-body”>
here is my code:
i am getting error after error as i don’t know how to build a collection???
dataEnteringNode = IN
assemblies=UnwrapElement(IN[0])
elements=UnwrapElement(IN[1])
for i in range(0,len(assemblies)):
elemlist=[]
elemlist.append(elements[i].Id)
assemblies[i].AddMemberIds(elemlist)
OUT = assemblies
</div>
Hey Peter,
Just to check, did you create your assemblies in the same script? From the API guide:
“The static Create() method of the AssemblyInstance class is used to create a new assembly instance in the project. The Create() method must be created inside a transaction and the transaction must be committed before performing any action on the newly created assembly instance.”
If it is a committed assembly, then maybe try the following:
![2015-02-26_114846](//cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/4/4a8ac90ae67c780d36fedc6ceb269f07e8619989.jpg)
Dimitar thannk you, that really helped a lot.
didn’t know that a collection is that easy to build…
tx peter
Technically the method doesn’t build a collection, but an IList (which is a .NET derivative, i.e. the Iron part in IronPython) that has identical properties to an ICollection. I found it easier to translate the python list into an IList than to an ICollection.
I’m still trying to wrap my head around all the different containers. I found some more info about the multitude of containers in .NET here:
http://blogs.msdn.com/b/kcwalina/archive/2005/09/23/collections.aspx
cool, i will study that tonight, tx again!