public override bool IsCommandAvailable(UIApplication _, DB.CategorySet selectedCategories)
            {
                if (!base.IsCommandAvailable(_, selectedCategories))
                {
                    return(false);
                }

                if (Instances.ActiveCanvas?.Document is GH_Document definition)
                {
                    if (Revit.ActiveUIDocument?.ActiveGraphicalView is DB.View view)
                    {
                        var options = new BakeOptions()
                        {
                            Document = view.Document,
                            View     = view,
                            Category = DB.Category.GetCategory(view.Document, ActiveBuiltInCategory),
                            Material = default
                        };

                        return(ObjectsToBake(definition, options).Any());
                    }
                }

                return(false);
            }
예제 #2
0
 public override bool IsCommandAvailable(UIApplication _, DB.CategorySet selectedCategories) =>
 base.IsCommandAvailable(_, selectedCategories) &&
 Instances.ActiveCanvas?.Document is object;
 public override bool IsCommandAvailable(UIApplication _, DB.CategorySet selectedCategories) =>
 base.IsCommandAvailable(_, selectedCategories) &&
 (PlugIn.PlugInExists(PluginId, out bool loaded, out bool loadProtected) & (loaded | !loadProtected));
 public override bool IsCommandAvailable(UIApplication _, DB.CategorySet selectedCategories)
 {
     return(GH.Guest.IsEditorLoaded() && base.IsCommandAvailable(_, selectedCategories));
 }
예제 #5
0
        void ReconstructDefineSharedParameter
        (
            DB.Document doc,
            ref DB.SharedParameterElement element,

            [Description("Parameter Name")] string name,
            [Description("Overwrite Parameter definition if found"), Optional, DefaultValue(false)] bool overwrite
        )
        {
            var  parameterGUID  = default(Guid?);
            var  parameterType  = DB.ParameterType.Text;
            var  parameterGroup = DB.BuiltInParameterGroup.PG_DATA;
            bool instance       = true;
            bool visible        = true;

            using (var bindings = doc.ParameterBindings.ReverseIterator())
            {
                while (bindings.MoveNext())
                {
                    if (bindings.Key is DB.InternalDefinition def)
                    {
                        if
                        (
                            def.Name == name &&
                            def.Visible == visible &&
                            def.ParameterType == parameterType &&
                            def.ParameterGroup == parameterGroup &&
                            (instance ? bindings.Current is DB.InstanceBinding : bindings.Current is DB.TypeBinding)
                        )
                        {
                            if (doc.GetElement(def.Id) is DB.SharedParameterElement parameterElement)
                            {
                                if (!overwrite)
                                {
                                    ReplaceElement(ref element, parameterElement);
                                    throw new CancelException($"A parameter called \"{name}\" is already in the document");
                                }
                                parameterGUID = parameterElement.GuidValue;
                            }
                        }
                    }
                }
            }

            using (var defOptions = new DB.ExternalDefinitionCreationOptions(name, parameterType)
            {
                Visible = visible
            })
            {
                if (parameterGUID.HasValue)
                {
                    defOptions.GUID = parameterGUID.Value;
                }

                using (var definitionFile = Revit.ActiveUIApplication.Application.CreateSharedParameterFile())
                {
                    if (definitionFile?.Groups.Create(DB.LabelUtils.GetLabelFor(parameterGroup)).Definitions.Create(defOptions) is DB.ExternalDefinition definition)
                    {
                        // TODO : Ask for categories
                        using (var categorySet = new DB.CategorySet())
                        {
                            foreach (var category in doc.Settings.Categories.Cast <DB.Category>().Where(category => category.AllowsBoundParameters))
                            {
                                categorySet.Insert(category);
                            }

                            var binding = instance ? (DB.ElementBinding) new DB.InstanceBinding(categorySet) : (DB.ElementBinding) new DB.TypeBinding(categorySet);

                            if (!doc.ParameterBindings.Insert(definition, binding, parameterGroup))
                            {
                                if (!overwrite || !doc.ParameterBindings.ReInsert(definition, binding, parameterGroup))
                                {
                                    throw new InvalidOperationException("Failed while creating the parameter binding.");
                                }
                            }
                        }

                        parameterGUID = definition.GUID;
                    }
                }
            }

            ReplaceElement(ref element, DB.SharedParameterElement.Lookup(doc, parameterGUID.Value));
        }
예제 #6
0
 public override bool IsCommandAvailable(UIApplication _, DB.CategorySet selectedCategories) =>
 base.IsCommandAvailable(_, selectedCategories) &&
 Revit.ActiveUIDocument?.Document.IsFamilyDocument == false;
 public override bool IsCommandAvailable(UIApplication _, DB.CategorySet selectedCategories)
 {
     RefreshUI();
     return(base.IsCommandAvailable(_, selectedCategories));
 }
예제 #8
0
 public bool IsCommandAvailable(UIApplication applicationData, Autodesk.Revit.DB.CategorySet selectedCategories)
 {
     return(true);
 }
예제 #9
0
 public bool IsCommandAvailable(Autodesk.Revit.UI.UIApplication applicationData, Autodesk.Revit.DB.CategorySet selectedCategories)
 {
     return(true);
     //return RevitApp.Instance.IsLogin;
 }