Skip to content

Instantly share code, notes, and snippets.

Avatar

Ali Asad imAliAsad

View GitHub Profile
View SimplePool.cs
///
/// Simple pooling for Unity.
/// Author: Martin "quill18" Glaude (quill18@quill18.com)
/// Latest Version: https://gist.github.com/quill18/5a7cfffae68892621267
/// License: CC0 (http://creativecommons.org/publicdomain/zero/1.0/)
/// UPDATES:
/// 2015-04-16: Changed Pool to use a Stack generic.
///
/// Usage:
///
@imAliAsad
imAliAsad / CopyFiles.bat
Created Dec 26, 2017
Copy files to multiple computers in a network by using a batchfile
View CopyFiles.bat
:: Usage
:: This batch file code is used to copy the files from one computer to all other computers with in a network
:: Make sure you'll have the access to that computer where you wish to copy the file.
:: How to use it
:: Put all the files on the same folder where this batch file is located
:: Put the target.txt file on the same folder where the same batch file is located.
:: target.txt file should contain the target folder address in this format
:: "\\LAE20039\C$\Users\Ali asad\AppData\Roaming\Autodesk\Revit\Addins\2017\"
@imAliAsad
imAliAsad / CreateFile.cs
Created Jan 17, 2018
Create a file or folder if it doesn't exist in C#
View CreateFile.cs
string path = @"E:\FamilyBrowser\";
string FullPath = @"E:\FamilyBrowser\Architecture\Annotation\Cable Tray\Fittings\Channel Horizontal Bend.rfa";
// Extract file path info
var newpath = FullPath.Replace(path, "");
newpath = newpath.Replace(".rfa", "");
newpath = path + @"IMG\" + newpath;
// Store File Path Info
var fileinfo = new System.IO.FileInfo(newpath + ".png");
@imAliAsad
imAliAsad / LoadNoHiddenFiles.cs
Created Jan 17, 2018
C# don't show the hidden files
View LoadNoHiddenFiles.cs
var dirs = Directory.GetDirectories(@"C:\")
.Select(d => new { Attr = new DirectoryInfo(d).Attributes, Dir = d })
.Where(x => !x.Attr.HasFlag(FileAttributes.System))
.Where(x => !x.Attr.HasFlag(FileAttributes.Hidden))
.Select(x => x.Dir)
.ToList();
@imAliAsad
imAliAsad / ExtractFamilyParameterData.cs
Created Jan 21, 2018
Extract or read Revit family parameter data and convert its internal ( Imperial ) unit into the metrics unit
View ExtractFamilyParameterData.cs
/// <summary>
/// Extract all family type properties data
/// </summary>
/// <param name="app"></param>
private MultiValueDictionary<string, Tuple<string, string>> ExtractFamilyParameterInfo(Application app)
{
//Open Revit Family File in a separate document
var doc = app.OpenDocumentFile(FamilyPath);
@imAliAsad
imAliAsad / FParameterData.cs
Last active Mar 4, 2018
Read and export all parameter data of a family
View FParameterData.cs
public class FParameterData
{
public string Family { get; set; }
public string BuiltinParameter { get; set; }
public string ParameterType { get; set; }
public string ParameterName { get; set; }
public string ParameterValue { get; set; }
public string ParameterGroup { get; set; }
public string BuiltinGroup { get; set; }
@imAliAsad
imAliAsad / App.cs
Created Feb 21, 2018
Create a button in a custom ribbon in Revit and add the functionality to enable/disable the revit addin button
View App.cs
class App : IExternalApplication
{
public static PushButton Pushbutton { get; set; }
public Result OnStartup(UIControlledApplication application)
{
OnButtonCreate(application);
return Result.Succeeded;
}
@imAliAsad
imAliAsad / Win32Api.cs
Created Mar 25, 2018 — forked from teocomi/Win32Api.cs
Run Revit commands using Win32 API
View Win32Api.cs
/// <summary>
/// Run Revit commands using Win32 API
/// </summary>
public class Win32Api
{
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern bool SetFocus(IntPtr hWnd);
@imAliAsad
imAliAsad / Configuration.cs
Created Apr 1, 2018
Window service that will copy all updated files from a network drive and paste it into a local drive
View Configuration.cs
public static class Configuration
{
public static readonly string ArchcorpAddinFolderPath = @"O:\IT\4th Door\Ali Asad\Projects\Revit Addins\Test Archcorp Addins\";
public static readonly string AutodeskRevitAddinFolderPath = $"C:\\Users\\{Environment.UserName}\\AppData\\Roaming\\Autodesk\\Revit\\Addins\\";
public static readonly List<string> AutodeskVersion = new List<string> { @"2015\", @"2017\", @"2018\", @"2019\" };
public static readonly string DeleteAddinNamePrefix = "delete_";
}
@imAliAsad
imAliAsad / ElementsInView.cs
Last active Jun 3, 2018
Get all elements in active view - Revit api C#
View ElementsInView.cs
FilteredElementCollector allElementsInView = new FilteredElementCollector(document, document.ActiveView.Id);
IList elementsInView = (IList)allElementsInView.ToElements();
You can’t perform that action at this time.