This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright(c) 2020, chuongho | |
# @chuongmep, https://chuongmep.com/ | |
import clr | |
import sys | |
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib') | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import * | |
import clr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def GetParameterValue(parameter): | |
value= None | |
if parameter.StorageType == StorageType.Double: | |
value = parameter.AsDouble() | |
elif parameter.StorageType == StorageType.Integer: | |
if parameter.Definition.ParameterType == ParameterType.Integer: | |
value = parameter.AsInteger() | |
else: | |
value = parameter.AsValueString() | |
elif parameter.StorageType == StorageType.String: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static object GetParameterValue(Autodesk.Revit.DB.Parameter param) | |
{ | |
object result; | |
switch (param.StorageType) | |
{ | |
case StorageType.ElementId: | |
int valueId = param.AsElementId().IntegerValue; | |
if (valueId > 0) | |
{ | |
var elem = ElementIDLifecycleManager<int>.GetInstance().GetFirstWrapper(valueId) as Element; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string GetParameterValue(this Parameter p) | |
{ | |
if (p == null) return string.Empty; | |
switch (p.StorageType) | |
{ | |
case StorageType.Double: | |
return p.AsDouble().ToString(); | |
case StorageType.ElementId: | |
try | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clr | |
clr.AddReference('ProtoGeometry') | |
from Autodesk.DesignScript.Geometry import Surface as DSSurf | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import* | |
clr.AddReference('RevitNodes') | |
import Revit | |
clr.ImportExtensions(Revit.GeometryConversion) | |
import sys | |
pyt_path = r'C:\\Program Files (x86)\\IronPython 2.7\\Lib' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<Autodesk.DesignScript.Geometry.Surface> GetTop(Autodesk.DesignScript.Geometry.Geometry geometry) | |
{ | |
List<Autodesk.DesignScript.Geometry.Surface> TopSurface = new List<Autodesk.DesignScript.Geometry.Surface>(); | |
Autodesk.DesignScript.Geometry.Geometry[] geometries = geometry.Explode(); | |
foreach (Autodesk.DesignScript.Geometry.Surface g in geometries) | |
{ | |
double d = g.NormalAtParameter(0.5, 0.5).Z; | |
if (d>0.1) | |
{ | |
TopSurface.Add(g); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static PlanarFace GetTopFace(Solid solid) | |
{ | |
PlanarFace topFace = null; | |
FaceArray faces = solid.Faces; | |
foreach (Face f in faces) | |
{ | |
PlanarFace pf = f as PlanarFace; | |
if (pf.FaceNormal.IsAlmostEqualTo(new XYZ(0, 0, 1))) | |
{ | |
topFace = pf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load the Python Standard and DesignScript Libraries | |
import sys | |
import clr | |
clr.AddReference('ProtoGeometry') | |
from Autodesk.DesignScript.Geometry import * | |
clr.AddReference('acdbmgd') | |
clr.AddReference('acmgd') | |
clr.AddReference('accoremgd') | |
clr.AddReference('AecBaseMgd') | |
import Autodesk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void PurgesCAD() | |
{ | |
Document doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; | |
Database db = doc.Database; | |
using (Transaction Tx = db.TransactionManager.StartTransaction()) | |
{ | |
BlockTable table = Tx.GetObject(db.BlockTableId, | |
OpenMode.ForRead) as BlockTable; | |
ObjectIdCollection blockIds = new ObjectIdCollection(); | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clr | |
clr.AddReference('ProtoGeometry') | |
import Autodesk.DesignScript.Geometry | |
a = IN[0] | |
if isinstance(a, list): | |
a = a | |
else: a = [a] |
OlderNewer