Hello!
I’m trying to create script which would create sheet, views and schedule for an assembly.
As a start I picked Tool.AssemblyViews from SteamNodes and successfully managed to add view template and view name functionality. Currently I’m trying to add part of code where I can create schedule (via CreateSingleCategorySchedule Method (Document, ElementId, ElementId, ElementId, Boolean)). I know that my schedule will always be “structural rebar” category, but I have no idea how to feed it to parameter. I was trying to feed it from input but I don’t think this is a good way (and doesn’t work for me). Also can I put a function in a parameter (viewTemplateRebarSchedule.Id)? Thanks in advance for all help. As you can see I’m a beginer at Python in Dynamo.
#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# 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
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
elt = []
for i in IN[0]:
elt.append(UnwrapElement(i).Id)
tb=UnwrapElement(IN[4]).Id
catid=doc.GetElement(elt[0]).Category.Id
viewTemplateHorizontalDetail = [t for t in FilteredElementCollector(doc).OfClass(View).ToElements() if t.IsTemplate and t.Name == "EPO_PAL_DETAL_1-10"][0]
viewTemplateDetailSectionA = [t for t in FilteredElementCollector(doc).OfClass(View).ToElements() if t.IsTemplate and t.Name == "EPO_PAL_DETAL_1-50"][0]
viewTemplateRebarSchedule = [t for t in FilteredElementCollector(doc).OfClass(View).ToElements() if t.IsTemplate and t.Name == "EPO_PAL_ZESTAWIENIE_ZBR"][0]
collection=List[ElementId](elt)
viewlist=[]
schedlist=[]
sheetlist=[]
view_ports=[]
# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for a in elt:
views=[]
if IN[1] == 1:
ds2=AssemblyViewUtils.CreateDetailSection(doc,a,AssemblyDetailViewOrientation.HorizontalDetail)
ds2.ViewTemplateId = viewTemplateHorizontalDetail.Id
ds2.Name = "Przekrój A-A"
views.append(ds2)
if IN[2] == 1:
ds10=AssemblyViewUtils.CreateDetailSection(doc,a,AssemblyDetailViewOrientation.DetailSectionA)
ds10.ViewTemplateId = viewTemplateDetailSectionA.Id
ds10.Name = "Widok"
views.append(ds10)
if IN[5] == 1:
ds11=AssemblyViewUtils.CreateSingleCategorySchedule(doc,a,IN[5],viewTemplateRebarSchedule.Id,True)
views.append(ds11)
viewlist.append(views)
if IN[3] == 1:
sh=AssemblyViewUtils.CreateSheet(doc,a,tb)
for v in views:
if Viewport.CanAddViewToSheet(doc,sh.Id,v.Id) == 1:
viewport = Viewport.Create(doc,sh.Id,v.Id,XYZ(0,0,0))
view_ports.append(viewport)
else:
ScheduleSheetInstance.Create(doc,sh.Id,v.Id,XYZ(0,0,0))
sheetlist.append(sh)
doc.Regenerate()
# End Transaction
TransactionManager.Instance.TransactionTaskDone()
OUT=viewlist,sheetlist,view_ports