657 lines
19 KiB
Markdown
657 lines
19 KiB
Markdown
## Document
|
||
|
||
### ActiveProjectLocation
|
||
|
||
- 获得项目的地址信息
|
||
|
||
- 继承与ProjectLocation
|
||
|
||
### ActiveView
|
||
|
||
- 获得激活视图
|
||
|
||
- View
|
||
|
||
### Application
|
||
|
||
- 获得应用对象
|
||
|
||
### Close()
|
||
|
||
- 关闭文件
|
||
|
||
### CombineElements(CombinewElementSet set)
|
||
|
||
- 连接几何图元
|
||
|
||
### ConvertDetailToModelCurves(DetailCurveArray array)
|
||
|
||
- 将细线转为模型线
|
||
|
||
### ConvertModelToDetailCurves(DetailCurveArray array)
|
||
|
||
### SymbolicCurve
|
||
|
||
### Create
|
||
|
||
- 获得Create对象,用于创建物体
|
||
|
||
- Create.Document
|
||
|
||
- Create(可用doc.GetdeFaultTypeId()获得Type
|
||
|
||
- Alignment
|
||
|
||
- 对齐尺寸
|
||
|
||
- NewArea(ViewPlan plan ,UV uv)
|
||
|
||
- 创建一个面积 必须在面积平面,ViewPlan必须为面积平面 UV为面积的中心点,且该中心点需要被闭合的边界线包围
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
ViewPlan view = doc.ActiveView as ViewPlan;
|
||
var create = doc.Create;
|
||
using (Transaction transaction = new Transaction(doc))
|
||
{
|
||
//通过创建四条面积边界线来形成一个正方形的闭合区域
|
||
transaction.Start("as");
|
||
var sketchPlane = view.SketchPlane;
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(20, 20, 0), new XYZ(40, 20, 0)), view);
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(40, 20, 0), new XYZ(40, 40, 0)), view);
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(40, 40, 0), new XYZ(20, 40, 0)), view);
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(20, 40, 0), new XYZ(20, 20, 0)), view);
|
||
create.NewArea(view, new UV(30, 30));
|
||
transaction.Commit();
|
||
|
||
}
|
||
|
||
- NewAreas(List<AreaCreationData〉dataList) 创建多个面积
|
||
|
||
- NewAreaBoundaryLine(SketchPlane sketchPlane,Curve geometryCurve,ViewPlan areaView)
|
||
|
||
-
|
||
|
||
该方法可创建一个闭合面,取中点给Area创建
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
ViewPlan view = doc.ActiveView as ViewPlan;
|
||
var create = doc.Create;
|
||
using (Transaction transaction = new Transaction(doc))
|
||
{
|
||
//通过创建四条面积边界线来形成一个正方形的闭合区域
|
||
transaction.Start("as");
|
||
var sketchPlane = view.SketchPlane;
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(20, 20, 0), new XYZ(40, 20, 0)), view);
|
||
transaction.Commit();
|
||
|
||
}
|
||
|
||
- NewAreaTag(ViewPlan view,Area room,UV point)
|
||
|
||
- 创建面积标签
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
ViewPlan view = doc.ActiveView as ViewPlan;
|
||
var create = doc.Create;
|
||
using (Transaction transaction = new Transaction(doc))
|
||
{
|
||
//通过创建四条面积边界线来形成一个正方形的闭合区域
|
||
transaction.Start("as");
|
||
var sketchPlane = view.SketchPlane;
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(20, 20, 0), new XYZ(40, 20, 0)), view);
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(40, 20, 0), new XYZ(40, 40, 0)), view);
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(40, 40, 0), new XYZ(20, 40, 0)), view);
|
||
create.NewAreaBoundaryLine(sketchPlane,
|
||
Line.CreateBound(new XYZ(20, 40, 0), new XYZ(20, 20, 0)), view);
|
||
Area area = create.NewArea(view, new UV(30, 30));
|
||
create.NewAreaTag(view, area, new UV(30, 30));
|
||
transaction.Commit();
|
||
|
||
}
|
||
|
||
- NewCrossFitting(四个Connector)
|
||
|
||
- 创建四通,四个Connector必须以主管方向的两个Connector在前面
|
||
|
||
- NewCurtainSystem(FaceArray array,CurtainSystemType)
|
||
|
||
- 创建幕墙系统,参数为面,和系统的type
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
Reference r = sel.PickObject(ObjectType.Face);
|
||
Element element = doc.GetElement(r);
|
||
Face face = element.GetGeometryObjectFromReference(r) as Face;
|
||
CurtainSystemType type = doc.GetElement(doc.GetDefaultElementTypeId(ElementTypeGroup.CurtainSystemType)) as CurtainSystemType;
|
||
FaceArray faceArray = new FaceArray();
|
||
|
||
faceArray.Append(face);
|
||
using (Transaction tr = new Transaction(doc))
|
||
{
|
||
tr.Start("Create Curtain System");
|
||
doc.Create.NewCurtainSystem(faceArray, type);
|
||
|
||
tr.Commit();
|
||
}
|
||
|
||
- NewDetailCurve(View view,Curve geometryCurve)
|
||
|
||
- 创建细线
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
|
||
using (Transaction tr = new Transaction(doc))
|
||
{
|
||
tr.Start("Create Detail Curve");
|
||
doc.Create.NewDetailCurve(doc.ActiveView,Line.CreateBound(new XYZ(0,0,0),new XYZ(10,0,0)));
|
||
|
||
tr.Commit();
|
||
}
|
||
|
||
- NewDimension(View view,Line line,ReferenceArray array,Type)
|
||
|
||
- 创建尺寸标注,line为标注的线,可为射线,参照数组为 线面的参照
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
Reference r1 = sel.PickObject(ObjectType.PointOnElement);
|
||
Reference r2 = sel.PickObject(ObjectType.PointOnElement);
|
||
|
||
ReferenceArray array = new ReferenceArray();
|
||
array.Append(r1);
|
||
array.Append(r2);
|
||
Element element = doc.GetElement(r1);
|
||
Line line = element.GetGeometryObjectFromReference(r1) as Line;
|
||
// 根据线的方向计算与之垂直的方向,新建一条线用于创建尺寸标注
|
||
double direc = Math.Acos(line.Direction.X) + Math.PI / 2;
|
||
Line l = Line.CreateUnbound(line.Origin, new XYZ(Math.Cos(direc), Math.Sin(direc), 0));
|
||
|
||
using (Transaction tr = new Transaction(doc))
|
||
{
|
||
tr.Start("Create Dimension");
|
||
doc.Create.NewDimension(doc.ActiveView, l, array);
|
||
|
||
tr.Commit();
|
||
}
|
||
|
||
- NewDuct(两个Connector一个Type)
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
|
||
using (Transaction tr = new Transaction(doc))
|
||
{
|
||
tr.Start("Create Duct");
|
||
DuctType type = doc.GetElement(doc.GetDefaultElementTypeId(ElementTypeGroup.DuctType)) as DuctType;
|
||
doc.Create.NewDuct(new XYZ(0,0,0),new XYZ(20,0,0), type);
|
||
tr.Commit();
|
||
}
|
||
|
||
- NewElbowFitting(两个Connector)
|
||
|
||
- 创建弯头
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
|
||
using (Transaction tr = new Transaction(doc))
|
||
{
|
||
tr.Start("Create Duct");
|
||
DuctType type = doc.GetElement(doc.GetDefaultElementTypeId(ElementTypeGroup.DuctType)) as DuctType;
|
||
Duct duct1 = doc.Create.NewDuct(new XYZ(0,0,0),new XYZ(20,0,0), type);
|
||
Duct duct2 = doc.Create.NewDuct(new XYZ(20, 20, 0), new XYZ(20, 0, 0), type);
|
||
|
||
Connector connector1 = GetConnector(duct1, new XYZ(20, 0, 0));
|
||
Connector connector2 = GetConnector(duct2, new XYZ(20, 0, 0));
|
||
doc.Create.NewElbowFitting(connector1, connector2);
|
||
|
||
tr.Commit();
|
||
}
|
||
|
||
=====================================================
|
||
|
||
private Connector GetConnector(Duct duct, XYZ xyz)
|
||
{
|
||
ConnectorSetIterator iterator = duct.ConnectorManager.Connectors.ForwardIterator();
|
||
Connector connector = null;
|
||
while (iterator.MoveNext())
|
||
{
|
||
Connector c = iterator.Current as Connector;
|
||
if (c.Origin.DistanceTo(xyz)>0.005) continue;
|
||
connector = c;
|
||
}
|
||
return connector;
|
||
}
|
||
|
||
- NewExtrusionRoof (CurveArray profile, ReferencePlane refPlane, Level level, RoofType roofType, double extrusionStart, double extrusionEnd);
|
||
|
||
- 拉伸屋顶(给定一组形状线,一个参照平面,***)
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
var create = doc.Create;
|
||
CurveArray array = new CurveArray();
|
||
array.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 20, 20)));
|
||
array.Append(Line.CreateBound(new XYZ(0, 20, 20), new XYZ(0, 40, 0)));
|
||
|
||
Transaction tr = new Transaction(doc);
|
||
tr.Start("create roof");
|
||
ReferencePlane plane = create.NewReferencePlane(new XYZ(0, 0, 0), new XYZ(0, 20, 0), new XYZ(0, 0, 20),doc.ActiveView);
|
||
Level level = doc.ActiveView.GenLevel;
|
||
RoofType roofType = doc.GetElement(doc.GetDefaultElementTypeId(ElementTypeGroup.RoofType)) as RoofType;
|
||
create.NewExtrusionRoof(array, plane, level, roofType, 0, 40);
|
||
tr.Commit();
|
||
|
||
- NewFamilyInstance(Curve curve,FamilySymbol symbol,Level level,StructuralType structuralType)
|
||
|
||
- curve为locationCurve
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
var create = doc.Create;
|
||
FilteredElementCollector col = new FilteredElementCollector(doc);
|
||
col.OfCategory(BuiltInCategory.OST_StructuralFraming);
|
||
FamilySymbol symbol = null;
|
||
foreach(Element e in col)
|
||
{
|
||
FamilySymbol familySymbol = e as FamilySymbol;
|
||
if (familySymbol == null) continue;
|
||
symbol = familySymbol;
|
||
break;
|
||
}
|
||
Transaction tr = new Transaction(doc);
|
||
tr.Start("create beam");
|
||
Curve curve = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 20, 0));
|
||
Level level = doc.ActiveView.GenLevel;
|
||
create.NewFamilyInstance(curve, symbol, level, StructuralType.Beam);
|
||
tr.Commit();
|
||
|
||
- NewFascia(args)
|
||
|
||
- 挡泥板?
|
||
|
||
- NewFlexDuct(args)
|
||
|
||
- 软风管
|
||
|
||
- NewFlexPipe(args)
|
||
|
||
- 软管
|
||
|
||
- NewFloor(args)
|
||
- NewFootPrintRoof(args)
|
||
|
||
- 迹线屋顶
|
||
ModelCurveArray modelCurveArray = new ModelCurveArray();
|
||
FootPrintRoof roof =
|
||
RevitDoc.Create.NewFootPrintRoof(curveArray, level, roofType, out modelCurveArray);
|
||
//设置屋顶坡度
|
||
ModelCurve curve1 = modelCurveArray.get_Item(0);
|
||
ModelCurve curve3 = modelCurveArray.get_Item(2);
|
||
roof.set_DefinesSlope(curve1, true);
|
||
roof.set_SlopeAngle(curve1, 0.5);
|
||
roof.set_DefinesSlope(curve3, true);
|
||
roof.set_SlopeAngle(curve3, 1.6);
|
||
|
||
|
||
- curveArr为创建时的迹线,Out为输出的模型线,可根据模型线设置坡度
|
||
|
||
- NewFoundationSlab(args)
|
||
|
||
- 基础板
|
||
|
||
- NewFoundationWall(args)
|
||
|
||
- 基础墙
|
||
|
||
- NewGroup(List<ElementId ids>
|
||
|
||
- 创建模型组
|
||
|
||
- NewGutter(Type,Reference r)
|
||
|
||
- 根据参照面创建檐沟
|
||
|
||
- NewMechanicalSystem(args)
|
||
|
||
- https://www.cnblogs.com/greatverve/archive/2011/07/18/revit-MechanicalSystem.html
|
||
|
||
- NewModelCurve(Curve geoCurve,SketchPlane plane)
|
||
|
||
- 创建模型线
|
||
|
||
- NewOpening(args)
|
||
|
||
- 开洞口
|
||
|
||
- https://blog.csdn.net/ruiqi317/article/details/6939692
|
||
|
||
- NewReferencePlane(3个XYZ,一个View)
|
||
|
||
- 为两点,和一个向量创建平面
|
||
|
||
- NewReferencePlane2(3个XYZ,一个View)
|
||
|
||
- 用3个点创建一个平面
|
||
|
||
- NewTakeoffFitting(Connector,Curve)
|
||
|
||
- 根据线和Connector创建两个T型风管链接
|
||
|
||
- NewTeeFitting(3个Connector)
|
||
|
||
- 创建三通,前两个Connector必须为主管方向上
|
||
|
||
- NewTransitionFitting(Connector,Connector)
|
||
|
||
- 创建过度件
|
||
|
||
- NewUnionFitting(两个Connector)
|
||
|
||
- 创建管套
|
||
|
||
### Delete(ElementId)
|
||
|
||
- 根据ElementId删除Element
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
Reference r = sel.PickObject(ObjectType.Element);
|
||
Element element = doc.GetElement(r);
|
||
|
||
// 删除选择构件
|
||
using(Transaction tr = new Transaction(doc))
|
||
{
|
||
tr.Start("test");
|
||
doc.Delete(element.Id);
|
||
|
||
tr.Commit();
|
||
}
|
||
|
||
### DisplayUnitSystem
|
||
|
||
- 项目使用的单位制度
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
// 打印项目单位制度
|
||
TaskDialog.Show("as", doc.DisplayUnitSystem.ToString());
|
||
|
||
### DocumentColsing
|
||
|
||
### DocumentPrinted
|
||
|
||
### DocumentPrinting
|
||
|
||
### DocumentSave
|
||
|
||
### DocumentSaveAs
|
||
|
||
### DocumentSaving
|
||
|
||
### DocumentSaveAsing
|
||
|
||
### EditFamily(Family family)
|
||
|
||
- 获得族的Document,通过Document编辑族
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
Reference r = sel.PickObject(ObjectType.Element);
|
||
Element element = doc.GetElement(r);
|
||
|
||
FamilyInstance instance = element as FamilyInstance;
|
||
if (instance == null) return Result.Failed;
|
||
Family family = instance.Symbol.Family;
|
||
|
||
|
||
// 选择一个Element 如果是FamilyInstance则打开编辑文档,打印文档的标题
|
||
Document famDoc = doc.EditFamily(family);
|
||
TaskDialog.Show("AS",famDoc.Title);
|
||
|
||
### Export(args)
|
||
|
||
- 根据地址和设置导出gbXML
|
||
|
||
### ExportImage(ImageExportOptions options)
|
||
|
||
- 根据选项导出图片
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
|
||
string filePath = @"C:\Users\Administrator\Desktop\test.jpg";
|
||
ImageExportOptions imageExportOptions = new ImageExportOptions();
|
||
|
||
imageExportOptions.FilePath = filePath;
|
||
doc.ExportImage(imageExportOptions);
|
||
|
||
### FamilyCreate
|
||
|
||
- 获得FamilyItemFactory对象,用于创建FamilyItem
|
||
|
||
### FamilyManager
|
||
|
||
- 用于管理Family对象和属性
|
||
|
||
### GetDefaultElementTypeId(ElementiTypeGroup **)
|
||
|
||
- 获得默认的ElementType
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
|
||
WallType type = doc.GetElement(doc.GetDefaultElementTypeId(ElementTypeGroup.WallType)) as WallType;
|
||
if (type == null) return Result.Failed;
|
||
using(Transaction tr = new Transaction(doc))
|
||
{
|
||
tr.Start("test");
|
||
type.Name = "哈哈哈";
|
||
tr.Commit();
|
||
}
|
||
|
||
### GetDocumentPreviewSettings()
|
||
|
||
- 获得预览设置对象,可强制视图更新
|
||
|
||
- DocumentPreviewSettings
|
||
|
||
### GetElement(ElementId id)
|
||
|
||
- 根据ID获得Element
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
Reference r = sel.PickObject(ObjectType.Element);
|
||
Element element = doc.GetElement(r);
|
||
// int id = 123456;
|
||
// Element e = doc.GetElement(new ElementId(id));
|
||
|
||
### GetPaintedMaterial(ElementId id ,Face face)
|
||
|
||
- 获得构件该面的材质的Id
|
||
|
||
- EelementId
|
||
|
||
### GetPrintSettingIds()
|
||
|
||
- 获得打印设置列表
|
||
|
||
- ICollection<EelementId>
|
||
|
||
### GetRoomAtPoint(XYZ xyz)
|
||
|
||
- 根据一个点获得包含这个点的房间
|
||
|
||
- Room
|
||
|
||
### GetSpaceAtPoint(XYZ xyz)
|
||
|
||
- 根据一个点获得包含这个点的Space
|
||
|
||
- Space
|
||
|
||
### Units ()
|
||
|
||
- 获得设置格式
|
||
|
||
### GetWorksetId(ElementId)
|
||
|
||
- 获得该构件工作集的ElementId
|
||
|
||
### GetWorksetTable()
|
||
|
||
- 获得工作集列表
|
||
|
||
### GetWorksharingCentralModelPath()
|
||
|
||
- 获得中心文件的路径
|
||
|
||
### get_PlanTopologies
|
||
|
||
### get_TypeOfStorage()
|
||
|
||
- 获得属性储存用的数据类型
|
||
|
||
### Import(args)
|
||
|
||
- 导入DGN文件 本特利的
|
||
|
||
### IsDetached
|
||
|
||
- 是否分离中心文件
|
||
|
||
### IsFamilyDocument
|
||
|
||
- 是否为族文件
|
||
|
||
### IsLinked
|
||
|
||
- 是否为链接文件
|
||
|
||
### IsPainted(ElementId id,Face face)
|
||
|
||
- 判断该面是否有材质
|
||
|
||
### Link(string fileName,Options)
|
||
|
||
- 链接文件
|
||
|
||
### LoadFamily(string fileName)
|
||
|
||
- 加载族
|
||
|
||
### LoadFamily(args)
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
string familyFilePath = @"C:\Users\Administrator\Desktop\1.rfa";
|
||
doc.LoadFamily(familyFilePath);
|
||
|
||
### MassDisplayTemporaryOverride
|
||
|
||
###
|
||
|
||
MullionTypes
|
||
竖艇
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Selection sel = uidoc.Selection;
|
||
MullionTypeSetIterator iterator = doc.MullionTypes.ForwardIterator();
|
||
while (iterator.MoveNext())
|
||
{
|
||
MullionType type = iterator.Current as MullionType;
|
||
TaskDialog.Show("SA", type.Name);
|
||
}
|
||
|
||
### OwnerFamily
|
||
|
||
- 获得当前FamilyDocument的Family
|
||
|
||
### Paint(args)
|
||
|
||
- 给构件添加材质
|
||
|
||
### PanelTypes()
|
||
|
||
- 获得所有的平面类型
|
||
|
||
### ParameterBindings
|
||
|
||
### Phases
|
||
|
||
- 获得所有Phase集合
|
||
|
||
### print(args)
|
||
|
||
- 打印
|
||
|
||
### PrintManager
|
||
|
||
- 打印管理对象
|
||
|
||
### ProjectInformation
|
||
|
||
- 项目信息
|
||
|
||
### RemovePaint(args)
|
||
|
||
- 删除材质
|
||
|
||
### SaveToProjectAsImage(OPTIONS)
|
||
|
||
- 将当前视图保存为图片
|
||
|
||
### SeparateElements()
|
||
|
||
- 分离所有链接图元
|
||
|
||
### SetDefaultElementTypeId(ElementTypeGroup group,ElementId typeId)
|
||
|
||
- 设置TypeGroup的默认类型
|
||
|
||
### SetDefaultFamilyTypeId
|
||
|
||
- 设置默认族类型
|
||
|
||
### Settings
|
||
|
||
- 获得Document的设置对象
|
||
|
||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||
Document doc = uidoc.Document;
|
||
Settings settings = doc.Settings;
|
||
Category category = settings.Categories.get_Item("墙");
|
||
TaskDialog.Show("as", category.Name);
|
||
|
||
### SiteLocation
|
||
|
||
### SynchronizeWithCentral
|
||
|
||
### Title
|
||
|
||
- 获得标题
|