private void LoadFammilyInstance(Transaction transaction, ComparisonCoupleElement openingData)
        {
            //tạo moi openning va tien hanh save data vao extensible va lay GUID luu vào ComparisonCoupleElement.RevitId
            StrAchOpenningMaker openningMaker = new StrAchOpenningMaker(_doc, openingData);

            openningMaker.CreateOpenning(transaction);
        }
Exemplo n.º 2
0
 public void FindAndAddListComparisonCoupleElement(Document document, List <CompareCoupleWithManager> listComparisonCoupleElement, ObservableCollection <Obj> Objs)
 {
     if (listComparisonCoupleElement != null)
     {
         for (int i = 0; i < listComparisonCoupleElement.ToList().Count; i++)
         {
             ComparisonCoupleElement  comparisonCoupleElement  = listComparisonCoupleElement.ToList()[i];
             CompareCoupleWithManager compareCoupleWithManager = listComparisonCoupleElement.ToList()[i];
             //comparisonCoupleElement.Action = Action.NONE;
             Obj objNew = new Obj(ref comparisonCoupleElement, document);
             if (objNew != null)
             {
                 ObservableCollection <InfileObject> InfileObjects = new ObservableCollection <InfileObject>();
                 foreach (string fileName in compareCoupleWithManager.DrawingsContain)
                 {
                     InfileObject infileObject = new InfileObject(fileName);
                     InfileObjects.Add(infileObject);
                 }
                 objNew.Infile = InfileObjects;
                 if (objNew.Infile != null && objNew.Infile.Count > 0)
                 {
                     objNew.CurrentInfile = objNew.Infile[0];
                 }
                 Objs.Add(objNew);
             }
         }
     }
 }
 private void AddOpeningFromStack(ComparisonCoupleElement coupleElement)
 {
     if (coupleElement.Action.Equals(Model.Action.PULL))
     {
         _openingLocalPullAction.Add(ElementSendServer.CreateWithStack(coupleElement));
     }
 }
Exemplo n.º 4
0
 public MEPOpeningMaker(Document document, ComparisonCoupleElement openningModel, string projectName = "")
 {
     _doc = document;
     _comparionCoupleElement = openningModel;
     _openningModel          = openningModel.ServerGeometry;
     GetValueGeometry(openningModel.ServerGeometry);
     if (Common.IsEqual(_direction, XYZ.BasisZ) || Common.IsEqual(_direction, XYZ.BasisZ.Negate()))
     {
         _isVertical = true;
         if (_shapeProfile == Define.RECTANGLE_FAMILY)
         {
             _openningName = Define.FLOOR_OPENNING_RECTANGLE_NAME_MEP;
         }
         else if (_shapeProfile == Define.CYLYNDER_FAMILY)
         {
             _openningName = Define.FLOOR_OPENNING_CYLYNDER_NAME_MEP;
         }
     }
     else
     {
         _isVertical = false;
         if (_shapeProfile == Define.RECTANGLE_FAMILY)
         {
             _openningName = Define.WALL_OPENNING_RECTANGLE_NAME_MEP;
         }
         else if (_shapeProfile == Define.CYLYNDER_FAMILY)
         {
             _openningName = Define.WALL_OPENNING_CYLYNDER_NAME_MEP;
         }
     }
 }
        public static void SetValueToExtensibleStorage(ComparisonCoupleElement openningModel, Element openning, string subject)
        {
            Schema schema = DefineSchemaBuilder(subject);
            Entity entity = new Entity(schema);

            SetValueStringGeometryToExtensibleStorage(ref schema, ref entity, openningModel);
            openning.SetEntity(entity);
        }
