2

私はこのコードを持っていますが、選択した壁の位置、高さ、および長さを表示する方法がわかりません:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
namespace PickSelectionFiltered
{
    [TransactionAttribute(TransactionMode.Manual)]
    [RegenerationAttribute(RegenerationOption.Manual)] 

    public class Class1: IExternalCommand
    {
        public class MySelectionFilter : ISelectionFilter
        {
            Document m_doc = null;

            public bool AllowElement(Element element)
            {
                return element is Wall;
            }
            public bool AllowReference(Reference refer, XYZ point)
            {
                GeometryObject geoObject = 
                m_doc.GetElement(refer)
                     .GetGeometryObjectFromReference(refer);
                return geoObject != null && geoObject is Face;
            }
        }


        public Result Execute(ExternalCommandData commandData, 
          ref string message, ElementSet elements)
        {
            //Get application and document objects
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            try
            {
                while (true)
                {
                    Reference selRef = 
                      uidoc.Selection.PickObject(ObjectType.Element, 
                        new MySelectionFilter(), "select a room");
                    /*
                     * Add the code to get position, lenght and height
                     * */
                }

            } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { }

            return Result.Succeeded;
        }
    }
}
4

1 に答える 1

4

壁の位置は、LocationCurveとして壁から取得された駆動曲線に基づいています。

Wall wall = document.GetReference(setRef) as Wall;
if (wall != null)
{
    LocationCurve locationCurve = wall.Location as LocationCurve;
    XYZ endPoint0 = locationCurve.Curve.get_EndPoint[0];
    XYZ endPoint1 = locationCurve.Curve.get_EndPoint[1];
} 

壁の長さは、壁のパラメータから取得されます。

BuiltInParameter.CURVE_ELEM_LENGTH

壁の幅は、壁タイプのパラメータから取得されます。

BuiltInParameter.WALL_ATTR_WIDTH_PARAM

これは標準の壁用であり、カーテンウォールや積み重ねられた壁などの特殊な壁タイプには適用されません。

于 2011-07-18T18:22:00.947 に答える