コード例 #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            var uidoc    = commandData.Application.ActiveUIDocument;
            var doc      = uidoc.Document;
            var connForm = new ConnectElmFrm(uidoc);

            if (connForm.ShowDialog() != DialogResult.OK)
            {
                return(Result.Cancelled);
            }

            doc.AutoTransaction(() =>
            {
                var combins = new CombinableElementArray();
                var elms    = connForm.Elms;

                elms.OfType <CombinableElement>().ToList().ForEach(f => combins.Append(f));

                if (doc.IsFamilyDocument && combins.Size >= 2)
                {
                    doc.CombineElements(combins);
                }
                else if (!doc.IsFamilyDocument && elms.Count >= 2)
                {
                    elms.ForEach(f1 => elms.ForEach(f2 =>
                    {
                        ExceptionUtil.AutoTry(() =>
                        {
                            if (f1 == f2)
                            {
                                return;
                            }

                            if (!doc.CrossSpaceBox(f1, f2))
                            {
                                return;
                            }

                            JoinGeometryUtils.JoinGeometry(doc, f1, f2);
                        });
                    }));
                }
            });

            return(Result.Succeeded);
        }
コード例 #2
0
ファイル: ParamCommand.cs プロジェクト: leshui1991/RevitDev
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            var uiapp = commandData.Application;
            var uidoc = uiapp.ActiveUIDocument;
            var doc   = uidoc.Document;
            var elm   = new ConnectElmFrm(uidoc).Elms.FirstOrDefault();

            if (elm == null)
            {
                return(Result.Cancelled);
            }

            doc.AutoTransaction(() =>
            {
                uiapp.InitParams(elm, null);
                elm.SetValue(string.Empty, string.Empty);
            });

            return(Result.Succeeded);
        }