Skip to content

Instantly share code, notes, and snippets.

View pzurek's full-sized avatar

Piotr Zurek pzurek

View GitHub Profile
@pzurek
pzurek / purge_unnamed_ref_planes.rb
Last active December 17, 2015 04:39
A simple Revit macro written in Ruby. Upon execution it detects and deletes all unnamed reference planes.
load_assembly "RevitAPI"
load_assembly "RevitAPIUI"
include Autodesk::Revit::DB
include Autodesk::Revit::UI
include Autodesk::Revit::UI::Selection
include System::Collections::Generic
include System::Collections
include System
@pzurek
pzurek / gist:3909011
Created October 17, 2012 23:33
Vend API docs
If you find any errors or discrepancies please notify __developer@vendhq.com__. Also if you have any brilliant ideas on how we can make it better, let us know. __:)__
Also, __don’t be evil__.
# Introduction
The Vend API is implemented as JSON over HTTPS using the verbs GET, PUT, POST and DELETE.
## Authentication
Authentication is managed using HTTP authentication (only "Basic" is supported right now). Every request must include the Authorization HTTP header. Use the properties username and password to authenticate. Example with Curl:
@pzurek
pzurek / Command.fs
Created September 11, 2012 23:24
A quick F# example for Revit
namespace FSharpPanelBuilder
open System
open System.Collections.Generic
open Autodesk.Revit
open Autodesk.Revit.UI
open Autodesk.Revit.Attributes
open Autodesk.Revit.DB
open Autodesk.Revit.UI.Selection
namespace FSharpPanelBuilder
open System
open System.Collections.Generic
open Autodesk.Revit
open Autodesk.Revit.UI
open Autodesk.Revit.Attributes
open Autodesk.Revit.DB
open Autodesk.Revit.UI.Selection
try {
if (null == commandData) {
throw new ArgumentNullException("commandData");
}
UIApplication app = commandData.Application;
UIDocument uiDoc = app.ActiveUIDocument;
Document doc = uiDoc.Document;
using (Transaction transaction = new Transaction(doc)) {
try
{
if( null == commandData )
{
throw new ArgumentNullException(
"commandData" );
}
UIApplication uiapp = commandData.Application;
Application app = uiapp.Application;
@pzurek
pzurek / UpdateReferencingSheet.cs
Created January 14, 2011 00:34
A simple workaround for a problem with Revit 2011 API
void updateReferencingSheet(Document doc)
{
// Retrieve the built-in VIEW_DISCIPLINE parameter
Parameter discipline = selectedViewport
.get_Parameter(BuiltInParameter.VIEW_DISCIPLINE);
// Save the value of that parameter for later
int disciplineNo = discipline.AsInteger();
Transaction transaction = new Transaction(doc);
@pzurek
pzurek / FilterPerformance.cs
Created January 10, 2011 03:16
Revit 2011 filter performance testing
//
// Compare TypeFilter versus using an
// anonymous method to filter elements.
// By Guy Robinson, info@r-e-d.co.nz.
//
// Copyright (C) 2008 by Jeremy Tammik,
// Autodesk Inc. All rights reserved.
//
// Updated to the Revit 2011 API and added LINQ filtering.
// Changed the anonymous method to a lambda expression.
public void Initialize()
{
DocumentCollection dm = Application.DocumentManager;
dm.DocumentActivated += delegate(object s, DocumentCollectionEventArgs d){
Document doc = d.Document;
doc.CommandWillStart += delegate(object sender, CommandEventArgs e){
if ((e.GlobalCommandName == "PUBLISH") ||
(e.GlobalCommandName == "EXPORT") ||
(e.GlobalCommandName == "3DDWF")){
(*
to compile use:
fsc FebKit.fs -r "/usr/lib/cli/webkit-sharp-1.0/webkit-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/gtk-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/gdk-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/atk-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/glib-sharp.dll"
*)
#light
open System
open WebKit
open Gtk