给我一段revit自动铺设构件的C#代码
时间: 2023-03-13 21:29:08 浏览: 115
答:将以下代码复制到Revit中: 'using System; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.Attributes; namespace Revit { [TransactionAttribute(TransactionMode.Automatic)] public class PlaceFamily : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Document doc = commandData.Application.ActiveUIDocument.Document; // Create a family instance in the current document. // First, define the family and symbol. FamilySymbol familySymbol = null; Family family = doc.LoadFamily(@"C:\Path\To\Family\Family.rfa", out familySymbol); // Now place the family in the document. // Create a reference point for the family instance. XYZ point = new XYZ(0, 0, 0); // Place the family instance. FamilyInstance familyInstance = doc.Create.NewFamilyInstance(point, familySymbol, StructuralType.NonStructural); // Return a value to indicate success or failure. return Result.Succeeded; } } }
阅读全文