Assemblies "ICollection"


#1

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>


#2

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


#3

Dimitar thannk you, that really helped a lot.

didn’t know that a collection is that easy to build…

tx peter


#4

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:


#5

cool, i will study that tonight, tx again!


#6

if it helps, same topic:

 

http://dynamobim.com/forums/topic/dynamo-and-python-nodes-icollection/