Quasar Package Guide: PART – A

Quasar Package Guide: PART – A

ActiveView – this node returns an active view of the current document.

active-view

Active View – IronPython

# IronPython Code

# dynamo version - 1.3.2

# import common language runtime
import clr

# clr.AddReference loads and imports .net assembly(dll)
# load RevitAPI.dll and RevitServices.dll
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

# import document manager
from RevitServices.Persistence import DocumentManager
# import transaction manager
from RevitServices.Transactions import TransactionManager

# instantiate current document
doc = DocumentManager.Instance.CurrentDBDocument

# active view
activeView = doc.ActiveView

# output
OUT = activeView

// CSharp Code
public static Revit.Elements.Element ActiveView()
{ var ActiveView = DocumentManager.Instance.CurrentDBDocument.ActiveView.ToDSType(true);
return ActiveView;
}


CeilingViewByRoom – create ceiling views by level, rooms, names and offset.

CeilingViewByRooom
QuasarPackage – CeilingViewByRoom

# dynamo version - 1.3.2
# import common language runtime
import clr

# clr.AddReference loads and imports .net assembly(dll) as python module
# load RevitAPI.dll and RevitServices.dll
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

# import all classes from Revit DB
from Autodesk.Revit.DB import *
# import document manager
from RevitServices.Persistence import DocumentManager
# import transaction manager
from RevitServices.Transactions import TransactionManager
# instantiate current document
doc = DocumentManager.Instance.CurrentDBDocument
# ceiling view to duplicate
cview = UnwrapElement(IN[0]);
rooms = IN[1];
names = IN[2];
Offset = IN[3]/304.8;
result = [];

# make list
if not isinstance(rooms,list):
Rooms = UnwrapElement([rooms]);
else:
Rooms = UnwrapElement(rooms);

if not isinstance(names,list):
Names = [names];
else:
Names = names;

def crop_box(bbox, offset):
minX = bbox.Min.X - offset;
minY = bbox.Min.Y - offset;
minZ = bbox.Min.Z - offset;
maxX = bbox.Max.X + offset;
maxY = bbox.Max.Y + offset;
maxZ = bbox.Max.Z + offset;

newbox = BoundingBoxXYZ();
newbox.Min = XYZ(minX,minY, minZ);
newbox.Max = XYZ(maxX, maxY, maxZ);
return newbox;

# collect views
views = FilteredElementCollector(doc).OfClass(View).ToElements();

# start transaction
TransactionManager.Instance.EnsureInTransaction(doc);

# loop room and name
for room,name in zip(Rooms,Names):
# duplicate ceiling view
view = cview.Duplicate(ViewDuplicateOption.WithDetailing);
# get room bbox
bbox = room.BoundingBox[doc.ActiveView];
# create new bbox
cbox = crop_box(bbox,Offset);
# get duplicated view
dupview = doc.GetElement(view);
# set name
dupview.Name = name;
# set view cropbox
dupview.CropBox = cbox;
# set cropbox active
dupview.CropBoxActive = True;
# set cropbox visibility
dupview.CropBoxVisible = False;
# set scale
dupview.Scale = 25;
# append result
result.append(dupview);
# transaction done
TransactionManager.Instance.TransactionTaskDone();
# output result;
OUT = result;
CS_CeilingViewByRoom
C# – CeilingViewByRoom

CopyPasteFilter – copy filters and override graphics settings from a view and paste it’s to given views.

# IronPython Code
# dynamo version - 1.3.2

# import common language runtime
import clr

# clr.AddReference loads and imports .net assembly(dll)
# load RevitAPI.dll and RevitServices.dll
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

# import all classes from Revit DB
from Autodesk.Revit.DB import *

# import document manager
from RevitServices.Persistence import DocumentManager
# import transaction manager
from RevitServices.Transactions import TransactionManager

# instantiate current document
doc = DocumentManager.Instance.CurrentDBDocument

# view to copy
viewtocopy= UnwrapElement(IN[0])
# views to paste
viewstopaste = IN[1]
# make list
if not isinstance(viewstopaste,list):
viewstopaste = UnwrapElement([IN[1]])
else:
viewstopaste = UnwrapElement(IN[1])

# start transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# views to paste loop each view
for view in viewstopaste:
# views to copy loop each filter id
for id in viewtocopy.GetFilters():
# set filter override
view.SetFilterOverrides(id,viewtocopy.GetFilterOverrides(id))
# set filter visibility
view.SetFilterVisibility(id,viewtocopy.GetFilterVisibility(id))

