Set position for a window with Dynamo

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.

@catafest

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

One way to do this:

I use default Revit family Type nodes.
@JacobSmall 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.

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

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

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.

@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.

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.

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 :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.

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

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

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()

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?

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

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.

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

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