Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

chuongmep

💭
I may be slow to respond.
View GitHub Profile
View Element.GetCurves.py
import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
View CreateSheet2.py
#Author Package RIE
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
View find_nearest_point.py
def calculate_distance(p1p2):
    return ((p1[0- p2[0])**2 + (p1[1- p2[1])**2)**0.5
def find_nearest_point(start_pointpoints):
    min_distance = math.inf
    index = 0
    for ipoint in enumerate(points):
        distance = calculate_distance(start_pointpoint)
        if min_distance > distance:
            min_distance = distance
View ClosestPointTo.cs
public static Autodesk.DesignScript.Geometry.Point ClosestPointTo(Point point, List<Point> points)
{
XYZ psrc = point.ToXyz();
XYZ pclosest = null;
double num = Double.MaxValue;
foreach (Point p in points)
{
var xyz = p.ToXyz();
double dis = xyz.DistanceTo(psrc);
if (dis<num)
View ReadexcelOpenXml.cs
Console.WriteLine("start write excel :" + DateTime.Now.ToString("h:mm:ss tt") + "\n");
string fileName = @"D:\test.xlsx";
using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(fileName, false))
{
WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;
WorksheetPart worksheetPart = workbookPart.WorksheetParts.First();
SheetData sheetData = worksheetPart.Worksheet.Elements<SheetData>().First();
string text;
View Relaycommand.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace WPFNotepad
{
/// <summary>
View LoadAssambly.cs
void LoadAssambly()
{
try
{
Assembly SampleAssembly =
Assembly.Load("EPPlus, Version=5.4.0.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1");
}
catch (Exception e)
{
}
View ReadExcelByTypeInterop.cs
public static List<List<string>> ReadExcelByType(string filePath, string worksheetName, DataStorage type,
int Index = 1)
{
List<List<string>> data = new List<List<string>>();
// Open the Excel file and get the worksheet
Application excelApp = null;
bool alreadyOpen = false;
try
{
excelApp = (Application) Marshal.GetActiveObject("Excel.Application");
View ReadExcelByTypeEPP.cs
public static List<List<string>> ReadExcelByType(string filePath, string worksheetName, DataStorage type,
int Index)
{
List<List<string>> data = new List<List<string>>();
ExcelPackage _excelPackage;
if (File.Exists(filePath))
{
FileInfo file = new FileInfo(filePath);
_excelPackage = new ExcelPackage(file);
}
View sort.py
import re
def sort(x):
convertText = lambda text: int(text) if text.isdigit() else text.lower()
Textkey = lambda key: [ convertText(c) for c in re.split('([0-9]+)', key) ]
return sorted(x, key = Textkey)
OUT = sort(IN[0])
You can’t perform that action at this time.