Placing Model group at multiple points

Hello to everyone…

I have found this code in other topic.

Topic

I´m trying to place modelgroups at multiple points.

The python issue is telling me that the line 28 is expected to get some xyz points and I am giving strings.
I have read that I can try with some Orchid´s node to get xyz points but I´m working with Dynamo 1.3.4.6666 and it doesn´t work anymore.

Can someone help me with this problem?

Hi @alejandre,

You need to convert your Dynamo points to Revit points. You can do this by using the ToXyz() method like this:

groups = doc.Create.PlaceGroup(l.ToXyz(), grouptype)

Edit: Read more about it here

Hi @MartinSpence

Thank you very much for your response.
I have tried it, but still not working. Now i have other issue:

Traceback (most recent call last):
File “”, line 28, in
AttributeError: ‘List[object]’ object has no attribute ‘ToXyz’

The problem is that… I don´t have any idea about Python…

It’s because you are feeding a list of list of points to the python node. If you want to keep the list structure, you need to accodate this within your looping.

Otherwise you need to use the output of the flatten node instead:

I´m doing something wrong?
:sleepy:

Traceback (most recent call last):
File “”, line 28, in
AttributeError: ‘Point’ object has no attribute ‘ToXyz’

Well… I get the Revit Points with a Python Code but still not working.

Now I have the next issue:

Traceback (most recent call last):
File “”, line 28, in
TypeError: expected GroupType, got List[object]

If you are placing a group type at each point position i would make the following changes to your code.

Add a new line after 22 and put the following along it
Count = 0

On line 28 make grouptype the following grouptype[count]

Add a new line after line 29 and add the following
Count = Count + 1

1 Like

You can do what @Brendan_Cassidy suggested or if you match the group list with the number of points, you can use zip() to “match” group and point.

So the iteration would be something like:

Transaction start:
for l, g in zip(location, grouptype):
    a.append(doc.Create.PlaceGroup(l.ToXyz(), g))
Transaction end.
2 Likes

Hi @MartinSpence and @Brendan_Cassidy!!!

Thank you very much to both of you for the response and your solutions.

I have find my own way to place the modelgroups.
I have modify the python script to the next one:

import clr
import math
clr.AddReference(“ProtoGeometry”)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import *

def tolist(obj1):
if hasattr(obj1,“iter”): return obj1
else: return [obj1]

grps = tolist(IN[0])
locs = tolist(IN[1])
outList =

i = 0

if len(grps) == len(locs):
for grp in grps:
g = UnwrapElement(grp)
loc = locs[i].ToRevitType(True)
TransactionManager.Instance.EnsureInTransaction(doc)
newGrp = doc.Create.PlaceGroup(loc, g)
outList.append(newGrp)
TransactionManager.Instance.TransactionTaskDone()
i = i+1
else:
if len(grps) == 1:
for l in locs:
g = UnwrapElement(grps[0])
loc = l.ToRevitType(True)
TransactionManager.Instance.EnsureInTransaction(doc)
newGrp = doc.Create.PlaceGroup(loc, g)
outList.append(newGrp)
TransactionManager.Instance.TransactionTaskDone()
else:
outList.append(“Could not Create Groups. Please check your inputs”)

OUT = outList

It works perfectly with point,bvcoordinates as you can see in the next pic.

I hope it can be useful for other people. Thank you for your collaboration.

1 Like