# Multiple Spot Coordinates

**URL:** <https://forum.dynamobim.com/t/multiple-spot-coordinates/40410>\
**Category:** Developers\
**Tags:** python\
**Created:** [September 6, 2019, 4:26pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410 "2019-09-06T16:26:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![quagliatol](https://avatars.discourse-cdn.com/v4/letter/q/edb3f5/32.png) [@quagliatol](https://forum.dynamobim.com/u/quagliatol)\
**Post date:** [September 6, 2019, 4:26pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/1 "2019-09-06T16:26:06Z")

</div>

Hello,

I’m trying to tag a floor in my view with multiple Spot Coordinates.

I haven’t found this in any other post except here: [Spot coordinates](https://forum.dynamobim.com/t/spot-coordinates/27910/9)

But that doesn’t work for multiple points.  
It’s giving me this error:  
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
Traceback (most recent call last):  
File “”, line 20, in   
AttributeError: ‘List[object]’ object has no attribute ‘ToXyz’

 ![Inputs](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/6/16b8e7efd6400e750fcbbf2754f2cc91fb61d666.png)

I know @fluffyhugger mentioned how you could make it work for multiple inputs, but I’m not good enough at Python to get it to work.

Any help would be appreciated.  
Thanks!  
Lynn

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [September 6, 2019, 4:32pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/2 "2019-09-06T16:32:28Z")

</div>

Hi @quagliatol

Could you drop here rvt file and dyn file?

---

<div class="post-metadata">

**Author:** ![quagliatol](https://avatars.discourse-cdn.com/v4/letter/q/edb3f5/32.png) [@quagliatol](https://forum.dynamobim.com/u/quagliatol)\
**Post date:** [September 6, 2019, 4:34pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/3 "2019-09-06T16:34:45Z")

</div>

Because of the complication of the script and file, it’ll be kind of hard to make an example file. 😕

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 6, 2019, 4:46pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/4 "2019-09-06T16:46:56Z")

</div>

Unfortunately it’s something that’s needed to help. ☹

---

<div class="post-metadata">

**Author:** ![quagliatol](https://avatars.discourse-cdn.com/v4/letter/q/edb3f5/32.png) [@quagliatol](https://forum.dynamobim.com/u/quagliatol)\
**Post date:** [September 6, 2019, 5:09pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/5 "2019-09-06T17:09:42Z")

</div>

I was hoping we could figure it out as a general Python question.

Here’s the code:

> [@Spot coordinates](https://forum.dynamobim.com/t/spot-coordinates/27910/9):
>
> ```auto
> import clr
> clr.AddReference('RevitAPI')
> from Autodesk.Revit.DB import *
> 
> clr.AddReference("RevitNodes")
> import Revit
> clr.ImportExtensions(Revit.GeometryConversion)
> 
> clr.AddReference("RevitServices")
> import RevitServices
> from RevitServices.Persistence import DocumentManager
> from RevitServices.Transactions import TransactionManager
> 
> doc = DocumentManager.Instance.CurrentDBDocument
> 
> v = UnwrapElement(IN[2])
> r = UnwrapElement(IN[0])
> p = UnwrapElement(IN[1]).ToXyz()
> o = UnwrapElement(IN[3]).ToXyz()
> n = UnwrapElement(IN[4]).ToXyz()
> 
> TransactionManager.Instance.EnsureInTransaction(doc)
> 
> e = []
> 
> e.append(doc.Create.NewSpotCoordinate(v, FamilyInstance.GetReferenceByName(r,"Center (Left/Right)"), p, o, n, p, True))
> 
> TransactionManager.Instance.TransactionTaskDone()
> 
> OUT = e
> 
> ```

Inputs p, o and n would need to have a list of points (instead of a single point) as inputs.

Sorry it would take me a while to replicate this in a new project and Dynamo script!

---

<div class="post-metadata">

**Author:** ![quagliatol](https://avatars.discourse-cdn.com/v4/letter/q/edb3f5/32.png) [@quagliatol](https://forum.dynamobim.com/u/quagliatol)\
**Post date:** [September 6, 2019, 8:39pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/6 "2019-09-06T20:39:21Z")

</div>

Well I tried to get the Python code to work with multiple points.

```
# editted code originally from https://forum.dynamobim.com/t/spot-coordinates/27910/9

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

v = UnwrapElement(IN[2])
r = UnwrapElement(IN[0])

inpoints = UnwrapElement(IN[1])
inbends = UnwrapElement(IN[3])
inends = UnwrapElement(IN[4])

TransactionManager.Instance.EnsureInTransaction(doc)

# make points XYZ

pointsxyz = []
bends = []
ends = []

for a in inpoints:
	g = a.ToXyz()
	pointsxyz.append(g)

for b in inbends:
	h = b.ToXyz()
	bends.append(h)

for c in inends:
	i = c.ToXyz()
	ends.append(i)

# floor edit

re = Reference(r)

# annotate
	
outanno = []

for d, e, f in zip(pointsxyz, bends, ends):
	outanno.append(doc.Create.NewSpotCoordinate(v, re, d, e, f, d, True))

TransactionManager.Instance.TransactionTaskDone()

OUT = outanno

```

Please excuse the awfully-formatted Python.

I think this should work but it’s giving me this error:

`Exception: Error occurred when creating Spot Dimension!`

If anyone knows how to fix this, please let me know!

---

<div class="post-metadata">

**Author:** ![cgartland](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/cgartland/32/45378_2.png) [@cgartland](https://forum.dynamobim.com/u/cgartland)\
**Post date:** [September 6, 2019, 9:40pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/7 "2019-09-06T21:40:10Z")

</div>

I would suggest giving more meaningful names to your variables. It looks like the code is minified, which makes it very hard to follow and debug.

---

<div class="post-metadata">

**Author:** ![fluffyhugger](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/fluffyhugger/32/54396_2.png) [@fluffyhugger](https://forum.dynamobim.com/u/fluffyhugger)\
**Post date:** [September 7, 2019, 11:35am UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/8 "2019-09-07T11:35:02Z")

</div>

If I may elaborate on behalf of @Kulkul and @jacob.small , most people asking here for help are field professionals and understandably can’t share the files on which they working (I’ve been there myself). But what many people don’t really think about is that in order to help, there has to be a complete problem definition. Because the root of the it is not always where one think it is. That’s why to help there has to be the whole outline. A small screenshot of a section of a script is not enough to go about. So for the future, just make a sample that replicates your issue and share that.

Dear colleagues if I got anything wrong, please correct me.

For this specific problem, it seems to be issue of `Reference` . If you replicate the code with singular input it says:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/0/70d8a1b996ca50368482695cae04fa4035fd2f1c.png)

`FamilyInstance.GetReferenceByName` doesn’t work on system families. I myself really don’t know how to solve it.

---

<div class="post-metadata">

**Author:** ![fluffyhugger](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/fluffyhugger/32/54396_2.png) [@fluffyhugger](https://forum.dynamobim.com/u/fluffyhugger)\
**Post date:** [September 9, 2019, 6:32am UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/9 "2019-09-09T06:32:04Z")

</div>

@quagliatol since nobody rushes to explain why `Recerence` method doesn’t work, here’s some workaround for floors and system families and for the matter any geometry in general.

Create a generic model family with small circle as model line and make is invisible. Load it in to your project. Now you have a geometrie instance that has coordinates and is invisible but can be spotted. Place it at desired place and elevation and use the original script. To make the script work on multiple inputs wrap it in a costume node (`File` -\> `New` -\> `Custom node..`). Make something like the following:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/4/545a88f306404ebaaceb66e7b60587a6088de10d.png)

Now to make it work just make sure you feed all inputs as 1 dimensional lists (so just items 1,2,3…n). I had to use `List.Combine` as shown below to make it work. And it did. Hope it helps.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/3/f31f4487f0afc7d68c4c4e4824ddad56fd1b85c7.png)

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [September 9, 2019, 7:58pm UTC](https://forum.dynamobim.com/t/multiple-spot-coordinates/40410/10 "2019-09-09T19:58:54Z")

</div>

Hi @quagliatol,

The Reference needs to be a geometric reference, which you need to get from the floor object. See below for a, quick and dirty, example for a single Floor object:

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/9/b9aa4a3a53daad8b8a4400f862c640a8d8a15537.png)

Python script:

```
import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#---###Start scripting here:###---#
floor = UnwrapElement(IN[0])
refPts = [i.ToXyz() for i in IN[1]]
view = doc.ActiveView

opts = Options()
opts.ComputeReferences = True

floorSolid = floor.get_Geometry(opts)
plFaces = [i.Faces for i in floorSolid][0]
upFace = None
for i in plFaces:
	normal = i.FaceNormal
	if normal.Z == 1:
		upFace = i

ref = upFace.Reference
		
#Transaction start:
TransactionManager.Instance.EnsureInTransaction(doc)
spotElev = []
for i in refPts:
	spotElev.append(doc.Create.NewSpotElevation(view, ref, i, i, i, i, False))
#Transaction end:
TransactionManager.Instance.TransactionTaskDone()

OUT = spotElev
```
