Autodesk.Revit.DB.GBXMLImportOptions是Revit API中的一个类,用于定义GBXML文件的导入参数和选项。
该类有两个构造函数:一个无参数的构造函数和一个带参数的构造函数。
GBXMLImportOptions()无参数的构造函数创建一个默认的GBXML导入选项列表,包括所有的默认设置。
GBXMLImportOptions(UnitSystem system)带参数的构造函数创建一个自定义的GBXML导入选项列表。
system:UnitSystem枚举值,指定导入GBXML文件时使用的单位系统。可选值为:
Autodesk.Revit.DB.UnitSystem.Imperial: 英制单位Autodesk.Revit.DB.UnitSystem.Metric: 公制单位下面列出了该类的公共属性,可用于设置和查询导入选项:
AirBoundariesAsWalls:布尔值,确定是否将空气边界作为墙导入。默认为false。AirWallHeight:双精度值,指定空气墙的高度。默认为10英尺。CreateAreas:布尔值,确定是否创建区域元素。默认为true。CreateRooms:布尔值,确定是否创建房间元素。默认为true。CreateSpaceBoundaries:布尔值,确定是否创建空间边界元素。默认为true。CreateSpaceSeparators:布尔值,确定是否创建空间分隔线元素。默认为true。CurveRepresentation:CurveRepresentation枚举值,指定导入曲线的表示方式。可选值为:
Autodesk.Revit.DB.CurveRepresentation.CurveAutodesk.Revit.DB.CurveRepresentation.PolylineExteriorWallFunction:RevitAPI.WallFunction枚举值,指定外墙的功能。可选值为:
NotDefined: 不定义NormalWall: 普通墙CurtainWall: 幕墙FoundationWall: 基础墙RetainingWall: 挡土墙FloorsAsRooms:布尔值,确定是否将楼板作为房间导入。默认为false。ImportAsType:RevitAPI.SelectionElementType枚举值,指定导入元素的类型。可选值为:
ElementType: 一般元素类型FamilyType: 家族类型InteriorWallFunction:RevitAPI.WallFunction枚举值,指定内墙的功能。可选值与ExteriorWallFunction相同。LoopsAsRooms:布尔值,确定是否将环作为房间导入。默认为false。OpeningsAsDoors:布尔值,确定是否将开口作为门导入。默认为false。OpeningsAsWindows:布尔值,确定是否将开口作为窗导入。默认为false。RoofsAsFamilyTypes:布尔值,确定是否将屋顶作为家族类型导入。默认为false。Scale:双精度值,指定导入元素的比例尺。默认为1.0。Units:GBXMLImportUnits枚举值,指定导入GBXML文件时使用的单位类型。可选值为:
GBXMLImportUnits.Architectural: 建筑单位GBXMLImportUnits.Structural: 结构单位要导入GBXML文件并使用GBXMLImportOptions,可以按照以下步骤操作:
GBXMLImportOptions对象,根据需要设定属性值。Document.Import(string filePath, GBXMLImportOptions options, out string message)方法,导入GBXML文件。GBXMLImportOptions importOptions = new GBXMLImportOptions();
importOptions.Units = GBXMLImportUnits.Architectural;
importOptions.InteriorWallFunction = RevitAPI.WallFunction.NormalWall;
importOptions.ExteriorWallFunction = RevitAPI.WallFunction.CurtainWall;
importOptions.CreateRooms = true;
importOptions.CreateAreas = true;
Document doc = uidoc.Document;
string filePath = "C:\example.gbxml";
string message;
Transaction trans = new Transaction(doc, "Import GBXML");
trans.Start();
doc.Import(filePath, importOptions, out message);
trans.Commit();
要检查GBXML文件中包含的元素,可以使用GBXMLOptionsReader类,如下所示:
GBXMLOptionsReader optionsReader = new GBXMLOptionsReader("C:\example.gbxml");
optionsReader.ReadOptions();
double thickness = optionsReader.WallThickness;
double height = optionsReader.AirWallHeight;
Autodesk.Revit.DB.GBXMLImportOptions是一个用于定义GBXML文件导入选项的类,可用于控制导入的元素、单位系统和比例尺等参数。使用时,可以创建该类的实例对象,并设置所需的属性值,然后调用Document.Import()方法,将GBXML文件导入Revit中。此外,还可以使用GBXMLOptionsReader类,检查GBXML文件中包含的元素和选项。