Beispiel #1
0
        /// <summary>
        /// Creates a Placeholder Sheet
        /// </summary>
        /// <param name="SheetNumber">The sheet number</param>
        /// <param name="SheetTitle">The sheet title</param>
        /// <param name="document">Document to create the sheet in.</param>
        /// <returns name="Sheet">Returns the created placeholder sheet as a dynamo wrapped sheet.</returns>
        public static DynaSheet CreatePlaceHolderSheet(string SheetNumber, string SheetTitle,
                                                       [DefaultArgument("Synthetic.Revit.Document.Current()")] RevitDoc document)
        {
            RevitSheet revitSheet;

            if (document.IsModifiable)
            {
                TransactionManager.Instance.EnsureInTransaction(document);
                revitSheet             = RevitSheet.CreatePlaceholder(document);
                revitSheet.SheetNumber = SheetNumber;
                RevitDB.Parameter paramName = revitSheet.get_Parameter(RevitDB.BuiltInParameter.SHEET_NAME);
                paramName.Set(SheetTitle);
                TransactionManager.Instance.TransactionTaskDone();
            }
            else
            {
                using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(document))
                {
                    trans.Start("Create Placeholder Sheet");
                    revitSheet             = RevitSheet.CreatePlaceholder(document);
                    revitSheet.SheetNumber = SheetNumber;
                    RevitDB.Parameter paramName = revitSheet.get_Parameter(RevitDB.BuiltInParameter.SHEET_NAME);
                    paramName.Set(SheetTitle);
                    trans.Commit();
                }
            }


            return((DynaSheet)revitSheet.ToDSType(false));
        }
Beispiel #2
0
        /// <summary>
        /// Return value Of parameter all case unit
        /// </summary>
        /// <param name="_parameter"></param>
        /// <returns></returns>
        public static string GetValue(this Autodesk.Revit.DB.Parameter _parameter)
        {
            string value;

            switch (_parameter.StorageType)
            {
            // database value, internal units, e.g. feet:
            case StorageType.Double:
                value = RealString(_parameter.AsDouble());
                break;

            case StorageType.Integer:
                value = _parameter.AsInteger().ToString();
                break;

            case StorageType.String:
                value = _parameter.AsString();
                break;

            case StorageType.ElementId:
                value = _parameter.AsElementId().IntegerValue.ToString();
                break;

            case StorageType.None:
                value = "None";
                break;

            default:
                Debug.Assert(false, "unexpected storage type"); value = string.Empty;
                break;
            }

            return(value);
        }
        public Dictionary <string, List <FamilyInstance> > GetAllConnection(Document doc)
        {
            Dictionary <string, List <FamilyInstance> > dic = new Dictionary <string, List <FamilyInstance> >();
            var Conn = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)).Cast <FamilyInstance>().ToList();

            foreach (var i in Conn)
            {
                ElementId faid                 = i.GetTypeId();
                Element   elemtype             = doc.GetElement(faid);
                Autodesk.Revit.DB.Parameter pa = elemtype.LookupParameter("MANUFACTURE_COMPONENT");
                if (pa != null)
                {
                    var vla = pa.AsString();
                    if (vla.Contains("CONNECTION"))
                    {
                        if (dic.ContainsKey(i.Name))
                        {
                            dic[i.Name].Add(i);
                        }
                        else
                        {
                            dic.Add(i.Name, new List <FamilyInstance> {
                                i
                            });
                        }
                    }
                }
            }
            return(dic);
        }
