Esempio n. 1
0
        public static void GetFamilyComponentReferencePlanes(FamilyComponent famcomponent, Document doc, User user)
        {
            if (doc != null)
            {
                if (famcomponent.RefferencePlaneItems.InternalCollection.Count <= 0)
                {
                    List <Element> referencePlaneElementList = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.ReferencePlane)).ToElements() as List <Element>;
                    foreach (Element element in referencePlaneElementList)
                    {
                        Autodesk.Revit.DB.ReferencePlane plane = (Autodesk.Revit.DB.ReferencePlane)element as Autodesk.Revit.DB.ReferencePlane;
                        ModBox.FamFactory.Revit.Manager.ReferencePlane refPlane = ReferencePlane.NewReferencePlane(famcomponent.internalSQLConenction, famcomponent.RefferencePlaneItems.InternalDataView, user);
                        refPlane.Name      = plane.Name;
                        refPlane.FamiltyId = famcomponent.Id;
                        refPlane.ElementId = plane.Id.IntegerValue;
                        refPlane.UniqueId  = plane.UniqueId;
                        refPlane.LevelId   = plane.LevelId.IntegerValue;
                        refPlane.ViewId    = plane.OwnerViewId.IntegerValue;

                        if (plane.Category != null)
                        {
                            refPlane.Category = plane.Category.Name;
                        }
                        else
                        {
                            refPlane.Category = "None";
                        }

                        refPlane.DirectionX = plane.Direction.X;
                        refPlane.DirectionY = plane.Direction.Y;
                        refPlane.DirectionZ = plane.Direction.Z;
                        refPlane.BubbleEndX = plane.BubbleEnd.X;
                        refPlane.BubbleEndY = plane.BubbleEnd.Y;
                        refPlane.BubbleEndZ = plane.BubbleEnd.Z;
                        refPlane.NormalX    = plane.Normal.X;
                        refPlane.NormalY    = plane.Normal.Y;
                        refPlane.NormalZ    = plane.Normal.Z;
                        refPlane.FreeEndX   = plane.FreeEnd.X;
                        refPlane.FreeEndY   = plane.FreeEnd.Y;
                        refPlane.FreeEndZ   = plane.FreeEnd.Z;
                        refPlane.IsActive   = true;
                        refPlane.EndEdit();
                    }
                    famcomponent.ParameterItems.RefreshCollections();
                }
                else
                {
                }
            }
        }
Esempio n. 2
0
        public static void GetFamilyComponentParameters(FamilyComponent famComponent, Document doc, User user)
        {
            if (famComponent.ParameterItems.InternalCollection.Count <= 0)
            {
                foreach (Autodesk.Revit.DB.FamilyParameter item in doc.FamilyManager.Parameters)
                {
                    Parameter parameter = Parameter.newParameter(famComponent.internalSQLConenction, famComponent.ParameterItems.InternalDataView, user);
                    parameter.FamilyId  = famComponent.Id;
                    parameter.Name      = item.Definition.Name;
                    parameter.ElementId = item.Id.IntegerValue;
                    parameter.IsShared  = item.IsShared;
                    if (parameter.IsShared)
                    {
                        parameter.ElementGUID = item.GUID.ToString();
                    }
                    else
                    {
                        parameter.ElementGUID = string.Empty;
                    }
                    parameter.HasValue          = false;
                    parameter.IsInstance        = item.IsInstance;
                    parameter.IsReadOnly        = item.IsReadOnly;
                    parameter.IsReporting       = item.IsReporting;
                    parameter.StorageType       = (int)item.StorageType;
                    parameter.BuiltInParamGroup = (int)item.Definition.ParameterGroup;
                    parameter.ParameterType     = (int)item.Definition.ParameterType;
                    parameter.UnitType          = (int)item.Definition.UnitType;

                    try
                    {
                        parameter.DisplayUnitType = (int)item.DisplayUnitType;
                    }
                    catch (Exception e)
                    {
                        parameter.DisplayUnitType = (int)Autodesk.Revit.DB.DisplayUnitType.DUT_UNDEFINED;
                    }

                    parameter.UserModifiable        = item.UserModifiable;
                    parameter.IsDeterminedByFormula = item.IsDeterminedByFormula;
                    parameter.Formula    = item.Formula;
                    parameter.IsActive   = false;
                    parameter.IsEditable = true;
                    parameter.EndEdit();
                }
                famComponent.ParameterItems.RefreshCollections();
            }
        }