Exemplo n.º 6
0
        private void Implement(ComparisonCoupleElement comparisonCoupleElement)
        {
            GeometryDetail openningModelSever = comparisonCoupleElement.ServerGeometry;
            GeometryDetail openningModelLocal = comparisonCoupleElement.LocalGeometry;

            OpeningName = comparisonCoupleElement.Name;
            if (openningModelLocal != null)
            {
                if (openningModelLocal.Original != null)
                {
                    string original = GetOriginalStrFromJson(openningModelLocal.Original);
                    CoordinateCurent = original;
                }

                if (openningModelLocal.Geometry != null)
                {
                    string geometry = GetGeometryStrFromJson(openningModelLocal.Geometry);
                    DimentionCurent = geometry;
                }

                if (openningModelLocal.Direction != null)
                {
                    string direction = GetDirectionStrFromJson(openningModelLocal.Direction);
                    DirectionCurent = direction;
                }

                if (comparisonCoupleElement.CurrentVersionGeometryOfLocal != null)
                {
                    ElementVersionCurent = comparisonCoupleElement.CurrentVersionGeometryOfLocal;
                }
            }
            if (openningModelSever != null)
            {
                if (openningModelSever.Original != null)
                {
                    string original = GetOriginalStrFromJson(openningModelSever.Original);
                    CoordinateLastest = original;
                }
                if (openningModelSever.Geometry != null)
                {
                    string geometry = GetGeometryStrFromJson(openningModelSever.Geometry);
                    DimentionLastest = geometry;
                }
                if (openningModelSever.Direction != null)
                {
                    string direction = GetDirectionStrFromJson(openningModelSever.Direction);
                    DirectionLastest = direction;
                }
                if (openningModelSever.Version != null)
                {
                    ElementVersionLastest     = openningModelSever.Version;
                    ElementVersionLastestDate = String.Format("{0:f}", openningModelSever.UpdatedDate);
                }
            }
            Id             = comparisonCoupleElement.Id;
            revitElementId = comparisonCoupleElement.IdRevitElement;
            _comment       = comparisonCoupleElement.Comment;
        }
Exemplo n.º 7
0
        public void saveDataToExtensibleStorage(Document document, ComparisonCoupleElement openningModel, ElementId openningId, string subject)
        {
            Element openning = document.GetElement(openningId);

            if (openning != null)
            {
                OpenningProcessExtensibleStorage.SetValueToExtensibleStorage(openningModel, openning, subject);
            }
        }
        private void saveDataToExtensibleStorage(ComparisonCoupleElement openningModel, ElementId openningId)
        {
            Element openning = _doc.GetElement(openningId);

            if (openning != null)
            {
                OpenningProcessExtensibleStorage.SetValueToExtensibleStorage(openningModel, openning, _subject);
            }
        }
Exemplo n.º 9
0
        private void UpdateDirection(ElementId id, ComparisonCoupleElement openningModel)
        {
            XYZ    basicZ    = XYZ.BasisZ;
            XYZ    direction = ConvertOpenningStringToObjectReVit.getDirection(openningModel.ServerGeometry.Direction);
            XYZ    axisVec   = basicZ.CrossProduct(direction);
            Line   axis      = Line.CreateBound(axisVec, axisVec * 2);
            double angle     = basicZ.AngleOnPlaneTo(direction, axisVec);

            ElementTransformUtils.RotateElement(_doc, id, axis, angle);
        }
Exemplo n.º 10
0
 public static ElementSendServer CreateWithStack(ComparisonCoupleElement coupleElement)
 {
     return(new ElementSendServer()
     {
         Id = coupleElement.Id,
         IdManager = coupleElement.IdManager,
         IdRevitElement = coupleElement.IdRevitElement,
         Geometry = coupleElement.ServerGeometry,
         ServerStatus = DefineStatus.NONE,
         LocalStatus = DefineStatus.NONE,
         Comment = coupleElement.Comment,
         DifferenceGeometry = !coupleElement.IsSameShapeAndLocation()
     });
 }
Exemplo n.º 11
0
 public static ElementSendServer Create(ComparisonCoupleElement coupleElement)
 {
     return(new ElementSendServer()
     {
         Id = coupleElement.Id,
         IdManager = coupleElement.IdManager,
         IdRevitElement = coupleElement.IdRevitElement,
         Geometry = coupleElement.Action == Model.Action.PUSH ? coupleElement.LocalGeometry : coupleElement.ServerGeometry,
         ServerStatus = coupleElement.ServerStatus,
         LocalStatus = coupleElement.LocalStatus,
         Comment = coupleElement.Comment,
         DifferenceGeometry = !coupleElement.IsSameShapeAndLocation()
     });
 }
 private void AddOpeningToSpecificGroup(ComparisonCoupleElement coupleElement)
 {
     if (coupleElement.Action.Equals(Model.Action.PULL))
     {
         _openingLocalPullAction.Add(ElementSendServer.Create(coupleElement));
     }
     else if (coupleElement.Action.Equals(Model.Action.PUSH))
     {
         _openingLocalPushAction.Add(ElementSendServer.Create(coupleElement));
     }
     else if (coupleElement.Action.Equals(Model.Action.DISCONNECT))
     {
         _openingLocalDisconnect.Add(ElementSendServer.Create(coupleElement));
     }
 }