Beispiel #4
0
        /// <summary>
        /// Given a list of viewport element IDs, the function will get the viewport from the document and give each viewport a temporary sheet number.  Function will ignore legends.
        /// </summary>
        /// <param name="viewPortIds">Revit ElementId of the viewports.</param>
        /// <param name="doc">The Revit Document the viewports are in.</param>
        /// <returns name="viewports">Returns the Revit viewports.</returns>
        internal static List <revitViewport> _tempRenumberViewports(List <revitElemId> viewPortIds, revitDoc doc)
        {
            List <revitViewport> viewPorts = new List <revitViewport>();
            int i = 1;

            foreach (revitElemId id in viewPortIds)
            {
                revitViewport vp = (revitViewport)doc.GetElement(id);
                revitView     v  = (revitView)doc.GetElement(vp.ViewId);

                if (
                    v.ViewType == revitDB.ViewType.FloorPlan ||
                    v.ViewType == revitDB.ViewType.CeilingPlan ||
                    v.ViewType == revitDB.ViewType.Elevation ||
                    v.ViewType == revitDB.ViewType.ThreeD ||
                    v.ViewType == revitDB.ViewType.DraftingView ||
                    v.ViewType == revitDB.ViewType.AreaPlan ||
                    v.ViewType == revitDB.ViewType.Section ||
                    v.ViewType == revitDB.ViewType.Detail ||
                    v.ViewType == revitDB.ViewType.Rendering
                    )
                {
                    viewPorts.Add(vp);

                    revitDB.Parameter param = vp.get_Parameter(revitDB.BuiltInParameter.VIEWPORT_DETAIL_NUMBER);
                    if (param != null)
                    {
                        param.Set("!!" + i);
                    }
                    i++;
                }
            }
            return(viewPorts);
        }
Beispiel #5
0
        /// <summary>
        /// Changes the workset of an element.
        /// </summary>
        /// <param name="element">Dynamo Elements.</param>
        /// <param name="workset">A revit workset</param>
        /// <returns name="element">The element that was changed.  Returns null if the change was unsuccessfull.</returns>
        public static dynamoElement SetElementWorkset(dynamoElement element, Workset workset)
        {
            //Get Revit Document object
            revitDoc doc = DocumentManager.Instance.CurrentDBDocument;

            Autodesk.Revit.DB.Element unwrapped = element.InternalElement;

            WorksetId wId = unwrapped.WorksetId;

            Autodesk.Revit.DB.Parameter wsParam = unwrapped.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM);
            if (wsParam == null)
            {
                return(null);
            }
            if (doc.IsModifiable)
            {
                wsParam.Set(workset.internalId.IntegerValue);
            }
            else
            {
                using (Autodesk.Revit.DB.Transaction tx = new Autodesk.Revit.DB.Transaction(doc))
                {
                    tx.Start("Change Element's Workset");
                    wsParam.Set(workset.internalId.IntegerValue);
                    tx.Commit();
                }
            }
            return(unwrapped.ToDSType(true));;
        }
        public Dictionary <string, List <CEGRebarInfo> > GetAllRebar(Document doc)
        {
            Dictionary <string, List <CEGRebarInfo> > dic  = new Dictionary <string, List <CEGRebarInfo> >();
            Dictionary <string, List <CEGRebarInfo> > dic2 = new Dictionary <string, List <CEGRebarInfo> >();
            List <FamilyInstance> col            = (from FamilyInstance x in new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_SpecialityEquipment).OfClass(typeof(FamilyInstance)) where x.Symbol.LookupParameter("BAR_SHAPE") != null select x).Cast <FamilyInstance>().ToList();
            ProgressbarWPF        progressbarWPF = new ProgressbarWPF(col.Count, "Export Schedule Rebar")
            {
                topmessage = "Collecting rebar..."
            };

            progressbarWPF.Show();
            foreach (var item in col)
            {
                progressbarWPF.Giatri();
                if (!progressbarWPF.iscontinue)
                {
                    break;
                }
                Autodesk.Revit.DB.Parameter parameter = (item != null) ? item.Symbol.LookupParameter("BAR_SHAPE") : null;
                bool fg = string.IsNullOrEmpty((parameter != null) ? parameter.AsString() : null);
                if (!fg)
                {
                    CEGRebarInfo rebar = new CEGRebarInfo(item);
                    if (rebar.UnistImperial != null && rebar.UnistImperial != "")
                    {
                        if (dic.ContainsKey(rebar.UnistImperial))
                        {
                            dic[rebar.UnistImperial].Add(rebar);
                        }
                        else
                        {
                            dic.Add(rebar.UnistImperial, new List <CEGRebarInfo> {
                                rebar
                            });
                        }
                    }
                }
            }
            var keys = dic.Keys.ToList();

            Caculator(keys);
            foreach (var item in keys)
            {
                foreach (var item2 in dic[item])
                {
                    if (dic2.ContainsKey(item2.UnistImperial))
                    {
                        dic2[item2.UnistImperial].Add(item2);
                    }
                    else
                    {
                        dic2.Add(item2.UnistImperial, new List <CEGRebarInfo> {
                            item2
                        });
                    }
                }
            }
            progressbarWPF.Close();
            return(dic2);
        }
