Hi all,
Following what’s been discusse in the following thread:
This worked great. Thanks to you all.
[GetSketch]
I’m trying to get the sketch lines of a wall object. I copied the python code posted by @Ben_Osborne but I’m getting an error:
My code is as follows:
import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
clr.AddReference("RevitNodes")
import Revit
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
items = UnwrapElement(IN[0])
elementlist = list()
for item in items:
trans = Autodesk.Revit.DB.SubTransaction(doc)
trans.Start()
ids = doc.Delete(item)
elementlist.append(ids)
trans.RollBack()
TransactionManager.Instance.TransactionTaskDone()
OUT = items
What did I do wrong?.
Thanks!
You missed a line -
There should be a line that says:
TransactionManager.Instance.EnsureInTransaction(doc)
right before the:
for item in items:
Right, my mistake. Now, I’m getting an error as follows:
Looks like you were after some id collector. As an input, I have a list of walls selected in the view. I’m looking for the sketch lines that defines each wall element, do you know how to get them?
Thanks in advance.
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
import Revit
clr.ImportExtensions(Revit.Elements)
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
from System.Collections.Generic import *
items = UnwrapElement(IN[0])
sketchlines = UnwrapElement(IN[1])
sketchlist = list()
elementlist = list()
foundidlist = list()
TransactionManager.Instance.EnsureInTransaction(doc)
for sketchline in sketchlines:
skid = sketchline.Id
sketchlist.append(skid)
for item in items:
trans = Autodesk.Revit.DB.SubTransaction(doc)
trans.Start()
ids = doc.Delete(item.Id)
elementlist.append(ids)
trans.RollBack()
TransactionManager.Instance.TransactionTaskDone()
for i in range(0,len(items)):
idslist=list()
idslist = elementlist[i]
intermediatelist = list()
elements = list()
for j in range(0,len(idslist)):
id=idslist[j]
for k in range(0,len(sketchlist)):
sketchid = sketchlist[k]
if id==sketchid:
intermediatelist.append(id)
for m in range(0,len(intermediatelist)):
el = intermediatelist[m]
elements.append(doc.GetElement(el).ToDSType(True))
foundidlist.append(elements)
elements = []
OUT = foundidlist
1 Like
Nice work @Ben_Osborne , thanks!. Looking into the code, I see that you use as an input the sketch lines (IN[1]). I want to get the sketch lines of the element, not as an input:
Regardless of whether your code works for my problem, it is good to know and I’m sure it will be handy in the next step of my script. Thanks a lot!
I found that Springs package’s Spings.COllector.ElementSketch node do the job.
Thanks!
in the Spings.Collector.ElementSketch (@Dimitar_Venkov ) node, why is it returning only the curves from the last wall?