Exemplo n.º 13
0
 public void FindAndAddListComparisonCoupleElement(Document document, List <ComparisonCoupleElement> listComparisonCoupleElement, ObservableCollection <Obj> Objs)
 {
     if (listComparisonCoupleElement != null)
     {
         for (int i = 0; i < listComparisonCoupleElement.Count(); i++)
         {
             ComparisonCoupleElement comparisonCoupleElement = listComparisonCoupleElement.ElementAt(i);
             Obj objNew = new Obj(ref comparisonCoupleElement, document);
             if (objNew != null)
             {
                 Objs.Add(objNew);
             }
         }
     }
 }
Exemplo n.º 14
0
        public Obj(ref ComparisonCoupleElement comparisonCoupleElement, Document document)
        {
            _level = "None";

            _doc       = document;
            IsSelected = false;
            ObjActions = new ObservableCollection <StatusItem>();
            StatusItem pull       = new StatusItem("PUSH");
            StatusItem push       = new StatusItem("PULL");
            StatusItem none       = new StatusItem("NONE");
            StatusItem disconnect = new StatusItem("DISCONNECT");

            ObjActions.Add(pull);
            ObjActions.Add(push);
            ObjActions.Add(none);
            ObjActions.Add(disconnect);

            _comparisonCoupleElement = comparisonCoupleElement;
            Implement(_comparisonCoupleElement);

            SolidColorBrush greenBrush = new SolidColorBrush();

            greenBrush.Color = Colors.Green;

            SolidColorBrush redBrush = new SolidColorBrush();

            redBrush.Color = Colors.Red;

            SolidColorBrush purpleBrush = new SolidColorBrush();

            redBrush.Color = Colors.Purple;

            SolidColorBrush yelowBrush = new SolidColorBrush();

            yelowBrush.Color = Colors.Orange;

            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;

            if (_comparisonCoupleElement.Action != OpeningClient.Model.Action.DISCONNECT)
            {
                if (_comparisonCoupleElement.LocalGeometry != null && _comparisonCoupleElement.ServerGeometry != null)
                {
                    if (!_comparisonCoupleElement.IsSameShapeAndLocation())
                    {
                        if (ElementVersionCurent == ElementVersionLastest)
                        {
                            _comparisonCoupleElement.Action = OpeningClient.Model.Action.PUSH;
                            Status = "Edit by Curent User";
                        }
                        else
                        {
                            _comparisonCoupleElement.Action = OpeningClient.Model.Action.PULL;
                            Status = "Edit by Another User";
                        }

                        _colorStatus = yelowBrush;
                    }
                    else
                    {
                        _comparisonCoupleElement.Action = OpeningClient.Model.Action.NONE;
                        Status       = "Nomal";
                        _colorStatus = greenBrush;
                    }
                }
                else
                {
                    if (_comparisonCoupleElement.ServerStatus != "Disconnect")
                    {
                        if (_comparisonCoupleElement.LocalGeometry == null)
                        {
                            _comparisonCoupleElement.Action = OpeningClient.Model.Action.NONE;
                            if (_comparisonCoupleElement.LocalStatus == "Deleted")
                            {
                                Status       = "Deleting";
                                _colorStatus = redBrush;
                            }
                            else
                            {
                                Status       = "New Opening From Server";
                                _colorStatus = blueBrush;
                            }
                        }
                        else if (_comparisonCoupleElement.ServerGeometry == null)
                        {
                            _comparisonCoupleElement.Action = OpeningClient.Model.Action.NONE;
                            if (_comparisonCoupleElement.ServerStatus == "PendingDelete")
                            {
                                Status       = "Pending Delete";
                                _colorStatus = redBrush;
                            }
                            else
                            {
                                Status       = "New Opening From Drawing";
                                _colorStatus = blueBrush;
                            }
                        }
                    }
                    else
                    {
                        if (_comparisonCoupleElement.LocalGeometry == null)
                        {
                            _comparisonCoupleElement.Action = OpeningClient.Model.Action.DISCONNECT;
                            Status       = "Deleting";
                            _colorStatus = redBrush;
                        }
                        else if (_comparisonCoupleElement.ServerGeometry == null)
                        {
                            _comparisonCoupleElement.Action = OpeningClient.Model.Action.DISCONNECT;
                            Status       = "Pending Delete";
                            _colorStatus = redBrush;
                        }
                        else if (_comparisonCoupleElement.LocalGeometry == null &&
                                 _comparisonCoupleElement.ServerGeometry == null)
                        {
                            _comparisonCoupleElement.Action = OpeningClient.Model.Action.DISCONNECT;
                            Status       = "Deleted";
                            _colorStatus = redBrush;
                        }
                    }
                }
            }
            else if (_comparisonCoupleElement.Action == OpeningClient.Model.Action.DISCONNECT)
            {
                _colorStatus = purpleBrush;
                Status       = "Disconect";
            }

            OnPropertyChanged(new PropertyChangedEventArgs(nameof(ColorStatus)));
            OpeningClient.Model.Action action = _comparisonCoupleElement.Action;
            switch (action)
            {
            case OpeningClient.Model.Action.PUSH:
                CurrentAction = ObjActions[0];    //.Where(x => x.Name == "PUSH") as StatusItem;
                break;

            case OpeningClient.Model.Action.PULL:
                CurrentAction = ObjActions.Where(x => x.Name == "PULL").First() as StatusItem;
                break;

            case OpeningClient.Model.Action.NONE:
                CurrentAction = ObjActions.Where(x => x.Name == "NONE").First() as StatusItem;
                break;

            case OpeningClient.Model.Action.DISCONNECT:
                CurrentAction = ObjActions.Where(x => x.Name == "DISCONNECT").First() as StatusItem;
                break;
            }
            Level level = GetlevelFromOpening();

            if (_comparisonCoupleElement.LocalGeometry != null)
            {
                XYZ curentLocation = GetOriginalFromJson(_comparisonCoupleElement.LocalGeometry.Original);
                if (level != null)
                {
                    _level = level.Name;
                }
                else
                {
                    _level = "None";
                }
                Grid grid1 = GetNearestGridInLevel(level, curentLocation, out Grid seconLocalGr);
                if (grid1 != null)
                {
                    _markLocationCurent = grid1.Name;
                }
                if (seconLocalGr != null)
                {
                    _markLocationCurent += ("-" + seconLocalGr.Name);
                }
            }

            if (_comparisonCoupleElement.LocalGeometry == null && _comparisonCoupleElement.ServerGeometry != null)
            {
                XYZ lastestLocation = GetOriginalFromJson(_comparisonCoupleElement.ServerGeometry.Original);
                _level = level.Name;
                Grid grid = GetNearestGridInLevel(level, lastestLocation, out Grid seconSeverGr);
                if (grid != null)
                {
                    _markLocationLastest = grid.Name;
                }
                if (seconSeverGr != null)
                {
                    _markLocationLastest += ("-" + seconSeverGr.Name);
                }
            }

            if (_level == "")
            {
                _level = "NULL";
            }

            if (_markLocationLastest == null || _markLocationLastest == "")
            {
                _markLocationLastest = "NULL";
            }

            if (_markLocationCurent == null || _markLocationCurent == "")
            {
                _markLocationCurent = "NULL";
            }

            if (/*_comparisonCoupleElement.LocalGeometry == null && */ _comparisonCoupleElement.ServerGeometry != null)
            {
                if (DimentionLastest.Contains("Cylynder"))
                {
                    ElementName += "Cylynder_";
                }
                else
                {
                    ElementName += "Rectangle_";
                }
                if (DirectionLastest.Contains("0/0/1"))
                {
                    ElementName += "Floor/";
                }
                else
                {
                    ElementName += "Window/";
                }
            }
            else if (_comparisonCoupleElement.LocalGeometry != null /*&& _comparisonCoupleElement.ServerGeometry == null*/)
            {
                if (DimentionCurent.Contains("Cylynder"))
                {
                    ElementName += "Cylynder_";
                }
                else
                {
                    ElementName += "Rectangle_";
                }
                if (DirectionCurent.Contains("0/0/1"))
                {
                    ElementName += "Floor_";
                }
                else
                {
                    ElementName += "Window_";
                }
            }

            ElementName += Level + "/";
            if (_markLocationCurent != "NULL")
            {
                ElementName += _markLocationCurent + "/";
            }
            if (_markLocationLastest != "NULL")
            {
                ElementName += _markLocationLastest + "/";
            }

            if (OpeningName != null && OpeningName != "")
            {
                ElementName += OpeningName;
            }
        }
