public TypeBrowserDialog(IfcElementType elementType)
        {
            InitializeComponent();
            ElementTypeIfcProperties property = new ElementTypeIfcProperties(elementType);

            propertyGrid1.SelectedObject = property;
        }
Пример #2
0
        /// <summary>
        ///   Returns the Material Select or creates
        /// </summary>
        /// <param name = "elemType"></param>
        /// <returns></returns>
        public static void SetMaterial(this IfcElementType elemType, IfcMaterialSelect matSel)
        {
            if (matSel is IfcMaterialLayerSetUsage)
            {
                throw new Exception("IfcElementType cannot have an IfcMaterialLayerSetUsage as its associated material");
            }

            IfcRelAssociatesMaterial relMat =
                elemType.HasAssociations.OfType <IfcRelAssociatesMaterial>().FirstOrDefault();

            if (relMat == null)
            {
                IModel model = elemType.ModelOf;
                if (model == null)
                {
                    throw new Exception("IfcElementType is not contained in a valid model");
                }
                else
                {
                    relMat = model.Instances.New <IfcRelAssociatesMaterial>();
                    relMat.RelatedObjects.Add(elemType);
                }
            }
            relMat.RelatingMaterial = matSel;
        }
Пример #3
0
        internal ElementTypeIfcProperties(IfcElementType type) : base(type)
        {
            string keyword  = type.KeyWord;
            bool   readOnly = true;

            foreach (IfcPropertySet pset in type.HasPropertySets.OfType <IfcPropertySet>())
            {
                foreach (IfcPropertySingleValue psv in pset.HasProperties.Values.ToList().OfType <IfcPropertySingleValue>())
                {
                    IfcValue val = psv.NominalValue;
                    if (val == null)
                    {
                        Add(new CustomProperty(psv.Name, "", typeof(string), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                    else
                    {
                        Object obj = val.Value;
                        Add(new CustomProperty(psv.Name, obj, obj.GetType(), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                }
            }
        }
Пример #4
0
        internal static IfcMetric CreateConstraint(string name, IfcElementType elementType, IfcResourceObjectSelect related, string referenceDesc)
        {
            IfcMetric metric = new IfcMetric(elementType.Database, name, IfcConstraintEnum.HARD)
            {
                ReferencePath = IfcReference.ParseDescription(elementType.Database, referenceDesc), BenchMark = IfcBenchmarkEnum.EQUALTO
            };
            IfcResourceConstraintRelationship rcr = new IfcResourceConstraintRelationship(metric, related);

            new IfcRelAssociatesConstraint(elementType, metric);
            return(metric);
        }
Пример #5
0
        public static IfcMaterialSelect GetMaterial(this IfcElementType elemType)
        {
            IfcRelAssociatesMaterial relMat =
                elemType.HasAssociations.OfType <IfcRelAssociatesMaterial>().FirstOrDefault();

            if (relMat != null)
            {
                return(relMat.RelatingMaterial);
            }
            else
            {
                return(null);
            }
        }
        public void Execute(UIApplication uiapp)
        {
            try
            {
                ICollection <ElementId> elementIds = uiapp.ActiveUIDocument.Selection.GetElementIds();
                string   path     = Path.GetTempPath();
                Document document = uiapp.ActiveUIDocument.Document;
                if (document.IsFamilyDocument || elementIds.Count == 0)
                {
                    mBrowser.mBrowserControl.propertyGrid.SelectedObject = null;
                    return;
                }
                string           ids     = string.Join(";", elementIds.ToList().ConvertAll(x => x.ToString()));
                IFCExportOptions options = new IFCExportOptions();
                options.AddOption("ElementsForExport", ids);
                string      fileName    = Path.GetFileNameWithoutExtension(document.PathName) + ".ifc";
                Transaction transaction = new Transaction(document, "Export IFC");
                transaction.Start();

                document.Export(path, fileName, options);
                transaction.RollBack();
                DatabaseIfc db = new DatabaseIfc(Path.Combine(path, fileName));

                List <IfcElement> elements = db.Context.Extract <IfcElement>();
                if (elements.Count > 0)
                {
                    IEnumerable <object> properties = elements.ConvertAll(x => new ElementIfcProperties(x));
                    IfcElementType       type       = elements[0].RelatingType as IfcElementType;
                    if (type != null)
                    {
                        foreach (IfcElement e in elements)
                        {
                            IfcElementType t = e.RelatingType as IfcElementType;
                            if (t == null || type.Index != t.Index)
                            {
                                type = null;
                                break;
                            }
                        }
                    }
                    mBrowser.mBrowserControl.propertyGrid.SelectedObjects = properties.ToArray();
                    mBrowser.mBrowserControl.ElementType = type;
                }
            }
            finally
            {
            }
            return;
        }
Пример #7
0
 private static ElementType ToElementType(this IfcElementType elementType)
 {
     if (elementType is IfcCoveringType)
     {
         throw new NotImplementedException();
     }
     if (elementType is IfcBeamType)
     {
         return(((IfcBeamType)elementType).ToStructuralFramingType());
     }
     if (elementType is IfcMemberType)
     {
         throw new NotImplementedException();
     }
     if (elementType is IfcColumnType)
     {
         return(((IfcColumnType)elementType).ToStructuralFramingType());
     }
     if (elementType is IfcWallType)
     {
         throw new NotImplementedException();
     }
     if (elementType is IfcSlabType)
     {
         return(((IfcSlabType)elementType).ToFloorType());
     }
     if (elementType is IfcStairFlightType)
     {
         throw new NotImplementedException();
     }
     if (elementType is IfcRampFlightType)
     {
         throw new NotImplementedException();
     }
     if (elementType is IfcCurtainWallType)
     {
         throw new NotImplementedException();
     }
     if (elementType is IfcRailingType)
     {
         throw new NotImplementedException();
     }
     if (elementType is IfcBuildingElementProxyType)
     {
         throw new NotImplementedException();
     }
     return(null);
 }
Пример #8
0
        internal ElementIfcProperties(IfcElement element) : base(element)
        {
            string keyword  = element.KeyWord;
            bool   readOnly = true;

            Add(new CustomProperty("ObjectType", element.ObjectType, typeof(string), readOnly, true)
            {
                Group = keyword
            });
            Add(new CustomProperty("Type", element.GetType().Name, typeof(string), true, true)
            {
                Group = keyword
            });
            Add(new CustomProperty("Tag", element.Tag, typeof(string), readOnly, true)
            {
                Group = keyword
            });

            IfcElementType elementType = element.RelatingType as IfcElementType;

            if (elementType != null)
            {
                List.Add(new ElementTypeIfcProperties(elementType));
            }
            foreach (IfcPropertySet pset in element.IsDefinedBy.ToList().ConvertAll(x => x.RelatingPropertyDefinition).OfType <IfcPropertySet>())
            {
                foreach (IfcPropertySingleValue psv in pset.HasProperties.Values.ToList().OfType <IfcPropertySingleValue>())
                {
                    IfcValue val = psv.NominalValue;
                    if (val == null)
                    {
                        Add(new CustomProperty(psv.Name, "", typeof(string), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                    else
                    {
                        Object obj = val.Value;
                        Add(new CustomProperty(psv.Name, obj, obj.GetType(), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                }
            }
        }