Skip to content

Instantly share code, notes, and snippets.

View johnpierson's full-sized avatar
🤡
clowning around

john pierson johnpierson

🤡
clowning around
View GitHub Profile
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#our inputs
phases = IN[0]
#to output
results = []
@johnpierson
johnpierson / openDocumentFile.cs
Created November 20, 2018 14:08
Example for background open of revit docs.
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using RevitServices.Persistence;
namespace ZeroTouchNode.Revit.Application
{
/// <summary>
/// Wrapper class for application level nodes.
/// </summary>
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import*
clr.AddReference('DSCoreNodes')
from DSCore import *
clr.AddReference('GeometryColor')
from Modifiers import*
public static global::Revit.Elements.Element ToUpper(global::Revit.Elements.Element textNote)
{
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
Autodesk.Revit.DB.TextNote internalNote = (Autodesk.Revit.DB.TextNote)textNote.InternalElement;
//Get the text from the text box
//we obtain formatted text and modify the caps instead of the string. Preserves formatting.
FormattedText formattedText = internalNote.GetFormattedText();
formattedText.SetAllCapsStatus(true);
//Change all the text to upper case and reassign to the text box
public Result OnStartup(UIControlledApplication a)
{
a.ControlledApplication.FileImporting += ControlledApplicationOnFileImporting;
return Result.Succeeded;
}
private void ControlledApplicationOnFileImporting(object sender, FileImportingEventArgs e)
{
TaskDialog.Show("Alert", "Sorry about that. No CAD import for you.");
e.Cancel();
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
# Copyright(c) 2017, Dimitar Venkov
# @5devene, dimitar.ven@gmail.com
# www.badmonkeys.net
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
from System.Drawing import Point, Color, Font
from System.Windows.Forms import *
@johnpierson
johnpierson / PrompForSaveApp.cs
Last active May 6, 2024 12:42
This is an example of an application level add-in that would prompt a user to save if they need to when launching dynamo.
#This code is proudly provided under the BSD-3-Clause, https://opensource.org/licenses/BSD-3-Clause
using System;
using Autodesk.Internal.Windows;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.UI;
namespace PromptForSaveOnDynamoLaunch
{
@johnpierson
johnpierson / RailingToTopo.py
Last active January 7, 2020 15:09
Host railing to topo
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
import clr
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
dialogContent = "You are about to delete all Fabrication Pipework content from the model. Are you sure?"
buttons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No
#assigning this to a dialog result variable allows us to check what the user selected
dialogResult = TaskDialog.Show('Delete all MEP',dialogContent,buttons)