# Set position for a window with Dynamo

**URL:** <https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748>\
**Category:** Revit\
**Created:** [April 24, 2020, 2:41pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748 "2020-04-24T14:41:47Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [April 24, 2020, 2:41pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/1 "2020-04-24T14:41:47Z")

</div>

I want to create a Dynamo custom node for a default Fixed window Family named 16" x 48".  
This is added to a default Wall.  
The input data for the window is the point on the default wall and the height where is place window.  
I try to get the Family window fixed 16" x 48" use with FamilyInstance.ByPoint but this not solve my issue.

---

<div class="post-metadata">

**Author:** ![patrick\_podeyn](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/patrick_podeyn/32/86368_2.png) [@patrick\_podeyn](https://forum.dynamobim.com/u/patrick_podeyn)\
**Post date:** [April 24, 2020, 3:43pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/2 "2020-04-24T15:43:02Z")

</div>

@catafest

Can you post an image of your graph or the graph itself and the file you’re working with?

---

<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:** [April 24, 2020, 10:51pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/3 "2020-04-24T22:51:45Z")

</div>

One way to do this:

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

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [April 28, 2020, 11:05am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/4 "2020-04-28T11:05:28Z")

</div>

I use default Revit family Type nodes.  
@jacob.small I cannot use the Spring Nodes in my project … I need to use basic nodes.  
@patrick_podeyn Is a default homework for Dynamo to add a models familly: door into a wall.  
Thank’s for help.

---

<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:** [April 28, 2020, 11:36am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/5 "2020-04-28T11:36:58Z")

</div>

In that case you will need to dive into the Revit API. Look into family by host methods.

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [April 28, 2020, 2:01pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/6 "2020-04-28T14:01:58Z")

</div>

I try another way  
… using a Fixed Door and I’m able to change the position using the data from a CSV file.  
The problem now is this:  
When I add the model Door Family the Wall category is cut, then when I change the position of the Door the cut area remains in the Wall into the last position where the Door is added for the first time.  
See my screenshot:  
 ![cut_door](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/3/53c60643f4f98bb6e57ddb4bbea65806b988b59b.png)

---

<div class="post-metadata">

**Author:** ![patrick\_podeyn](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/patrick_podeyn/32/86368_2.png) [@patrick\_podeyn](https://forum.dynamobim.com/u/patrick_podeyn)\
**Post date:** [April 28, 2020, 2:19pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/7 "2020-04-28T14:19:16Z")

</div>

When you run an operation that places or creates elements within Revit, and you move the location point within Dynamo after your first run, it creates a new elements in some cases. To be on the safe side, if you are moving points after running the first time, undo in Revit prior to running the graph with new points and disconnect a wire that fulfills that creation node to sort of reset it. Then you can reconnect the wire and run again with the new points. That’s what I imagine might be causing the error.

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [April 28, 2020, 3:08pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/8 "2020-04-28T15:08:09Z")

</div>

@patrick_podeyn no, is not an error , I think I don’t set the cuting nodes for these two geometry’s into my Dynamo file. I don’t know how can I do it and if this step is necessary. I think the first add of Door cut automatically the wall and the next reposition of my Door not cut the Wall and remain to the first one.

---

<div class="post-metadata">

**Author:** ![patrick\_podeyn](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/patrick_podeyn/32/86368_2.png) [@patrick\_podeyn](https://forum.dynamobim.com/u/patrick_podeyn)\
**Post date:** [April 28, 2020, 3:10pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/9 "2020-04-28T15:10:57Z")

</div>

As Jacob mentioned previously then, you’ll need to build a python script to that uses the Revit API call to place a family that requires a point, host and family type if custom packages are not applicable.

Aussie BIM Guru just launched helpful tutorial videos on his youtube about working with Python and the Revit API.

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [May 5, 2020, 10:58am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/10 "2020-05-05T10:58:55Z")

</div>

I search on the web and I did not find a script to cut the wall with a _FamilyInstance_…  
I can set the parameter of _Element.SetParameterByName_ for _Head Height_ and this allows me to make some changes for **the door 🚪 or window**.  
Into this moment, I used a CSV file and I read the FamilyTypes - and I used the **FamilyType.ByFamilyNameAndTypeName** and is not render … just a point into 3D .  
Maybe it cannot be used without **drag and drop into Revit - where the wall is automatically cut by door**.  
I cannot use packages like Spring, is not allowed by the project manager.

Can you provide a script example for this issue (link, video tutorial) that **use the Dynamo to show a wall and door and makes the cut wall to render into Revit properly**?

Thank you. Best regards.

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [May 6, 2020, 11:53am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/11 "2020-05-06T11:53:44Z")

</div>

Hi!

you have to use an overload of API method - NewFamilyInstance.  
Check the script below. I calculate a midpoint of the wall but you can provide any other location.

```
import clr

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

clr.AddReference("RevitServices")
import RevitServices

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
#The inputs to this node will be stored as a list in the IN variables.
host = UnwrapElement(IN[0])
familyType = UnwrapElement(IN[1])

lc = host.Location.Curve

p0 = lc.GetEndPoint(0)
p1 = lc.GetEndPoint(1)
m = p0 + 0.5*(p1-p0)

d = (p1-p0).CrossProduct(XYZ(0,0,1))

TransactionManager.Instance.EnsureInTransaction(doc)
fi = doc.Create.NewFamilyInstance(m, familyType, d, host, StructuralType.NonStructural)
TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = fi
```

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [May 6, 2020, 2:44pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/12 "2020-05-06T14:44:01Z")

</div>

I understand your script is simple.  
I add + another input to go to the next line where is need to link with the and comes with this warning:

```
  Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
  Traceback (most recent call last):
  File "<string>", line 20, in <module>
  AttributeError: 'NoneType' object has no attribute 'Location'

```

I think it needs an element with location output and link it with IN.

_The main problem I cannot add the wall or door/window from Revit._

I need to **add it to Revit from the Dynamo DYN file type** , and now I’m testing with a CSV file.

I used and CSV file type with the name of Family Name and Type with point coordinate … and I try to use it with **FamilyType.ByFamilyNameAndTypeName**

You can see, is not drawing the door/window and the script does not want to get the point location …  
 ![error_forum](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/b/4ba69a7df49125eae60a878fe7c630d1c1f430b0.png)

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [May 6, 2020, 4:03pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/14 "2020-05-06T16:03:57Z")

</div>

You have to specify the host for the method to work.  
If you want to do it only by point then you have to somehow find the wall at the location first.

Also the script won’t take a family instance as an input, because it is creating a family instance from family type - not modifying an existing one.

If you have to find a family type by name you can use a FilteredElementCollector…  
The code below will give you all element types from the project - then you just have to filter out the one you need in Dynamo (eg. by name attribute)

```
import clr

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

clr.AddReference("RevitServices")
import RevitServices

from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc).WhereElementIsElementType()

#Assign your output to the OUT variable.
OUT = collector.ToElements()
```

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [May 7, 2020, 7:51am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/15 "2020-05-07T07:51:56Z")

</div>

[maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka) thank’s for help.  
Yes, I can get all elements …  
The point location I read from a CSV(FilePath - Data.ImportCSV) nothing special and all I need.  
I want to add a door/window into my Revit workspace, is a python API for this operation?

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [May 8, 2020, 7:11am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/16 "2020-05-08T07:11:02Z")

</div>

what do you mean by that? Loading a family into a Revit doc, or placing an already loaded one ?

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [May 8, 2020, 7:45am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/17 "2020-05-08T07:45:23Z")

</div>

None of these.  
The goal of my homework is to improve the working area on Revit.  
I want to know if it is possible after load the Revit project with families to **instantiate** objects into Revit workspace using the Dynamo or another way (node’s, python scripting, C#).  
These step about **instantiate** is difficult for me because the project is empty and I need to add it without drag and drop feature from Project Browser to the 3D work area.

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [May 8, 2020, 8:57am UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/18 "2020-05-08T08:57:09Z")

</div>

Perhaps I am misunderstanding, but the doc.Create.NewFamilyInstance() (mentioned above) actually instantiates an object based on family symbol.

---

<div class="post-metadata">

**Author:** ![catafest](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/catafest/32/92342_2.png) [@catafest](https://forum.dynamobim.com/u/catafest)\
**Post date:** [May 8, 2020, 12:50pm UTC](https://forum.dynamobim.com/t/set-position-for-a-window-with-dynamo/49748/19 "2020-05-08T12:50:25Z")

</div>

ꟿ FamilyInstance.ByHostAndPoint solve the problem by Spring package !!!