Beispiel #7
0
        public static Model.ParameterValue AsValue(this Autodesk.Revit.DB.Parameter p)
        {
            string text   = null;
            double number = 0;

            switch (p.StorageType)
            {
            case Autodesk.Revit.DB.StorageType.String:
                text = p.AsString();
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Text, ValueText = text
                });

            case Autodesk.Revit.DB.StorageType.ElementId:
                text = revitData.Document.GetElement(p.AsElementId()).Name;
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Text, ValueText = text
                });

            case Autodesk.Revit.DB.StorageType.Integer:
                number = p.AsInteger();
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Number, ValueNumber = number
                });

            case Autodesk.Revit.DB.StorageType.Double:
                number = p.AsDouble().GetConvertValue(p.DisplayUnitType);
                return(new Model.ParameterValue {
                    ParameterValueType = ParameterValueType.Number, ValueNumber = number
                });
            }
            throw new Exception("Đoạn code này không được đọc tới.");
        }
Beispiel #8
0
        /// <summary>
        /// Method is taken from here:
        /// https://spiderinnet.typepad.com/blog/2011/08/revit-parameter-api-asvaluestring-tostring-tovaluestring-and-tovaluedisplaystring.html
        /// </summary>
        /// <param name="p">Revit parameter</param>
        /// <returns>Stringified contents of the parameter</returns>
        internal static string ToValueString(this Autodesk.Revit.DB.Parameter p)
        {
            string ret = string.Empty;

            switch (p.StorageType)
            {
            case StorageType.ElementId:
                ret = p.AsValueString().ToString();
                break;

            case StorageType.Integer:
                ret = p.AsInteger().ToString();
                break;

            case StorageType.String:
                ret = p.AsString();
                break;

            case StorageType.Double:
                ret = p.AsValueString();
                break;

            default:
                break;
            }

            return(ret);
        }
        private void Load()
        {
            DirectoryInfo d        = new DirectoryInfo(_data.Setting.GetFolderPath());
            var           p        = d.GetFiles().ToList();
            string        filename = lb_view.SelectedItem.ToString();
            string        pathfile = "";

            foreach (var item in p)
            {
                if (item.Name.Replace(".json", "") == filename)
                {
                    pathfile = item.FullName;
                    break;
                }
            }
            var             json    = File.ReadAllText(pathfile);
            CegParameterSet dictemp = JsonConvert.DeserializeObject <CegParameterSet>(json);

            a.ViewSheet viewSheet = _doc.ActiveView as a.ViewSheet;
            using (a.Transaction tran = new a.Transaction(_doc, "Set Parameter Sheet"))
            {
                tran.Start();
                foreach (var item in dictemp.Parameters)
                {
                    foreach (var item2 in _data.dic.Parameters)
                    {
                        if (item.Value.Name == item2.Value.Name)
                        {
                            a.Parameter pa = viewSheet.LookupParameter(item2.Value.Name);
                            if (pa != null)
                            {
                                a.InternalDefinition definition = pa.Definition as a.InternalDefinition;
                                if (definition.BuiltInParameter != a.BuiltInParameter.SHEET_NAME && definition.BuiltInParameter != a.BuiltInParameter.SHEET_NUMBER)
                                {
                                    switch (item2.Value.Type)
                                    {
                                    case a.StorageType.Double:
                                        pa.Set(item.Value.AsDouble);
                                        break;

                                    case a.StorageType.String:
                                        pa.Set(item.Value.AsString);
                                        break;

                                    case a.StorageType.Integer:
                                        pa.Set(item.Value.AsInteger);
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                tran.Commit();
            }
            Close();
        }
Beispiel #10
0
        private static void _transferParameters(RevitElem SourceElement, RevitElem DestinationElement)
        {
            RevitDB.ParameterSet sourceParameters = SourceElement.Parameters;

            foreach (RevitDB.Parameter sourceParam in sourceParameters)
            {
                if (sourceParam.IsReadOnly == false)
                {
                    RevitDB.Definition def = sourceParam.Definition;
                    RevitDB.Parameter  destinationParam = DestinationElement.get_Parameter(def);

                    RevitDB.StorageType st = sourceParam.StorageType;
                    switch (st)
                    {
                    case RevitDB.StorageType.Double:
                        destinationParam.Set(sourceParam.AsDouble());
                        break;

                    case RevitDB.StorageType.ElementId:
                        destinationParam.Set(sourceParam.AsElementId());
                        break;

                    case RevitDB.StorageType.Integer:
                        destinationParam.Set(sourceParam.AsInteger());
                        break;

                    case RevitDB.StorageType.String:
                        destinationParam.Set(sourceParam.AsString());
                        break;
                    }
                }
            }
        }
Beispiel #11
0
        private static string GetParameterValue(Parameter param)
        {
            string s;

            switch (param.StorageType)
            {
            case StorageType.Double:
                s = param.AsValueString();
                break;

            case StorageType.Integer:
                s = param.AsInteger().ToString();
                break;

            case StorageType.String:
                s = param.AsString();
                break;

            case StorageType.ElementId:
                s = param.AsValueString() == string.Empty ? param.AsElementId().IntegerValue.ToString() : param.AsValueString();
                break;

            case StorageType.None:
                s = "?NONE?";
                break;

            default:
                s = "?ELSE?";
                break;
            }

            return(s);
        }
Beispiel #12
0
        public static Dictionary <string, List <Element> > GetFilteredElementsByCategory(Document doc)
        {
            var sortedElements = new Dictionary <string, List <Element> >();

            var els = new FilteredElementCollector(doc)
                      .WhereElementIsNotElementType()
                      .WhereElementIsViewIndependent()
                      .Where(e => (e.Category != null) && e.Category.HasMaterialQuantities);

            foreach (Element e in els)
            {
                Parameter volume = e.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED); // Check if element isVoid or Solid. Void elements have volume=0
                if ((e is FamilyInstance fs && (fs.SuperComponent != null)) || ((volume != null) && !volume.HasValue))
                {
                    continue;
                }

                if (!sortedElements.ContainsKey(e.Category.Name))
                {
                    sortedElements.Add(e.Category.Name, new List <Element>());
                }

                sortedElements[e.Category.Name].Add(e);
            }

            return(sortedElements);
        }
Beispiel #13
0
        SetParameter(Revit.Parameter parameterToSet, Revit.ParameterSet parameterSet)
        {
            foreach (Revit.Parameter param in parameterSet)
            {
                if (param.Definition.Name == parameterToSet.Definition.Name)
                {
                    switch (param.StorageType)
                    {
                    case Revit.StorageType.Double:
                        parameterToSet.Set(param.AsDouble());
                        break;

                    case Revit.StorageType.ElementId:
                        Revit.ElementId elemId = param.AsElementId();
                        parameterToSet.Set(elemId);
                        break;

                    case Revit.StorageType.Integer:
                        parameterToSet.Set(param.AsInteger());
                        break;

                    case Revit.StorageType.String:
                        parameterToSet.Set(param.AsString());
                        break;
                    }
                    return;
                }
            }
        }
Beispiel #14
0
        public FamilyinstanceInfo(FamilyInstance familyInstance)
        {
            ID = familyInstance.Id;
            Autodesk.Revit.DB.Parameter parameter = familyInstance.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
            if (parameter != null)
            {
                var value = parameter.AsString();
                if (value != null)
                {
                    Workplane = value;
                }
                else
                {
                    Workplane = "";
                }
            }
            if (familyInstance.Name.Contains("CONN"))
            {
                Name = familyInstance.Name;
            }
            else
            {
                Name = "(" + familyInstance.Symbol.FamilyName + ")" + " " + familyInstance.Name;
            }
            LocationPoint locationPoint = familyInstance.Location as LocationPoint;

            location = locationPoint.Point;
        }
Beispiel #15
0
        public GroupInstanceInfo(FamilyInstance familyInstance)
        {
            ID = familyInstance.Id.ToString();
            Autodesk.Revit.DB.Parameter parameter = familyInstance.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
            if (parameter != null)
            {
                var value = parameter.AsString();
                if (value != null)
                {
                    Workplane = value;
                }
                else
                {
                    Workplane = "";
                }
            }

            if (familyInstance.Name.Contains("CONN"))
            {
                Name = familyInstance.Name;
            }
            else
            {
                Name = "(" + familyInstance.Symbol.FamilyName + ")" + " " + familyInstance.Name;
            }
            location       = (familyInstance.Location as LocationPoint).Point;
            Origintranform = familyInstance.GetTransform().Origin;
            Handing        = familyInstance.HandOrientation.ToString() + familyInstance.Name;
            Transform      = familyInstance.GetTransform();
            Bassic         = ((familyInstance.GetTransform().BasisX) + ";" + (familyInstance.GetTransform().BasisY) + ";" + (familyInstance.GetTransform().BasisZ)).ToString();
        }
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            Autodesk.Revit.DB.Parameter parameter = null;
            if (!DA.GetData("ParameterValue", ref parameter))
            {
                return;
            }

            DA.SetData("Group", parameter?.Definition.ParameterGroup);
            DA.SetData("Type", parameter?.Definition.ParameterType);
            if (parameter?.Element is ElementType)
            {
                DA.SetData("Binding", RevitAPI.ParameterBinding.Type);
            }
            else if (parameter?.Element is Element)
            {
                DA.SetData("Binding", RevitAPI.ParameterBinding.Instance);
            }
            else
            {
                DA.SetData("Binding", null);
            }
            DA.SetData("Unit", parameter?.Definition.UnitType);
            DA.SetData("IsReadOnly", parameter?.IsReadOnly);
            DA.SetData("UserModifiable", parameter?.UserModifiable);
        }
Beispiel #17
0
        /// <summary>
        /// Return type Of Parameter
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static string GetParameterType(this Autodesk.Revit.DB.Parameter parameter)
        {
            ParameterType pt = parameter.Definition.ParameterType; // returns 'Invalid' for 'ElementId'
            string        s  = ParameterType.Invalid == pt ? "" : "/" + pt;

            return(parameter.StorageType + s);
        }
        public static void SetPipeDiameter(Pipe pipe, double diameter)
        {
            RevitLibrary.Parameter parameter = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM);
            Console.Write(parameter.DisplayUnitType);
            double value = UnitUtils.Convert(diameter, DisplayUnitType.DUT_MILLIMETERS, parameter.DisplayUnitType);

            parameter.Set(value);
        }
Beispiel #19
0
        public double rebarCover(Element e)
        {
            Autodesk.Revit.DB.Parameter rcPara = e.LookupParameter("Rebar Cover - Exterior Face");
            ElementId      rcId   = rcPara.AsElementId();
            RebarCoverType rcType = doc.GetElement(rcId) as ElementType as RebarCoverType;

            return(rcType.CoverDistance);;
        }
Beispiel #20
0
 public static Dictionary <string, object> GetParameterNameAndValue(Autodesk.Revit.DB.Parameter parameter)
 {
     return(new Dictionary <string, object>
     {
         { "Name", parameter.Definition.Name },
         { "Value", parameter.AsValueString() },
     });
 }
Beispiel #21
0
        public static void SetParameterValue(Autodesk.Revit.DB.Parameter param, Element value)
        {
            if (param.StorageType != StorageType.ElementId)
            {
                throw new Exception(Properties.Resources.ParameterStorageNotElement);
            }

            param.Set(value.InternalElement.Id);
        }
Beispiel #22
0
        /// <summary>
        /// Initialize a Wall element
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="wallType"></param>
        /// <param name="baseLevel"></param>
        /// <param name="height"></param>
        /// <param name="offset"></param>
        /// <param name="flip"></param>
        /// <param name="isStructural"></param>
        private void InitWall(Curve curve, Autodesk.Revit.DB.WallType wallType, Autodesk.Revit.DB.Level baseLevel, double height, double offset, bool flip, bool isStructural)
        {
            // This creates a new wall and deletes the old one
            TransactionManager.Instance.EnsureInTransaction(Document);

            //Phase 1 - Check to see if the object exists and should be rebound
            var wallElem =
                ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.Wall>(Document);

            bool successfullyUsedExistingWall = false;

            //There was a modelcurve, try and set sketch plane
            // if you can't, rebuild
            if (wallElem != null && wallElem.Location is Autodesk.Revit.DB.LocationCurve)
            {
                var wallLocation = wallElem.Location as Autodesk.Revit.DB.LocationCurve;
                if ((wallLocation.Curve is Autodesk.Revit.DB.Line == curve is Autodesk.Revit.DB.Line) ||
                    (wallLocation.Curve is Autodesk.Revit.DB.Arc == curve is Autodesk.Revit.DB.Arc) ||
                    (wallLocation.Curve is Autodesk.Revit.DB.Ellipse == curve is Autodesk.Revit.DB.Ellipse))
                {
                    if (!CurveUtils.CurvesAreSimilar(wallLocation.Curve, curve))
                    {
                        wallLocation.Curve = curve;
                    }

                    Autodesk.Revit.DB.Parameter baseLevelParameter =
                        wallElem.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.WALL_BASE_CONSTRAINT);
                    Autodesk.Revit.DB.Parameter topOffsetParameter =
                        wallElem.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM);
                    Autodesk.Revit.DB.Parameter wallTypeParameter =
                        wallElem.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.ELEM_TYPE_PARAM);
                    if (baseLevelParameter.AsElementId() != baseLevel.Id)
                    {
                        baseLevelParameter.Set(baseLevel.Id);
                    }
                    if (Math.Abs(topOffsetParameter.AsDouble() - height) > 1.0e-10)
                    {
                        topOffsetParameter.Set(height);
                    }
                    if (wallTypeParameter.AsElementId() != wallType.Id)
                    {
                        wallTypeParameter.Set(wallType.Id);
                    }
                    successfullyUsedExistingWall = true;
                }
            }

            var wall = successfullyUsedExistingWall ? wallElem :
                       Autodesk.Revit.DB.Wall.Create(Document, curve, wallType.Id, baseLevel.Id, height, offset, flip, isStructural);

            InternalSetWall(wall);

            TransactionManager.Instance.TransactionTaskDone();

            // delete the element stored in trace and add this new one
            ElementBinder.CleanupAndSetElementForTrace(Document, InternalWall);
        }
