Hi @Mark.Ackerley,
Good to see you again. The code you posted here has been helpful to experiment with. Thank you. As for my current stumbling block - I’m trying to create levels without inputting them into the node in dynamo. Ie -
topLevelId = int(str(baseLevel.Id)) + 1
Can i call out the next level without having to input the level from the node? First - I’ve pasted your code as I’m altering.
Then see further below for a version of my code I am trying to get to work. I guess I don’t really understand the builtInParams part of your code.
Thanks again for your time.
#thanks to clockwork and Archi-lab
import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import System
doc = DocumentManager.Instance.CurrentDBDocument
baseLevel = UnwrapElement(IN[0])
#topLevel = UnwrapElement(IN[1])
wallType = UnwrapElement(IN[2])
pt1 = XYZ(0, 0, 0)
pt2 = XYZ(10, 0, 0)
TransactionManager.Instance.EnsureInTransaction(doc)
line = Line.CreateBound(pt1, pt2)
wall = Wall.Create(doc, line, baseLevel.Id, False)
#we need to get an id from the type to use in setting the type, this must be an integer, to make an integer we need to convert the id to a string first
typeId = int(str(wallType.Id))
#change type, this needs an element id which is defined by the typeid
wall.ChangeTypeId(ElementId(typeId))
#to isolate the built in parameter we want, we first get all of them, then add the one which matches the name to our list.
builtInParams = System.Enum.GetValues(BuiltInParameter)
for i in builtInParams:
if i.ToString() == 'WALL_HEIGHT_TYPE':
bip = i
else:
continue
#as above we need an id from the top constraint to set the parameter value
topLevelId = int(str(baseLevel.Id)) + 1
#we first get the wall parameter then we set it
wall.get_Parameter(bip).Set(ElementId(topLevelId))
TransactionManager.Instance.TransactionTaskDone()
OUT = wall
This is my code I’m trying to manipulate:
import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import System
doc = DocumentManager.Instance.CurrentDBDocument
baseLevel = UnwrapElement(IN[0])
pt1 = XYZ(0,0,0)
pt2 = XYZ(IN[2],0,0)
pt3 = XYZ(IN[2],IN[1],0)
pt4 = XYZ(0,IN[1],0)
wallType = UnwrapElement(IN[3])
pts = [pt1, pt2, pt3, pt4]
walls = []
levelOut = int(str(baseLevel.Id)) + 1
TransactionManager.Instance.EnsureInTransaction(doc)
for n, pt in enumerate(pts):
try:
wall_line = Line.CreateBound(pt, pts[n+1])
except IndexError:
wall_line = Line.CreateBound(pt, pts[0])
wall = Wall.Create(doc, wall_line, baseLevel.Id, False).ToDSType(False)
# wall = Wall.Create(doc, wall_line, wallType.Id, baseLevel.Id, 10.0, 1.2, False, False).ToDSType(False)
wall.get_Parameter.WALL_HEIGHT_TYPE.Set(ElementId(levelOut))
walls.append(wall)
TransactionManager.Instance.TransactionTaskDone()
OUT = walls, baseLevel.Id, levelOut
the error I get is: AttributeError: ‘Wall’ object has no attribute ‘get_Parameter’