Exemplo n.º 15
0
        private void LoadFammilyInstance(Transaction transaction, ComparisonCoupleElement openingData)
        {
            MEPOpeningMaker mEPOpeningMaker = new MEPOpeningMaker(_doc, openingData, _projectName);

            mEPOpeningMaker.LoadFammilyInstance(transaction);
        }
Exemplo n.º 16
0
        private void UpdateGeometryAndDirection(Transaction transaction, Element element, ComparisonCoupleElement openningModel)
        {
            StrAchOpenningMaker openningMaker = new StrAchOpenningMaker(_doc, openningModel);

            openningMaker.EditOpening(transaction, element);
            //saveDataToExtensibleStorage(openningModel, element.Id);
        }
Exemplo n.º 17
0
        private void UpdateGeometryAndDirection(Transaction transaction, ElementId id, ComparisonCoupleElement openningModel)
        {
            MEPOpeningMaker mEPOpeningMaker = new MEPOpeningMaker(_doc, openningModel, _projectName);

            mEPOpeningMaker.UpdateGeometryAndDirection(transaction, id);
        }
Exemplo n.º 18
0
 public static ElementSendDTO ComparisonToElementToSend(this ComparisonCoupleElement comparisonCoupleElement)
 {
     return(new ElementSendDTO()
     {
     });
 }
 public static void SetValueStringGeometryToExtensibleStorage(ref Schema schema, ref Entity entity, ComparisonCoupleElement openningModel)
 {
     try {
         entity.Set <string>(schema.GetField(Define.CommonId), openningModel.IdManager);
         //entity.Set<string>(schema.GetField(Define.ElementId), openningModel.IdLocal);
         //entity.Set<string>(schema.GetField(Define.DrawingId), openningModel.IdDrawing);
         //entity.Set<string>(schema.GetField(Define.CreateDate), openningModel.CreateDate);
         //entity.Set<string>(schema.GetField(Define.UpdatedDate), openningModel.Geometry.UpdatedDate);
         if (openningModel.LocalStatus != null)
         {
             entity.Set <string>(schema.GetField(Define.ElementVersionStatus), openningModel.LocalStatus);
         }
         //entity.Set<string>(schema.GetField(Define.UserID), openningModel.Geometry.UserID);
         //entity.Set<string>(schema.GetField(Define.VersionId), openningModel.Geometry.VersionId);
         //entity.Set<string>(schema.GetField(Define.RevitElementCommonId), openningModel.Geometry.RevitElementCommonId);
         if (openningModel.ServerGeometry.Geometry != null)
         {
             entity.Set <string>(schema.GetField(Define.Geometry), openningModel.ServerGeometry.Geometry);
         }
         if (openningModel.ServerGeometry.Original != null)
         {
             entity.Set <string>(schema.GetField(Define.Original), openningModel.ServerGeometry.Original);
         }
         if (openningModel.ServerGeometry.Direction != null)
         {
             entity.Set <string>(schema.GetField(Define.Direction), openningModel.ServerGeometry.Direction);
         }
         //entity.Set<string>(schema.GetField(Define.Status), openningModel.Geometry.Status.ToString());
         //entity.Set<string>(schema.GetField(Define.Description), openningModel.Geometry.Description);
         //entity.Set<string>(schema.GetField(Define.UpdatedDate), openningModel.Geometry.UpdatedDate);
         //entity.Set<string>(schema.GetField(Define.CreateUserId), openningModel.CreateUserId);
     }
     catch (Exception ex) {
         TaskDialog.Show(" ", ex.ToString());
     }
 }