Skip to content

Instantly share code, notes, and snippets.

View gtalarico's full-sized avatar
♥️
Python, Javascript, and Go

Gui Talarico gtalarico

♥️
Python, Javascript, and Go
View GitHub Profile
import sys
if sys.version_info >= (3, 0):
sys.stdout.write("Sorry, requires Python 2.x, not Python 3.x\n")
sys.exit(1)
def function1():
"""Description of Function 1."""
pass
def funciton2():
"""Description of Function 2."""
pass
def function3():
"""Description of Function 3."""
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
@gtalarico
gtalarico / .bashrc
Created June 22, 2016 04:42
Custom config added to bash.
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
def tree():
return defaultdict(tree)
Adding a simple subclass allows attribute like selection:
class mydefaultdict(defaultdict):
def __getattr__(self, attr):
return self[attr]
def __setattr__(self, attr, val):
self[attr] = val
@gtalarico
gtalarico / revitapidocs_CropImage.py
Last active September 1, 2016 01:00
RevitAPI::Working Tools::Crop Selected Image Using a Filled Region
"""
Crop Image
Crops an Image to a Filled Region Boundary
TESTED REVIT API: 2015
Copyright (c) 2014-2016 Gui Talarico
github.com/gtalarico
This script is part of PyRevitPlus: Extensions for PyRevit
github.com/gtalarico/pyrevitplus
@gtalarico
gtalarico / revitapidocs_GetFilledRegionByName.py
Last active September 1, 2016 01:01
RevitAPI::Code Snippets::Get Filled Region Id - by Name
from Autodesk.Revit.DB import Element, FilteredElementCollector
from Autodesk.Revit.DB import FilledRegionType, FilledRegion
def fregion_id_by_name(name=None):
"""Get Id of Filled Region Type by Name.
Loops through all types, tries to match name.
If name not supplied, first type is used.
If name supplied does not match any existing types, last type is used
"""
@gtalarico
gtalarico / revitapidocs_GetPhaseByName.py
Last active September 1, 2016 01:01
RevitAPI::Code Snippets::Get Phase By Name
from Autodesk.Revit.DB import Phase, FilteredElementCollector
def get_phase_by_name(phase_name):
phase_collector = FilteredElementCollector(doc).OfClass(Phase)
for phase in phase_collector:
if phase.Name.Equals(phase_name):
return phase
phase = get_phase_by_name('01 - Existing')
print phase.Name
@gtalarico
gtalarico / revitapidocs_CreateTextFunc.py
Last active September 1, 2016 01:04
RevitAPI::Code Snippets::Create Text Function
''' Create a text annotation element.
Does not include start/commit transaction.'''
def create_text(view, text, point, align):
"""Creates a Revit Text.
create_test(view, text_string, point)
view: view object to insert text
text: text to be inserted
point: insertion point - XYZ() instance
align: 'left', 'right', or 'center'
@gtalarico
gtalarico / revitapidocs_ImportImage.py
Created September 6, 2016 19:16
RevitAPI::Code Snippets::Import Image
# Import Image
# http://www.revitapidocs.com/2015/05c3dbe2-fe7e-c293-761d-b11f356a011b.htm
from clr import StrongBox
from Autodesk.Revit.DB import XYZ, ImageImportOptions, BoxPlacement, BuiltInParameter
# Import Options
import_options = ImageImportOptions()
import_options.Placement = BoxPlacement.Center
import_options.RefPoint = XYZ(0,0,0)