Ejemplo n.º 1
0
        public override sealed void ComputeData()
        {
            Rhinoceros.InvokeInHostContext(() => base.ComputeData());

            if (unhandledException is object)
            {
                unhandledException = default;
                ResetData();
            }
        }
Ejemplo n.º 2
0
 private static Result Pick <TResult>(out TResult value, Func <TResult> picker)
 {
     using (new External.EditScope())
     {
         value = default;
         try { value = Rhinoceros.InvokeInHostContext(picker); }
         catch (Autodesk.Revit.Exceptions.OperationCanceledException) { return(Result.Cancelled); }
         catch (Exception) { return(Result.Failed); }
         return(Result.Succeeded);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the active Graphical <see cref="Autodesk.Revit.DB.View"/> of the provided <see cref="Autodesk.Revit.DB.Document"/>.
        /// </summary>
        /// <param name="doc"></param>
        /// <returns>The active graphical <see cref="Autodesk.Revit.DB.View"/></returns>
        public static View GetActiveGraphicalView(this Document doc)
        {
            using (var uiDocument = new Autodesk.Revit.UI.UIDocument(doc))
            {
                var activeView = uiDocument.ActiveGraphicalView;
                if (activeView is null)
                {
                    var openViews = Rhinoceros.InvokeInHostContext(() => uiDocument.GetOpenUIViews()).
                                    Select(x => doc.GetElement(x.ViewId) as View).
                                    Where(x => x.ViewType.IsGraphicalViewType());

                    activeView = openViews.FirstOrDefault();
                }

                return(activeView);
            }
        }
Ejemplo n.º 4
0
        public override void PostProcessData()
        {
            base.PostProcessData();

            Rhinoceros.InvokeInHostContext
            (
                () =>
            {
                if (SourceCount == 0)
                {
                    RefreshList(NickName);
                }
                else
                {
                    RefreshList(VolatileData.AllData(true));
                }

                // Show elements sorted
                ListItems.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name));

                //base.CollectVolatileData_Custom();
                m_data.Clear();

                var path = new GH_Path(0);
                if (SelectedItems.Count == 0)
                {
                    m_data.AppendRange(new IGH_Goo[0], path);
                }
                else
                {
                    foreach (var item in SelectedItems)
                    {
                        m_data.Append(item.Value, path);
                    }
                }
            }
            );
        }
Ejemplo n.º 5
0
 public override sealed void ComputeData() =>
 Rhinoceros.InvokeInHostContext(() => base.ComputeData());
Ejemplo n.º 6
0
 public static string GetFamilyName(this ElementType elementType) => Rhinoceros.InvokeInHostContext(() => elementType.FamilyName);