Quasar Package Guide: PART – C

Parent Topic : Quasar Package Guide

Quasar Package Guide – PART – C

ElementActiveViewByCategory – collect all elements of a category from an active view.

ElementActiveView
ElementActiveViewByCategory
# dynamo version - 1.3.4

import clr,System
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
# document
doc = DocumentManager.Instance.CurrentDBDocument
# category input
category = UnwrapElement(IN[0])
# all BuiltInCategory object
builtInCategories = System.Enum.GetValues(BuiltInCategory)

# check matching id to collect BIC object
for bic in builtInCategories:
	# if match
	if ElementId(bic) == category.Id:
		catObj = bic
		break
	
# collect elements
elements = FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(catObj).ToElements()

# output
OUT = elements

RoomTagToRoom – relocate room’s tag to its room location.

RoomTag
RoomTagToRoom
# dynamo version - 1.3.4

import clr
#clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')

#from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

elems = IN[0];

if not isinstance(elems,list):
	elems = UnwrapElement([elem])
else:
	elems = UnwrapElement(elems)

#room_tags = FilteredElementCollector(doc).OfClass(SpatialElementTag).ToElements()

TransactionManager.Instance.EnsureInTransaction(doc)

for i in elems:
	room_loc = i.Room.Location.Point
	new_loc = room_loc - i.Location.Point
	i.Location.Move(new_loc)

TransactionManager.Instance.TransactionTaskDone()

OUT = elems

RoomCollector – Collect rooms by their status.

rooms
# dynamo version - 1.3.4

import clr
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

# if provided input[0]
if IN[0]:
	rooms = UnwrapElement(IN[0])
	
# if no input, collect all rooms
else:
	# collect all rooms 
	rooms = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements()

# room status list for output
placed,notplaced,notenclosed,redundant = [],[],[],[]

# loop rooms
for r in rooms:
	# get room boundary need one argument(opts)
	s = r.GetBoundarySegments(SpatialElementBoundaryOptions())
	# get location of room
	l = r.Location
	# if location is none
	if l == None:
		# append to not placed
		notplaced.append(r)
	# elif no boundary segments
	elif len(s)<1:
		# append to not enclosed
		notenclosed.append(r)
	# elif area zero
	elif r.Area == 0:
		# append to redundant
		redundant.append(r)
	# passed all conditions
	else:
		# append to placed
		placed.append(r)

OUT = placed,notplaced,notenclosed,redundant

Become a Patron!

Work In Progress …

Advertisements

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.