# transaction done
TransactionManager.Instance.TransactionTaskDone()

# output views
OUT = viewstopaste
CS_CopyPasteFilter
C# – CopyPasteFilter
GIF_CopyPasteFilter
Demo – CopyPasteFilter

CreateDuctByModelCurves – create duct by family type and model curves.

CreateDuct
QuasarPackage – CreateDuctsByModelCurves
# dynamo version - 1.3.2
# import common language runtime
import clr
# clr.AddReference loads and imports .net assembly(dll)
# load RevitAPI.dll and RevitServices.dll
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

# import all classes from Revit DB
from Autodesk.Revit.DB import *

# import document manager
from RevitServices.Persistence import DocumentManager
from Autodesk.Revit.DB.Mechanical import *
# import transaction manager
from RevitServices.Transactions import TransactionManager

# instantiate current document
doc = DocumentManager.Instance.CurrentDBDocument

lines = IN[0];
ductType = UnwrapElement(IN[1]);
ducts = [];
# make list
if isinstance(lines, list):
lines = UnwrapElement(lines);
else:
lines = UnwrapElement([lines]);
#current view level
level = doc.ActiveView.GenLevel;
#collect family symbol
fsymbol = FilteredElementCollector(doc).OfClass(MechanicalSystemType).ToElements()[0];

#transaction start
TransactionManager.Instance.EnsureInTransaction(doc);
# loop lines
for line in lines:
#create duct
duct = Duct.Create(doc, fsymbol.Id,ductType.Id, level.Id,
line.GeometryCurve.GetEndPoint(0), line.GeometryCurve.GetEndPoint(1));
#append to result
ducts.append(duct);

#transaction end
TransactionManager.Instance.TransactionTaskDone();
# output result
OUT = ducts
GIF_CreateDuct
Demo – CreateDuctByModelCurves

CreateBeamsByModelCurves – create beam by family type and model curves.

CreateBeam
QuasarPackage – CreateBeamsByModelCurves
# IronPython Code
# dynamo version - 1.3.2
# import common language runtime
import clr
# clr.AddReference loads and imports .net assembly(dll)
# load RevitAPI.dll and RevitServices.dll
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

# import all classes from Revit DB
from Autodesk.Revit.DB import *
# import document manager
from RevitServices.Persistence import DocumentManager
# import transaction manager
from RevitServices.Transactions import TransactionManager
# instantiate current document
doc = DocumentManager.Instance.CurrentDBDocument

# input model curves
lines = IN[0]
# empty list for return output
beams = []
# if input is a list
if isinstance(lines, list):
lines = UnwrapElement(lines)
# if not a list
else:
lines = UnwrapElement([lines])
#current view level
level = doc.ActiveView.GenLevel
#structural framing symbol
sym=UnwrapElement(IN[1])

#transaction start
TransactionManager.Instance.EnsureInTransaction(doc)
#loop lines
for line in lines:
#create beam
beam = doc.Create.NewFamilyInstance(line.GeometryCurve,
sym, level, Structure.StructuralType.Beam)
#append to output
beams.append(beam)

#transaction end
TransactionManager.Instance.TransactionTaskDone()
#output
OUT = beams
GIF_CreateBeam
Demo – CreateBeamsByModelCurves

CreateWallSweep – create wall sweep by walls, wall sweep type and offset.

CreateWallSweep
QuasarPackage – CreateWallSweep
# dynamo version - 1.3.2
# import common language runtime
import clr
# load RevitAPI.dll and RevitServices.dll
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")
# import all classes from Revit DB
from Autodesk.Revit.DB import *
# import document manager, transaction manager
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# instantiate current document
doc = DocumentManager.Instance.CurrentDBDocument
# for output result
wallSweeps = []
# wallsweeptype dictionary
wallSweepTypes = {"Sweep": WallSweepType.Sweep,
"Reveal": WallSweepType.Reveal}
walls = IN[0]
sweepOrReveal = IN[2]
# input4 boolean input default is horizontal(false)
vertical = IN[3] if IN[3] else False
# distance from wall base horizontal,vertical wall start(default 1000mm)
distance = IN[4]/304.8 if IN[4] else 1000/304.8
# check and make list
if not isinstance(walls,list):
walls = UnwrapElement([IN[0]])
else:
walls = UnwrapElement(IN[0])
# input2 wall sweep type input
wallSweepTypeId = UnwrapElement(IN[1]).Id
# wall sweep info class constructor
wallSweepInfo = WallSweepInfo(wallSweepTypes[sweepOrReveal],vertical)
# set distance
wallSweepInfo.Distance = distance
# start transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# loop input walls
for wall in walls:
# create wall sweep by wall, wallsweepid and wallsweep info
wallsweep = WallSweep.Create(wall,wallSweepTypeId,wallSweepInfo)
# append result to output
wallSweeps.append(wallsweep)
# transaction done
TransactionManager.Instance.TransactionTaskDone()
# output result
OUT = wallSweeps
CS_CreateWallSweep
C# – CreateWallSweep
GIF_CreateWallSweep
Demo – CreateWallSweep

