Unwrapping elements to place rooms with python


#1

I’m trying to place rooms in a revit file based on the level and UV. I tried to follow the syntax for creating a transaction and unwraping dynamo elements that I found in the migrating to .7 document, but I’m running into an error “Expecting UV, got UV” (on the line that creates the new room). Does anyone know what this error means(code below)?

Thanks,

Nate

import clr

Import RevitAPI

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) extension method

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
TransactionManager.Instance.EnsureInTransaction(doc)

#The inputs to this node will be stored as a list in the IN variable.

levels = IN[0]
uvs = IN[1]

for i in range(len(uvs)):
level=UnwrapElement(levels[i])
uv=UnwrapElement(uvs[i])
roomlist=[]
doccreation = doc.Create
room = doc.Create.NewRoom(level, uv)
roomlist.append(room)

TransactionManager.Instance.TransactionTaskDone()
OUT=roomlist


#2

This is clearly a DS to Revit compatibility issue. You might have to take that UV and decompose it and then use those parts to create a Revit API UV. I have a feeling that the UV you are passing in is of DS type. Let me know if you cannot solve this problem, and i can have a closer look. Also, it’s a good idea to zip together the definition and revit files and post them with a question so that people answering it can quickly re-create your error.


#3

I got similar issue with XYZ. Migration page indicates to add ToXyz when unwrapping so that DS type becomes Revit type. Read this chapter again to see if it could be so with UVs. Otherwise Konrad tip will work. I did a node like this in 0.6.3, would be great you publish it as package for 0.7!