Esempio n. 3
0
        public static void GetFamilyComponentFeatures(FamilyComponent famComponent, Document doc, User user)
        {
            if (famComponent.FamilyGeometryItems.InternalCollection.Count <= 0)
            {
                if (doc != null)
                {
                    List <Element> sweepElementList      = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Sweep)).ToElements() as List <Element>;
                    List <Element> extrudeElementList    = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Extrusion)).ToElements() as List <Element>;
                    List <Element> blendElementList      = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Blend)).ToElements() as List <Element>;
                    List <Element> sweptBlendElementList = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.SweptBlend)).ToElements() as List <Element>;
                    List <Element> revolveElementList    = new FilteredElementCollector(doc).OfClass(typeof(Autodesk.Revit.DB.Revolution)).ToElements() as List <Element>;

                    foreach (Element element in sweepElementList)
                    {
                        Autodesk.Revit.DB.Sweep sweep          = (Autodesk.Revit.DB.Sweep)element as Autodesk.Revit.DB.Sweep;
                        FamilyGeometry          familyGeometry = FamilyGeometry.NewFamilyGeometry(famComponent.internalSQLConenction, famComponent.FamilyGeometryItems.InternalDataView, user);
                        familyGeometry.Name        = sweep.Name;
                        familyGeometry.ElementId   = sweep.Id.IntegerValue;
                        familyGeometry.Description = string.Empty;

                        if (sweep.Category != null)
                        {
                            familyGeometry.Category = sweep.Category.Name;
                        }
                        else
                        {
                            familyGeometry.Category = "None";
                        }

                        if (sweep.Subcategory != null)
                        {
                            familyGeometry.SubCategory = sweep.Subcategory.Name;
                        }
                        else
                        {
                            familyGeometry.SubCategory = "None";
                        }

                        familyGeometry.FamilyId     = famComponent.Id;
                        familyGeometry.GeometryType = sweep.Name;
                        familyGeometry.UniqueId     = sweep.UniqueId;
                        familyGeometry.OwnerViewId  = sweep.OwnerViewId.IntegerValue;
                        familyGeometry.LevelId      = sweep.LevelId.IntegerValue;
                        familyGeometry.IsSolid      = sweep.IsSolid;
                        familyGeometry.MaterialId   = 0;
                        familyGeometry.CreatedById  = user.Id;
                        familyGeometry.CreatedBy    = user;
                        familyGeometry.ModifiedBy   = user;
                        familyGeometry.ModifiedById = user.Id;
                        familyGeometry.EndEdit();
                    }

                    foreach (Element element in extrudeElementList)
                    {
                        Autodesk.Revit.DB.Extrusion extrude = (Autodesk.Revit.DB.Extrusion)element as Autodesk.Revit.DB.Extrusion;
                        FamilyGeometry familyGeometry       = FamilyGeometry.NewFamilyGeometry(famComponent.internalSQLConenction, famComponent.FamilyGeometryItems.InternalDataView, user);
                        familyGeometry.Name        = extrude.Name;
                        familyGeometry.ElementId   = extrude.Id.IntegerValue;
                        familyGeometry.Description = string.Empty;

                        if (extrude.Category != null)
                        {
                            familyGeometry.Category = extrude.Category.Name;
                        }
                        else
                        {
                            familyGeometry.Category = "None";
                        }

                        if (extrude.Subcategory != null)
                        {
                            familyGeometry.SubCategory = extrude.Subcategory.Name;
                        }
                        else
                        {
                            familyGeometry.SubCategory = "None";
                        }

                        familyGeometry.FamilyId     = famComponent.Id;
                        familyGeometry.GeometryType = extrude.Name;
                        familyGeometry.UniqueId     = extrude.UniqueId;
                        familyGeometry.OwnerViewId  = extrude.OwnerViewId.IntegerValue;
                        familyGeometry.LevelId      = extrude.LevelId.IntegerValue;
                        familyGeometry.IsSolid      = extrude.IsSolid;
                        familyGeometry.MaterialId   = 0;
                        familyGeometry.CreatedById  = user.Id;
                        familyGeometry.CreatedBy    = user;
                        familyGeometry.ModifiedBy   = user;
                        familyGeometry.ModifiedById = user.Id;
                        familyGeometry.EndEdit();
                    }
                    foreach (Element element in blendElementList)
                    {
                        Autodesk.Revit.DB.Blend blend          = (Autodesk.Revit.DB.Blend)element as Autodesk.Revit.DB.Blend;
                        FamilyGeometry          familyGeometry = FamilyGeometry.NewFamilyGeometry(famComponent.internalSQLConenction, famComponent.FamilyGeometryItems.InternalDataView, user);
                        familyGeometry.Name        = blend.Name;
                        familyGeometry.ElementId   = blend.Id.IntegerValue;
                        familyGeometry.Description = string.Empty;

                        if (blend.Category != null)
                        {
                            familyGeometry.Category = blend.Category.Name;
                        }
                        else
                        {
                            familyGeometry.Category = "None";
                        }

                        if (blend.Subcategory != null)
                        {
                            familyGeometry.SubCategory = blend.Subcategory.Name;
                        }
                        else
                        {
                            familyGeometry.SubCategory = "None";
                        }

                        familyGeometry.FamilyId     = famComponent.Id;
                        familyGeometry.GeometryType = blend.Name;
                        familyGeometry.UniqueId     = blend.UniqueId;
                        familyGeometry.OwnerViewId  = blend.OwnerViewId.IntegerValue;
                        familyGeometry.LevelId      = blend.LevelId.IntegerValue;
                        familyGeometry.IsSolid      = blend.IsSolid;
                        familyGeometry.MaterialId   = 0;
                        familyGeometry.CreatedById  = user.Id;
                        familyGeometry.CreatedBy    = user;
                        familyGeometry.ModifiedBy   = user;
                        familyGeometry.ModifiedById = user.Id;
                        familyGeometry.EndEdit();
                    }
                    foreach (Element element in sweptBlendElementList)
                    {
                        Autodesk.Revit.DB.SweptBlend weptblend = (Autodesk.Revit.DB.SweptBlend)element as Autodesk.Revit.DB.SweptBlend;
                        FamilyGeometry familyGeometry          = FamilyGeometry.NewFamilyGeometry(famComponent.internalSQLConenction, famComponent.FamilyGeometryItems.InternalDataView, user);
                        familyGeometry.Name        = weptblend.Name;
                        familyGeometry.ElementId   = weptblend.Id.IntegerValue;
                        familyGeometry.Description = string.Empty;

                        if (weptblend.Category != null)
                        {
                            familyGeometry.Category = weptblend.Category.Name;
                        }
                        else
                        {
                            familyGeometry.Category = "None";
                        }

                        if (weptblend.Subcategory != null)
                        {
                            familyGeometry.SubCategory = weptblend.Subcategory.Name;
                        }
                        else
                        {
                            familyGeometry.SubCategory = "None";
                        }

                        familyGeometry.FamilyId     = famComponent.Id;
                        familyGeometry.GeometryType = "SweptBlend";
                        familyGeometry.UniqueId     = weptblend.UniqueId;
                        familyGeometry.OwnerViewId  = weptblend.OwnerViewId.IntegerValue;
                        familyGeometry.LevelId      = weptblend.LevelId.IntegerValue;
                        familyGeometry.IsSolid      = weptblend.IsSolid;
                        familyGeometry.MaterialId   = 0;
                        familyGeometry.CreatedById  = user.Id;
                        familyGeometry.CreatedBy    = user;
                        familyGeometry.ModifiedBy   = user;
                        familyGeometry.ModifiedById = user.Id;
                        familyGeometry.EndEdit();
                    }
                    foreach (Element element in revolveElementList)
                    {
                        Autodesk.Revit.DB.Revolution revolve = (Autodesk.Revit.DB.Revolution)element as Autodesk.Revit.DB.Revolution;
                        FamilyGeometry familyGeometry        = FamilyGeometry.NewFamilyGeometry(famComponent.internalSQLConenction, famComponent.FamilyGeometryItems.InternalDataView, user);
                        familyGeometry.Name        = revolve.Name;
                        familyGeometry.ElementId   = revolve.Id.IntegerValue;
                        familyGeometry.Description = string.Empty;

                        if (revolve.Category != null)
                        {
                            familyGeometry.Category = revolve.Category.Name;
                        }
                        else
                        {
                            familyGeometry.Category = "None";
                        }

                        if (revolve.Subcategory != null)
                        {
                            familyGeometry.SubCategory = revolve.Subcategory.Name;
                        }
                        else
                        {
                            familyGeometry.SubCategory = "None";
                        }

                        familyGeometry.FamilyId     = famComponent.Id;
                        familyGeometry.GeometryType = revolve.Name;
                        familyGeometry.UniqueId     = revolve.UniqueId;
                        familyGeometry.OwnerViewId  = revolve.OwnerViewId.IntegerValue;
                        familyGeometry.LevelId      = revolve.LevelId.IntegerValue;
                        familyGeometry.IsSolid      = revolve.IsSolid;
                        familyGeometry.MaterialId   = 0;
                        familyGeometry.CreatedById  = user.Id;
                        familyGeometry.CreatedBy    = user;
                        familyGeometry.ModifiedBy   = user;
                        familyGeometry.ModifiedById = user.Id;
                        familyGeometry.EndEdit();
                    }
                    famComponent.ParameterItems.RefreshCollections();
                }
            }
            else
            {
            }
        }