ElevationByRoom – Create elevation views in rooms with crop offset by room floorplan and offset. Default naming is ” RoomNumber_RoomName ” plus ” A, B, C, D ”  for each of the elevation view.

ElevationByRoom
QuasarPackage – ElevationInRoom
GIF_ElevationByRoom
Demo – ElevationInRoom

ThreeDViewByRoom

This node takes three inputs, Room Elements, Names and Offset(desire crop distance room bounding box) and returns New ThreeD Views.

ThreeDViewByRoom
QuasarPackage – ThreeDViewByRoom

# import common language runtime
import clr

# clr.AddReference loads and imports .net assembly(dll) as python module
# load RevitAPI.dll and RevitServices.dll
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

# import all classes from Revit DB
from Autodesk.Revit.DB import *
# import document manager
from RevitServices.Persistence import DocumentManager
# import transaction manager
from RevitServices.Transactions import TransactionManager
# instantiate current document
doc = DocumentManager.Instance.CurrentDBDocument

rooms = IN[0]
names = IN[1]
offset = IN[2]/304.8 # mm to ft
results = []

# check list for rooms
if isinstance(IN[0], list):
rooms = UnwrapElement(IN[0])
else:
rooms = [UnwrapElement(IN[0])]
# check list for name
if isinstance(IN[1],list):
names = IN[1]
else:
names = [IN[1]]

def crop_box(bbox, offset):
# modify x,y,z point of bbox
minX = bbox.Min.X - offset
minY = bbox.Min.Y - offset
minZ = bbox.Min.Z - offset
maxX = bbox.Max.X + offset
maxY = bbox.Max.Y + offset
maxZ = bbox.Max.Z + offset
# create new bbox
newbox = BoundingBoxXYZ()
newbox.Min = XYZ(minX,minY, minZ)
newbox.Max = XYZ(maxX, maxY, maxZ)
return newbox

def createNewSectionBox(elem,viewName,offset):
# collect view type in document
viewTypes = FilteredElementCollector(doc).OfClass(ViewFamilyType)
#loop view types
for i in viewTypes:
# 3d view type
if i.ViewFamily == ViewFamily.ThreeDimensional:
# get type id
viewTypeId = i.Id
# break the loop
break
# create new bbox by current bbox and offset
bbox = crop_box(elem.BoundingBox[doc.ActiveView],offset)

# create 3D View
view = View3D.CreateIsometric(doc, viewType.Id)
# set view name
view.Name = viewName
# set sectionbox to bbox
view.SetSectionBox(bbox)
# set cropbox active
view.CropBoxActive = True
# set cropbox visibility
view.CropBoxVisible = True
# set view scale
view.Scale = 50
# set detail level to fine
view.DetailLevel = ViewDetailLevel.Fine
# set detail style to shading
view.DisplayStyle = DisplayStyle.Shading
# return view
return view

# start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# loop element and name together
for element,name in zip(rooms,names):
# call function with element, name and offset arguments
# and append it to results
results.append(createNewSectionBox(element,name,offset))

# end Transaction
TransactionManager.Instance.TransactionTaskDone()
# output results
OUT = results


ViewSelector -this UI node returns selected views.

GIF_ViewSelector
Demo – ViewSelector

TransferViewTemplateAndFilterUI – transfer selected view templates including associate filters from a linked document to the current document.

TransferViewTemplate
Quasar – TransferViewTemplateAndFilterUI
TransferViewTemplates
Demo – TransferViewTemplateAndFilter

Continue to PART – B

Become a Patron!

Advertisements

6 thoughts on “Quasar Package Guide: PART – A”

  1. Elevation by Room – brilliant, far easier than the one available on Dynamo forum!

    It did work, however with a warning that Operation Failed. I couldn’t select a specific View Template.
    Another thing is that I would love to assign a specific Elevation Type, and have no clue whatsoever how to do it via Dynamo.

    Otherwise, brill!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.