Beispiel #23
0
        private void SetParameterValue(Autodesk.Revit.DB.Parameter param, Revit.Elements.Element value)
        {
            if (param.StorageType != StorageType.ElementId)
            {
                throw new Exception("The parameter's storage type is not an Element.");
            }

            param.Set(value.InternalElementId);
        }
Beispiel #24
0
        private void SetParameterValue(Autodesk.Revit.DB.Parameter param, SIUnit value)
        {
            if (param.StorageType != StorageType.Double)
            {
                throw new Exception("The parameter's storage type is not an integer.");
            }

            param.Set(value.ConvertToHostUnits());
        }
Beispiel #25
0
        public static void SetParameterValue(Autodesk.Revit.DB.Parameter param, string value)
        {
            if (param.StorageType != StorageType.String)
            {
                throw new Exception(Properties.Resources.ParameterStorageNotString);
            }

            param.Set(value);
        }
Beispiel #26
0
        private void SetParameterValue(Autodesk.Revit.DB.Parameter param, bool value)
        {
            if (param.StorageType != StorageType.Integer)
            {
                throw new Exception("The parameter's storage type is not an integer.");
            }

            param.Set(value == false ? 0 : 1);
        }
Beispiel #27
0
        public static void SetParameterValue(Autodesk.Revit.DB.Parameter param, bool value)
        {
            if (param.StorageType != StorageType.Integer)
            {
                throw new Exception(Properties.Resources.ParameterStorageNotInteger);
            }

            param.Set(value == false ? 0 : 1);
        }
