Пример #1
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            var app   = commandData.Application;
            var uidoc = app.ActiveUIDocument;
            var doc   = uidoc.Document;

            // Ask the user to select a Face
            Face face;

            try
            {
                var pickedObject = uidoc.Selection.PickObject(ObjectType.Face, "Select a face");
                var element      = doc.GetElement(pickedObject);
                face = element.GetGeometryObjectFromReference(pickedObject) as Face;
            }
            catch (OperationCanceledException)
            {
                return(Result.Cancelled);
            }

            using (var tx = new Transaction(doc))
            {
                tx.Start("Sort and Mark Face Curve Loops");

                // Sort the loops on the selected face
                var lists = SortCurveLoops(face);

                // Create a label on each loop.
                // Outer loops are counterclockwise.
                // The label is at U=0.33, closer to the beginning of the
                // edge, which gives an idea of the loop orientation.
                for (var i = 0; i < lists.Count; i++)
                {
                    for (var j = 0; j < lists[i].Count; j++)
                    {
                        var loop = lists[i][j];
                        Creator.CreateTextNote($"[{i}][{j}]", loop.First().Evaluate(0.33, true), doc);
                    }
                }
                tx.Commit();
            }

            return(Result.Succeeded);
        }