# FamilyInstance.ByCoords - Op fails / object not valid?

**URL:** <https://forum.dynamobim.com/t/familyinstance-bycoords-op-fails-object-not-valid/12548>\
**Category:** Revit\
**Tags:** revit\
**Created:** [June 19, 2017, 6:25am UTC](https://forum.dynamobim.com/t/familyinstance-bycoords-op-fails-object-not-valid/12548 "2017-06-19T06:25:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian\_Esdaile](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/adrian_esdaile/32/28599_2.png) [@Adrian\_Esdaile](https://forum.dynamobim.com/u/Adrian_Esdaile)\
**Post date:** [June 19, 2017, 6:25am UTC](https://forum.dynamobim.com/t/familyinstance-bycoords-op-fails-object-not-valid/12548/1 "2017-06-19T06:25:12Z")

</div>

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/6/a6bb5995feb72200ed44e8b9e4734dd46b683085.PNG)

See image: I’m trying to place a list of Families, passing the list to FamilyInstance.ByCoodinates

To keep things simple for this example, I’m ignoring my coordinates, and just using the default of 0,0,0

The families are definitely Point-type families, the list filtering you can partially see takes care of that.

The objects are correct - they are Revit.Element.FamilyType which is what the FamilyInstance.ByCoordinates expects as input.

However - there’s that error! _Referenced Object is not valid._

I’m at a loss - the only thing I can think of is that I’m working at the Family (RFA) level - my open Document is a Family; and I’m trying to automatically place subfamilies from a predetermined list in predetermined locations. It’s all read from an Excel file, but as you can see, the Families _are there_ and are being recognized as FamilyTypes.

I’ve tried all kinds of List Lacing, that has no effect (it shows Longest in image)

Does anyone have any idea what I’m doing wrong here?

EDIT:

It suddenly works, but I have NO IDEA what I did that suddenly made it work. I think I might have opened the Dynamo Script after the Family RFA file; would this make a difference? Even though Dynamo said it was connected to the currently open file and was reporting it correctly?

---

<div class="post-metadata">

**Author:** ![zhukoven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/zhukoven/32/70962_2.png) [@zhukoven](https://forum.dynamobim.com/u/zhukoven)\
**Post date:** [June 19, 2017, 7:06am UTC](https://forum.dynamobim.com/t/familyinstance-bycoords-op-fails-object-not-valid/12548/2 "2017-06-19T07:06:44Z")

</div>

> [@Adrian\_Esdaile](#):
>
> I think I might have opened the Dynamo Script after the Family RFA file; would this make a difference?

@Adrian_Esdaile, this makes sense if you’re switching between Project & Family editor environments. They are completely different. So be sure to open your graph after opening the Revit document.

---

<div class="post-metadata">

**Author:** ![Adrian\_Esdaile](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/adrian_esdaile/32/28599_2.png) [@Adrian\_Esdaile](https://forum.dynamobim.com/u/Adrian_Esdaile)\
**Post date:** [June 19, 2017, 7:23am UTC](https://forum.dynamobim.com/t/familyinstance-bycoords-op-fails-object-not-valid/12548/3 "2017-06-19T07:23:47Z")

</div>

@zhukoven, Thanks for the reply - yes I think that’s it.

I’m trying to build a system that can essentially ‘copy’ a family from a Revit Project into a Family file - something that cannot be done either in Revit, or the API.

I’m taking the location & rotation of a family, relative to a room; copying that info to an Excel file, then loading that data into a Family.

I’ve got the first part working - exporting tablular data, reading it, pre-loading the right subfamilies, but I’m having trouble with the placing in the Instances. It seems that the location / rotation data stored at the Project level doesn’t reflect the true location / rotation transformation of the family (annoyingly), so I’ll have to look at other ways to record the spatial relationship between objects

---

<div class="post-metadata">

**Author:** ![zhukoven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/zhukoven/32/70962_2.png) [@zhukoven](https://forum.dynamobim.com/u/zhukoven)\
**Post date:** [June 19, 2017, 8:11am UTC](https://forum.dynamobim.com/t/familyinstance-bycoords-op-fails-object-not-valid/12548/4 "2017-06-19T08:11:01Z")

</div>

> [@Adrian\_Esdaile](#):
>
> It seems that the location / rotation data stored at the Project level doesn’t reflect the true location / rotation transformation of the family (annoyingly), so I’ll have to look at other ways to record the spatial relationship between objects

@Adrian_Esdaile, Family document has its own fixed orientation, that could be reached by the “FamilyInstance.FacingOrientation” node. Resulting vector is relative to Revit project in which the family is placed, so that it could be used to get the actual family rotation angle (“Vector.AngleAboutAxis”). Then the angle may be transferred to the “FamilyInstance.SetRotation” node inside the Family document via Excel.
