Beispiel #1
0
        /// <summary>
        /// Calculate and paint the attenuation
        /// values on the given face.
        /// </summary>
        public static void PaintFace(
            Face face,
            XYZ psource,
            AttenuationCalculator calc)
        {
            IList <UV>           uvPts    = new List <UV>();
            IList <ValueAtPoint> uvValues = new List <ValueAtPoint>();

            BoundingBoxUV bb = face.GetBoundingBox();

            double umin  = bb.Min.U;
            double umax  = bb.Max.U;
            double ustep = 0.2 * (umax - umin);

            double vmin  = bb.Min.V;
            double vmax  = bb.Max.V;
            double vstep = 0.2 * (vmax - vmin);

            List <double> vals = new List <double>(1);

            vals.Add(0);

            XYZ psource2 = psource + _z_offset;

            for (double u = umin; u <= umax; u += ustep)
            {
                for (double v = vmin; v <= vmax; v += vstep)
                {
                    UV uv = new UV(u, v);

                    if (face.IsInside(uv))
                    {
                        uvPts.Add(uv);

                        XYZ ptarget = face.Evaluate(uv)
                                      + _z_offset;

                        vals[0] = calc.Attenuation(
                            psource2, ptarget);

                        uvValues.Add(new ValueAtPoint(vals));
                    }
                }
            }

            FieldDomainPointsByUV fpts
                = new FieldDomainPointsByUV(uvPts);

            FieldValues fvals = new FieldValues(uvValues);

            _sfm.UpdateSpatialFieldPrimitive(
                _sfp_index, fpts, fvals, _schemaId);
        }
Beispiel #2
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;
            Selection     sel   = uidoc.Selection;

            // Pick signal source point on floor slab.

            Reference r;

            try
            {
                r = sel.PickObject(
                    ObjectType.Face,
                    new FloorFilter(),
                    "Please pick signal source point.");

                Debug.Print(Util.PointString(r.GlobalPoint));
            }
            catch (Autodesk.Revit.Exceptions
                   .OperationCanceledException)
            {
                return(Result.Cancelled);
            }

            // Set up AVF display style.

            View view = uidoc.ActiveView;

            SetUpAvfSfm(view, r);

            // Display attenuation.

            Element floor = doc.GetElement(r.ElementId);

            Face face = floor.GetGeometryObjectFromReference(
                r) as Face;


            Settings settings = Settings.Load();

            AttenuationCalculator calc
                = new AttenuationCalculator(doc, settings);

#if DEBUG_GRAPHICAL
            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Draw Debug Model Lines");
#endif // DEBUG_GRAPHICAL

            PaintFace(face, r.GlobalPoint, calc);

#if DEBUG_GRAPHICAL
            tx.Commit();
        }
#endif // DEBUG_GRAPHICAL

            return(Result.Succeeded);
        }