Beispiel #28
0
        private void SetParameterValue(Autodesk.Revit.DB.Parameter param, int value)
        {
            if (param.StorageType != StorageType.Integer && param.StorageType != StorageType.Double)
            {
                throw new Exception("The parameter's storage type is not a number.");
            }

            param.Set(value);
        }
Beispiel #29
0
        private void SetParameterValue(Autodesk.Revit.DB.Parameter param, string value)
        {
            if (param.StorageType != StorageType.String)
            {
                throw new Exception("The parameter's storage type is not a string.");
            }

            param.Set(value);
        }
        public Dictionary <string, Partinfo> GetPartDictionary(Document doc)
        {
            Dictionary <string, Partinfo> dictionary = new Dictionary <string, Partinfo>();
            FilteredElementCollector      filteredElementCollector = new FilteredElementCollector(doc);
            IList <Element> list = filteredElementCollector.OfClass(typeof(FamilyInstance)).ToElements();

            foreach (Element item in list)
            {
                FamilyInstance familyInstance  = item as FamilyInstance;
                FamilyInstance familyInstance2 = familyInstance?.SuperComponent as FamilyInstance;
                if (familyInstance2 != null && familyInstance2.SuperComponent == null)
                {
                    Autodesk.Revit.DB.Parameter parameter = familyInstance.Symbol.LookupParameter("CONTROL_MARK");
                    if (parameter != null && parameter.StorageType == StorageType.String)
                    {
                        string text = parameter.AsString();
                        if (!string.IsNullOrEmpty(text))
                        {
                            string name  = familyInstance2.Symbol.Name;
                            string text2 = familyInstance.LookupParameter("BOM_PRODUCT_HOST")?.AsString() ?? "";
                            if (dictionary.ContainsKey(text))
                            {
                                if (string.IsNullOrEmpty(dictionary[text].ProductName))
                                {
                                    dictionary[text].ProductName = text2;
                                }
                                else if (!dictionary[text].ProductName.Contains(text2))
                                {
                                    dictionary[text].ProductName = dictionary[text].ProductName + "; " + text2;
                                }
                                if (dictionary[text].Connection == null)
                                {
                                    dictionary[text].Connection = name;
                                }
                                else if (!dictionary[text].Connection.Contains(name))
                                {
                                    dictionary[text].Connection = dictionary[text].Connection + "; " + name;
                                }
                            }
                            else
                            {
                                dictionary[text] = new Partinfo
                                {
                                    ProductName = text2
                                };
                                string description = familyInstance.Symbol.LookupParameter("IDENTITY_DESCRIPTION")?.AsString();
                                dictionary[text].Description = description;
                                dictionary[text].Connection  = name;
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }
Beispiel #31
0
 internal Parameter(Autodesk.Revit.DB.Parameter internalParameter)
 {
     this.InternalParameter = internalParameter;
 }