コード例 #1
0
        public static void AddNewDisconnector(Point3d StartPoint, Point3d EndPoint, ObjectId GroupOI)
        {
            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Disconnector).Scale;
            //Database db = Application.DocumentManager.MdiActiveDocument.Database;
            DrawDisconnectorJig _DrawDisconnectorJig = new DrawDisconnectorJig(MyScale);
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //ed.WriteMessage("start22:{0} end22:{1} \n", StartPoint, EndPoint);
            ObjectIdCollection OIC = new ObjectIdCollection();

            foreach (Entity ent in _DrawDisconnectorJig.GetDemoForEdit(StartPoint, EndPoint))
            {
                //Group group = tr.GetObject(GroupOI, OpenMode.ForWrite, true) as Group;
                //if (group != null)
                //{
                //ObjectId[] objs = group.GetAllEntityIds();
                //foreach (ObjectId id in objs)
                //{

                //    OIC.Add(id);

                //}
                ObjectId NewOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                OIC.Add(NewOI);
                Atend.Base.Acad.AT_INFO _AT_INFO = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(GroupOI);
                _AT_INFO.SelectedObjectId = NewOI;
                _AT_INFO.Insert();


                //}
            }
            Atend.Global.Acad.Global.AddObjectToGroup(GroupOI, OIC);
            //ed.WriteMessage("add to group for new drawing finished\n");
            //}
            //}
        }
コード例 #2
0
        /// <summary>
        /// this method had command before for drwing
        /// </summary>
        public void DrawConnectionPoint()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            DrawConnectionPointJig DCP = new DrawConnectionPointJig();

            bool Conti = true;

            PromptResult pr;

            while (Conti)
            {
                pr = ed.Drag(DCP);

                if (pr.Status == PromptStatus.OK)
                {
                    Conti = false;

                    // time to draw

                    Entity entity = DCP.GetEntity();

                    Atend.Global.Acad.UAcad.DrawEntityOnScreen(entity, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                    Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO();

                    at_info.ParentCode       = "";
                    at_info.NodeCode         = "";
                    at_info.NodeType         = (int)Atend.Control.Enum.ProductType.ConnectionPoint;
                    at_info.ProductCode      = 0;
                    at_info.SelectedObjectId = entity.ObjectId;
                    at_info.Insert();
                }
            }
        }
コード例 #3
0
        public static ObjectId DrawConnectionPoint(Point3d CenterPoint, ObjectId ParentOI)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            DrawConnectionPointJig DCP = new DrawConnectionPointJig();
            Entity   ent          = DCP.GetDemo(CenterPoint);
            ObjectId ConnectionOI = ObjectId.Null;

            if (ent != null)
            {
                ConnectionOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());


                Atend.Base.Acad.AT_INFO ParentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI);

                Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(ConnectionOI);
                //ed.WriteMessage("ParentCode For connection Point: {0}\n", ParentInfo.NodeCode);
                at_info.ParentCode  = ParentInfo.NodeCode;
                at_info.NodeCode    = "";
                at_info.NodeType    = (int)Atend.Control.Enum.ProductType.ConnectionPoint;
                at_info.ProductCode = 0;
                at_info.Insert();

                Atend.Base.Acad.AT_SUB ConnectionPSub = new Atend.Base.Acad.AT_SUB(ConnectionOI);
                ConnectionPSub.SubIdCollection.Add(ParentOI);
                ConnectionPSub.Insert();

                Atend.Base.Acad.AT_SUB.AddToAT_SUB(ConnectionOI, ParentOI);
            }
            return(ConnectionOI);
        }
コード例 #4
0
        public bool UpdateRodData(Guid EXCode)
        {
            Editor           ed = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbTransaction aTransaction;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();
                try
                {
                    RodPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode);
                    //ed.WriteMessage("**RodPAck.Code={0}\n",RodPack.Code);
                    if (!UseAccess)
                    {
                        if (!ERod.AccessInsert(aTransaction, aConnection, true, true))
                        {
                            throw new System.Exception("eRod.AccessInsert failed");
                        }
                    }
                    RodPack.IsExistance = Existance;
                    RodPack.ProductCode = ERod.Code;
                    RodPack.ProjectCode = ProjectCode;
                    RodPack.Number      = "";
                    if (RodPack.AccessUpdate(aTransaction, aConnection))
                    {
                        //ed.WriteMessage("ERod.Code={0},SelectedRod.ObjId={1}\n",ERod.Code,selectedObjectId);
                        Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);// id);

                        atinfo.ProductCode = ERod.Code;
                        atinfo.Insert();
                        ChangeComment(selectedObjectId, ERod.Comment);
                    }
                    else
                    {
                        throw new System.Exception("RodPack.AccessInsert2 failed");
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR Updaterod 01(transaction) : {0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR UpdateRod 01 : {0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }

            aTransaction.Commit();
            aConnection.Close();
            return(true);
        }
コード例 #5
0
ファイル: AcDrawLight.cs プロジェクト: ParisaMousavi/ATEND
        public bool UpdateLightData(Guid EXCode)
        {
            Editor           ed = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbTransaction aTransaction;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();
                try
                {
                    LightPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode);
                    if (!UseAccess)
                    {
                        if (!eLight.AccessInsert(aTransaction, aConnection, true, true))
                        {
                            throw new System.Exception("eLight.AccessInsert failed");
                        }
                    }
                    LightPack.IsExistance = Existance;
                    LightPack.ProjectCode = ProjectCode;
                    LightPack.ProductCode = eLight.Code;
                    LightPack.Number      = "";
                    if (LightPack.AccessUpdate(aTransaction, aConnection))
                    {
                        Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);
                        atinfo.ProductCode = eLight.Code;
                        atinfo.Insert();
                        ChangeComment(Atend.Global.Acad.UAcad.GetEntityGroup(selectedObjectId), eLight.Comment);
                    }
                    else
                    {
                        throw new System.Exception("LightPack.AccessInsert2 failed");
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR UpdateLight 01(transaction) : {0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR UpdateLight 01 : {0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }

            aTransaction.Commit();
            aConnection.Close();
            return(true);
        }
コード例 #6
0
        public bool UpdateKalampData(Guid NodeCode)
        {
            Editor           ed          = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);
            OleDbTransaction aTransaction;

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();
                try
                {
                    ClampPack = Atend.Base.Design.DPackage.AccessSelectByCode(NodeCode);
                    if (!UseAccess)
                    {
                        if (!eClamp.AccessInsert(aTransaction, aConnection, true, true))//aTransaction, aConnection))??
                        {
                            throw new System.Exception("eClamp.AccessInsert failed");
                        }
                    }
                    ClampPack.IsExistance = Existance;
                    ClampPack.ProductCode = eClamp.Code;
                    ClampPack.ProjectCode = ProjectCode;
                    if (ClampPack.AccessUpdate())
                    {
                        Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);
                        atinfo.ProductCode = eClamp.Code;
                        atinfo.Insert();
                    }
                    else
                    {
                        throw new System.Exception("ClampPack.AccessInsert2 failed");
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR UpdateKalampData 01 : {0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR UpdateKalampData 01 : {0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }
            aTransaction.Commit();
            aConnection.Close();
            return(true);
        }
コード例 #7
0
ファイル: AcDrawKablsho.cs プロジェクト: ParisaMousavi/ATEND
 public bool SaveKablshoDataForExternalCall(Atend.Base.Acad.AT_INFO NodeInformation)
 {
     if (!SaveKablshoData())
     {
         return(false);
     }
     else
     {
         NodeInformation.ProductCode = KablshoPack.ProductCode;
         NodeInformation.NodeCode    = KablshoPack.Code.ToString();
         NodeInformation.Insert();
     }
     return(true);
 }
コード例 #8
0
ファイル: AcDrawCatOut.cs プロジェクト: ParisaMousavi/ATEND
        public static void AddNewCatout(Point3d StartPoint, Point3d EndPoint, ObjectId GroupOI)
        {
            double             MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.CatOut).Scale;
            DrawCatOutJig      _DrawCatOutJig = new DrawCatOutJig(MyScale);
            Editor             ed             = Application.DocumentManager.MdiActiveDocument.Editor;
            ObjectIdCollection OIC            = new ObjectIdCollection();

            foreach (Entity ent in _DrawCatOutJig.GetDemoForEdit(StartPoint, EndPoint))
            {
                ObjectId NewOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                OIC.Add(NewOI);
                Atend.Base.Acad.AT_INFO _AT_INFO = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(GroupOI);
                _AT_INFO.SelectedObjectId = NewOI;
                _AT_INFO.Insert();
            }
            Atend.Global.Acad.Global.AddObjectToGroup(GroupOI, OIC);
        }
コード例 #9
0
ファイル: AcDrawBreaker.cs プロジェクト: ParisaMousavi/ATEND
        public static void AddNewBreaker(Point3d StartPoint, Point3d EndPoint, ObjectId GroupOI)
        {
            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Breaker).Scale;

            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //ed.WriteMessage("start22:{0} end22:{1} \n", StartPoint, EndPoint);
            DrawBreakerJig     _DrawBreakerJig = new DrawBreakerJig(MyScale);
            ObjectIdCollection OIC             = new ObjectIdCollection();

            foreach (Entity ent in _DrawBreakerJig.GetDemoForEdit(StartPoint, EndPoint))
            {
                //ed.WriteMessage("each entity \n");
                ObjectId NewOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                OIC.Add(NewOI);
                Atend.Base.Acad.AT_INFO _AT_INFO = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(GroupOI);
                _AT_INFO.SelectedObjectId = NewOI;
                _AT_INFO.Insert();


                //Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
            }
            //ed.WriteMessage("add to group \n");
            Atend.Global.Acad.Global.AddObjectToGroup(GroupOI, OIC);
        }
コード例 #10
0
        public void DrawGround02()
        {
            Editor ed    = Application.DocumentManager.MdiActiveDocument.Editor;
            bool   conti = true;
            //ed.WriteMessage("1\n");
            List <Entity> Entities;
            //ed.WriteMessage("2\n");
            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Ground).Scale;
            //ed.WriteMessage("3\n");
            //double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Ground).CommentScale;
            DrawGroundJig02 _DrawGroundJig = new DrawGroundJig02(MyScale);

            while (conti)
            {
                //PromptEntityOptions PEO = new PromptEntityOptions("Select Parent:");
                //PromptEntityResult PER = ed.GetEntity(PEO);
                //if (PER.Status == PromptStatus.OK)
                //{
                //Atend.Base.Acad.AT_INFO SelectedEntityInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(PER.ObjectId);
                //if (SelectedEntityInfo.ParentCode != "NONE")
                //{

                //System.Data.DataTable Parents = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Ground);
                //DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", SelectedEntityInfo.NodeType));
                //if (drs.Length > 0)
                //{
                ObjectId ParentOI = ObjectId.Null;
                while (conti)
                {
                    _DrawGroundJig.GetStartPoint = true;
                    _DrawGroundJig.GetEndPoint   = false;
                    PromptResult pr = ed.Drag(_DrawGroundJig);
                    //pr = ed.Drag(_DrawGroundJig);
                    if (pr.Status == PromptStatus.OK)
                    {
                        if (IsValidParent(_DrawGroundJig.StartPoint, out ParentOI))
                        {
                            _DrawGroundJig.GetStartPoint = false;
                            _DrawGroundJig.GetEndPoint   = true;
                            pr = ed.Drag(_DrawGroundJig);
                            //pr = ed.Drag(_DrawGroundJig);
                            if (pr.Status == PromptStatus.OK)
                            {
                                _DrawGroundJig.GetStartPoint = false;
                                _DrawGroundJig.GetEndPoint   = false;
                                conti = false;

                                Entities = _DrawGroundJig.GetEntities();
                                //foreach (Entity en in Entities)
                                //{
                                //    Atend.Global.Acad.UAcad.DrawEntityOnScreen(en, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                                //}

                                #region SaveData
                                ObjectIdCollection      OIC = new ObjectIdCollection();
                                Atend.Base.Acad.AT_INFO SelectedEntityInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI);
                                if (SaveGroundData(SelectedEntityInfo.NodeCode))
                                {
                                    foreach (Entity ent in Entities)
                                    {
                                        OIC.Add(Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()));

                                        Atend.Base.Acad.AT_INFO GroundInfo = new Atend.Base.Acad.AT_INFO(OIC[OIC.Count - 1]);
                                        GroundInfo.ParentCode  = SelectedEntityInfo.NodeCode;
                                        GroundInfo.NodeCode    = GroundPack.Code.ToString();
                                        GroundInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Ground;
                                        GroundInfo.ProductCode = eGround.Code;
                                        GroundInfo.Insert();
                                    }

                                    ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(GroundPack.Code.ToString(), OIC);
                                    Atend.Base.Acad.AT_INFO GroundGroupInfo = new Atend.Base.Acad.AT_INFO(GOI);
                                    GroundGroupInfo.ParentCode  = SelectedEntityInfo.NodeCode;
                                    GroundGroupInfo.NodeCode    = GroundPack.Code.ToString();
                                    GroundGroupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Ground;
                                    GroundGroupInfo.ProductCode = eGround.Code;
                                    GroundGroupInfo.Insert();


                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, ParentOI);


                                    Atend.Base.Acad.AT_SUB GroundSub = new Atend.Base.Acad.AT_SUB(GOI);
                                    GroundSub.SubIdCollection.Add(ParentOI);
                                    GroundSub.Insert();
                                }

                                #endregion
                            }

                            else
                            {
                                conti = false;
                            }



                            conti = false;
                        }
                    }
                    else
                    {
                        ed.WriteMessage("parent was not valid\n");
                        conti = false;
                    }
                }// end while
                 //}
                 //else
                 //{

                //    string s = "";
                //    foreach (DataRow dr in Parents.Rows)
                //    {
                //        s = s + Atend.Base.Design.DProductProperties.AccessSelectByCodeDrawable(Convert.ToInt32(dr["ContainerCode"])).ProductName + "-";
                //    }
                //    Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification();
                //    notification.Title = "ÇÊÕÇáÇÊ ãÌÇÒ";
                //    notification.Msg = s;
                //    notification.infoCenterBalloon();

                //}
                //}
                //}
                //else
                //{
                //    conti = false;
                //}
            }
        }
コード例 #11
0
ファイル: AcDrawBreaker.cs プロジェクト: ParisaMousavi/ATEND
        //update in tehran 7/15
        public void DrawBreaker()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            //ed.WriteMessage("DRaw BREAKER \n");
            System.Data.DataTable ParentList = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Breaker);
            double V1 = 0;
            double V2 = 0;

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Breaker).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Breaker).CommentScale;

            PromptEntityOptions peo1 = new PromptEntityOptions("Select first node:");
            PromptEntityResult  per  = ed.GetEntity(peo1);

            if (per.Status == PromptStatus.OK)
            {
                Atend.Base.Acad.AT_INFO Info1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId);
                DataRow[] drs = ParentList.Select(string.Format("SoftwareCode={0}", Info1.NodeType));
                if (drs.Length != 0)
                {
                    switch (((Atend.Control.Enum.ProductType)drs[0]["SoftwareCode"]))
                    {
                    case Atend.Control.Enum.ProductType.HeaderCabel:
                        //V1 = Atend.Base.Equipment.EHeaderCabel.AccessSelectByCode(Info1.ProductCode);
                        V1 = 0;
                        break;

                    case Atend.Control.Enum.ProductType.Consol:
                        V1 = Atend.Base.Equipment.EConsol.AccessSelectByCode(Info1.ProductCode).VoltageLevel;
                        break;

                    case Atend.Control.Enum.ProductType.KablSho:
                        //V1 = Atend.Base.Equipment.EKablsho.AccessSelectByCode(Info1.ProductCode);
                        V1 = 0;
                        break;

                    case Atend.Control.Enum.ProductType.Kalamp:
                        V1 = Atend.Base.Equipment.EClamp.AccessSelectByCode(Info1.ProductCode).VoltageLevel;
                        break;
                    }
                    PromptEntityOptions peo2 = new PromptEntityOptions("Select second node:");
                    PromptEntityResult  per1 = ed.GetEntity(peo2);
                    if (per1.Status == PromptStatus.OK)
                    {
                        Atend.Base.Acad.AT_INFO Info2 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per1.ObjectId);
                        DataRow[] drs1 = ParentList.Select(string.Format("SoftwareCode={0}", Info2.NodeType));
                        if (drs1.Length != 0)
                        {
                            switch (((Atend.Control.Enum.ProductType)drs1[0]["SoftwareCode"]))
                            {
                            case Atend.Control.Enum.ProductType.HeaderCabel:
                                //V1 = Atend.Base.Equipment.EHeaderCabel.AccessSelectByCode(Info1.ProductCode);
                                V2 = 0;
                                break;

                            case Atend.Control.Enum.ProductType.Consol:
                                V2 = Atend.Base.Equipment.EConsol.AccessSelectByCode(Info2.ProductCode).VoltageLevel;
                                break;

                            case Atend.Control.Enum.ProductType.KablSho:
                                //V1 = Atend.Base.Equipment.EKablsho.AccessSelectByCode(Info1.ProductCode);
                                V2 = 0;
                                break;

                            case Atend.Control.Enum.ProductType.Kalamp:
                                V2 = Atend.Base.Equipment.EClamp.AccessSelectByCode(Info2.ProductCode).VoltageLevel;
                                break;
                            }

                            if (V1 == V2 && Info1.ParentCode == Info2.ParentCode)
                            {
                                DrawBreakerJig _DrawBreakerJig = new DrawBreakerJig(MyScale);
                                List <Entity>  ents            = _DrawBreakerJig.GetDemo(
                                    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId)),
                                    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per1.ObjectId)));

                                if (SaveBreakerData())
                                {
                                    ObjectIdCollection OIC = new ObjectIdCollection();
                                    foreach (Entity ent in ents)
                                    {
                                        ObjectId TerminalOI = ObjectId.Null;
                                        ObjectId KetOI      = ObjectId.Null;
                                        ObjectId NOI        = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                                        Atend.Global.Acad.AcadJigs.MyLine terminal = ent as Atend.Global.Acad.AcadJigs.MyLine;
                                        if (terminal != null)
                                        {
                                            object ProductType = null;
                                            if (terminal.AdditionalDictionary.TryGetValue("ProductType", out ProductType))
                                            {
                                                if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.Terminal)
                                                {
                                                    //ed.WriteMessage("terminal aws found\n");
                                                    if (ProductType != null)
                                                    {
                                                        TerminalOI = NOI;
                                                    }
                                                }
                                                else if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.Key)
                                                {
                                                    //ed.WriteMessage("Key aws found\n");
                                                    if (ProductType != null)
                                                    {
                                                        KetOI = NOI;
                                                    }
                                                }
                                            }
                                        }
                                        OIC.Add(NOI);



                                        if (TerminalOI == ObjectId.Null)
                                        {
                                            if (KetOI == ObjectId.Null)
                                            {
                                                Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                                groupInfo.NodeCode    = BreakerPack.Code.ToString();
                                                groupInfo.ParentCode  = "";
                                                groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Breaker;
                                                groupInfo.ProductCode = BreakerPack.ProductCode;
                                                groupInfo.Insert();
                                            }
                                            else
                                            {
                                                //ed.WriteMessage("KEYOI != null\n");
                                                Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                                groupInfo.NodeCode    = BreakerPack.Code.ToString();
                                                groupInfo.ParentCode  = "";
                                                groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Key;
                                                groupInfo.ProductCode = BreakerPack.ProductCode;
                                                groupInfo.Insert();
                                            }
                                        }
                                        else
                                        {
                                            Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                            groupInfo.NodeCode    = BreakerPack.Code.ToString();
                                            groupInfo.ParentCode  = "";
                                            groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Terminal;
                                            groupInfo.ProductCode = BreakerPack.ProductCode;
                                            groupInfo.Insert();
                                        }
                                    }

                                    ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(BreakerPack.Code.ToString(), OIC);
                                    //ed.WriteMessage("----<<<<<----GOI:{0}\n",GOI);

                                    Atend.Base.Acad.AT_INFO groupInfo1 = new Atend.Base.Acad.AT_INFO(GOI);
                                    groupInfo1.NodeCode    = BreakerPack.Code.ToString();
                                    groupInfo1.ParentCode  = "";
                                    groupInfo1.NodeType    = (int)Atend.Control.Enum.ProductType.Breaker;
                                    groupInfo1.ProductCode = BreakerPack.ProductCode;
                                    groupInfo1.Insert();


                                    ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(
                                        Atend.Global.Acad.UAcad.WriteNote(eBreaker.Comment,
                                                                          _DrawBreakerJig.MyCenterPoint
                                                                          , MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()
                                        );

                                    Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi);
                                    textInfo.NodeCode    = "";
                                    textInfo.ParentCode  = BreakerPack.Code.ToString();
                                    textInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                                    textInfo.ProductCode = 0;
                                    textInfo.Insert();

                                    Atend.Base.Acad.AT_SUB groupSub = new Atend.Base.Acad.AT_SUB(GOI);
                                    groupSub.SubIdCollection.Add(per.ObjectId);
                                    groupSub.SubIdCollection.Add(per1.ObjectId);
                                    groupSub.SubIdCollection.Add(TextOi);
                                    groupSub.Insert();

                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per.ObjectId);
                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per1.ObjectId);
                                }
                                //Line l = new Line(
                                //    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId)),
                                //    Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per1.ObjectId)));
                                //Atend.Global.Acad.UAcad.DrawEntityOnScreen(l);
                            }
                            else
                            {
                                ed.WriteMessage("Voltage was not ok \n");
                            }
                        } //if (drs1.Length != 0)
                    }     //if (per1.Status == PromptStatus.OK)
                }         //if (drs.Length != 0)
            }             //if (per.Status == PromptStatus.OK )
        }
コード例 #12
0
ファイル: AcDrawKablsho.cs プロジェクト: ParisaMousavi/ATEND
        public ObjectId DrawKablsho02(Point3d CenterPoint)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //ed.WriteMessage("CurrentPoint:{0} \n", CenterPoint);
            ObjectId HeaderOI = ObjectId.Null;


            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.KablSho).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.KablSho).CommentScale;

            System.Data.DataTable Parents            = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.KablSho);
            System.Data.DataTable PointContainerList = Atend.Global.Acad.Global.PointInsideWhichEntity(CenterPoint);
            ObjectId ParentOI = ObjectId.Null;

            foreach (System.Data.DataRow dr in PointContainerList.Rows)
            {
                DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", Convert.ToInt32(dr["Type"])));
                if (drs.Length != 0)
                {
                    ParentOI = new ObjectId(new IntPtr(Convert.ToInt32(dr["ObjectId"])));
                }
            }

            double BaseX = CenterPoint.X - 2.5;
            double BaseY = CenterPoint.Y;

            Atend.Global.Acad.AcadJigs.MyPolyLine pLine = new Atend.Global.Acad.AcadJigs.MyPolyLine();
            //pLine.ColorIndex = 40;
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0);
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY - 5), 0, 0, 0);
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX + 5, BaseY), 0, 0, 0);
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0);
            pLine.Closed = true;

            Matrix3d trans1 = Matrix3d.Scaling(MyScale, CenterPoint);

            pLine.TransformBy(trans1);

            if (SaveKablshoData())
            {
                string LayerName = Atend.Control.Enum.AutoCadLayerName.LOW_GROUND.ToString();
                HeaderOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(pLine, LayerName);
                //ed.WriteMessage("HeaderOI : {0} \n", HeaderOI);
                Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(HeaderOI);
                if (ParentOI != ObjectId.Null)
                {
                    Atend.Base.Acad.AT_INFO parentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI);
                    //ed.WriteMessage("parentInfo.NodeCode:{0} \n", parentInfo.NodeCode);
                    at_info.ParentCode = parentInfo.NodeCode;
                }
                else
                {
                    at_info.ParentCode = "";
                }
                //ed.WriteMessage("HeaderPack.Code:{0} \n", HeaderPack.Code);
                at_info.NodeCode    = KablshoPack.Code.ToString();
                at_info.NodeType    = (int)Atend.Control.Enum.ProductType.KablSho;
                at_info.ProductCode = eKablsho.Code;
                at_info.Insert();


                ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(KablshoPack.Number, Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(HeaderOI)), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());


                Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi);
                textInfo.ParentCode  = KablshoPack.Code.ToString();
                textInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                textInfo.NodeCode    = "";
                textInfo.ProductCode = 0;
                textInfo.Insert();

                Atend.Base.Acad.AT_SUB ConnectionPSub = new Atend.Base.Acad.AT_SUB(HeaderOI);
                ConnectionPSub.SubIdCollection.Add(TextOi);
                if (ParentOI != ObjectId.Null)
                {
                    ConnectionPSub.SubIdCollection.Add(ParentOI);
                }
                ConnectionPSub.Insert();

                if (ParentOI != ObjectId.Null)
                {
                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(HeaderOI, ParentOI);
                }
            }

            //ed.WriteMessage("return from draw header cable \n");
            return(HeaderOI);
        }
コード例 #13
0
        public void DrawMafsal()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            //ed.WriteMessage("aaaaa\n");
            PromptKeywordOptions PSO = new PromptKeywordOptions("\nترسیم مفصل");

            PSO.Keywords.Add("New", "New", "New");
            PSO.Keywords.Add("Break", "Break", "Break Cabel");
            PSO.Keywords.Default = "New";
            PromptResult psr = ed.GetKeywords(PSO);

            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Mafsal).Scale;


            DrawMafsalJig DCP = new DrawMafsalJig(MyScale);

            if (psr.Status == PromptStatus.OK)
            {
                switch (psr.StringResult)
                {
                case "New":

                    bool         Conti = true;
                    PromptResult pr;
                    while (Conti)
                    {
                        pr = ed.Drag(DCP);

                        if (pr.Status == PromptStatus.OK)
                        {
                            Conti = false;
                            Entity entity = DCP.GetEntity();
                            if (SaveMafsalData())
                            {
                                Atend.Global.Acad.UAcad.DrawEntityOnScreen(entity, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                                Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(entity.ObjectId);
                                at_info.ParentCode  = "";
                                at_info.NodeCode    = MafsalInfo.Code.ToString();
                                at_info.NodeType    = (int)Atend.Control.Enum.ProductType.Mafsal;
                                at_info.ProductCode = Convert.ToInt32(MafsalInfo.ProductCode);
                                at_info.Insert();
                            }
                        }
                        else
                        {
                            Conti = false;
                        }
                    }
                    break;

                case "Break":

                    PromptEntityOptions peo = new PromptEntityOptions("\nمحل برش کابل را انتخاب نمایید");
                    PromptEntityResult  per = ed.GetEntity(peo);
                    if (per.Status == PromptStatus.OK)
                    {
                        Polyline SelectedCable = Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId) as Polyline;
                        if (SelectedCable != null)
                        {
                            //////SelectedCable.UpgradeOpen();
                            //////SelectedCable.SetField("Name",new Field("Parisa", true));
                            int     NearestSegmentIndex    = 0;
                            double  NearestSegmentDistance = 100000;
                            Point3d NearestPoint           = Point3d.Origin;
                            for (int counter = 0; counter < SelectedCable.NumberOfVertices - 1; counter++)
                            {
                                LineSegment3d ls1           = new LineSegment3d(SelectedCable.GetPoint3dAt(counter), SelectedCable.GetPoint3dAt(counter + 1));
                                Point3d       SelectedPoint = ls1.GetClosestPointTo(per.PickedPoint).Point;
                                //ed.WriteMessage("SP:{0}\n", SelectedPoint);

                                if (SelectedPoint.DistanceTo(per.PickedPoint) < NearestSegmentDistance)
                                {
                                    NearestSegmentDistance = SelectedPoint.DistanceTo(per.PickedPoint);
                                    NearestSegmentIndex    = counter;
                                    NearestPoint           = SelectedPoint;
                                }
                            }
                            //ed.WriteMessage("SINDEX:{0}\n", NearestSegmentIndex);
                            //seprate Cable

                            Polyline Part1 = new Polyline();
                            Polyline Part2 = new Polyline();
                            for (int counter = 0; counter <= NearestSegmentIndex; counter++)
                            {
                                Part1.AddVertexAt(Part1.NumberOfVertices, SelectedCable.GetPoint2dAt(counter), 0, 0, 0);
                                //ed.WriteMessage("POINT:{0}\n", SelectedCable.GetPoint2dAt(counter));
                            }
                            Part1.AddVertexAt(Part1.NumberOfVertices, new Point2d(NearestPoint.X, NearestPoint.Y), 0, 0, 0);

                            Part2.AddVertexAt(Part2.NumberOfVertices, new Point2d(NearestPoint.X, NearestPoint.Y), 0, 0, 0);
                            for (int counter = NearestSegmentIndex + 1; counter <= SelectedCable.NumberOfVertices - 1; counter++)
                            {
                                Part2.AddVertexAt(Part2.NumberOfVertices, SelectedCable.GetPoint2dAt(counter), 0, 0, 0);
                            }
                            if (SaveMafsalData())
                            {
                                try
                                {
                                    Atend.Base.Acad.AT_INFO LastCableInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId);
                                    Atend.Base.Acad.AT_SUB  LastCableSub  = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(per.ObjectId);
                                    //ed.WriteMessage("-3\n");
                                    //determine header belong to part1 or part2
                                    ObjectIdCollection Blong1 = new ObjectIdCollection();
                                    ObjectIdCollection Blong2 = new ObjectIdCollection();
                                    foreach (ObjectId oi in LastCableSub.SubIdCollection)
                                    {
                                        Atend.Base.Acad.AT_INFO oiInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi);
                                        Point3d FirstPoint             = SelectedCable.GetPoint3dAt(0);
                                        //ed.WriteMessage("-3.1\n");
                                        if (oiInfo.ParentCode != "NONE" && FirstPoint != null)
                                        {
                                            //ed.WriteMessage("-3.2\n");
                                            switch ((Atend.Control.Enum.ProductType)oiInfo.NodeType)
                                            {
                                            case Atend.Control.Enum.ProductType.Mafsal:
                                                //ed.WriteMessage("-3.3\n");
                                                if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == FirstPoint)
                                                {
                                                    //ed.WriteMessage("-3.4\n");
                                                    Blong1.Add(oi);
                                                }
                                                else
                                                {
                                                    //ed.WriteMessage("-3.5\n");
                                                    Blong2.Add(oi);
                                                }
                                                break;

                                            case Atend.Control.Enum.ProductType.HeaderCabel:
                                                //ed.WriteMessage("-3.6\n");
                                                //ed.WriteMessage("color:{0}\n",curv.ColorIndex);
                                                //ed.WriteMessage("-3.6.1\n");
                                                if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == FirstPoint)
                                                {
                                                    //ed.WriteMessage("-3.7\n");
                                                    Blong1.Add(oi);
                                                }
                                                else
                                                {
                                                    //ed.WriteMessage("-3.8\n");
                                                    Blong2.Add(oi);
                                                }
                                                break;

                                            case Atend.Control.Enum.ProductType.ConnectionPoint:
                                                if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == FirstPoint)
                                                {
                                                    Blong1.Add(oi);
                                                }
                                                else
                                                {
                                                    Blong2.Add(oi);
                                                }

                                                break;
                                            }
                                        }
                                    }

                                    Entity   MafsalEntiyt     = DCP.GetDemo(NearestPoint);
                                    ObjectId NewDrawnMafsalOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(MafsalEntiyt, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                                    Atend.Base.Acad.AT_INFO newinfo1 = new Atend.Base.Acad.AT_INFO(NewDrawnMafsalOI);
                                    newinfo1.ParentCode  = "";
                                    newinfo1.NodeCode    = MafsalInfo.Code.ToString();
                                    newinfo1.NodeType    = (int)Atend.Control.Enum.ProductType.Mafsal;
                                    newinfo1.ProductCode = MafsalInfo.ProductCode;
                                    newinfo1.Insert();



                                    //ed.WriteMessage("-4\n");
                                    Atend.Global.Acad.AcadRemove.DeleteEntityByObjectId(SelectedCable.ObjectId);
                                    //ed.WriteMessage("1\n");
                                    Atend.Global.Acad.UAcad.DrawEntityOnScreen(Part1, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString());
                                    //ed.WriteMessage("2\n");
                                    Atend.Global.Acad.UAcad.DrawEntityOnScreen(Part2, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString());
                                    //ed.WriteMessage("3\n");

                                    Atend.Base.Acad.AT_SUB mafsalsub = new Atend.Base.Acad.AT_SUB(NewDrawnMafsalOI);
                                    mafsalsub.SubIdCollection.Add(Part1.ObjectId);
                                    mafsalsub.SubIdCollection.Add(Part2.ObjectId);
                                    mafsalsub.Insert();
                                    //ed.WriteMessage("4\n");

                                    LastCableInfo.SelectedObjectId = Part1.ObjectId;
                                    LastCableInfo.Insert();
                                    ///ed.WriteMessage("5\n");

                                    LastCableInfo.SelectedObjectId = Part2.ObjectId;
                                    LastCableInfo.Insert();
                                    //ed.WriteMessage("6\n");

                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewDrawnMafsalOI, Part1.ObjectId);

                                    foreach (ObjectId oi in Blong1)
                                    {
                                        Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, Part1.ObjectId);
                                    }

                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewDrawnMafsalOI, Part2.ObjectId);

                                    foreach (ObjectId oi in Blong2)
                                    {
                                        Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, Part2.ObjectId);
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    ed.WriteMessage("~~~{0}~~~~~~\n", ex.Message);
                                }
                            }    //catch ended here
                        }
                    }


                    break;
                }
            }
        }
コード例 #14
0
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        //public void DrawMiddleJackPanel(Entity PostEntity, System.Data.DataTable AllData)
        //{

        //    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
        //    bool conti = true;
        //    //Dictionary<Guid, List<Entity>> MyCells = new Dictionary<Guid, List<Entity>>();
        //    double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MiddleJackPanel).Scale;

        //    DrawMiddleJackPanelJig MidJ = new DrawMiddleJackPanelJig(PostContainerEntity, MyScale);
        //    MidJ.MiddleJackPanelProductCode = ProductCode;
        //    MidJ.MiddleJaclPanelParentCode = ParentCode;
        //    MidJ.Cells = JackpanelCells;
        //    PromptResult pr;
        //    while (conti)
        //    {
        //        pr = ed.Drag(MidJ);
        //        if (pr.Status == PromptStatus.OK)
        //        {
        //            conti = false;
        //            #region save data here
        //            ObjectIdCollection OIC = new ObjectIdCollection();
        //            List<Guid> CellsGuid = new List<Guid>();

        //            List<Entity> Entities = new List<Entity>();
        //            Entities = MidJ.GetEntities();
        //            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        //            #region Seprate different cells from each other
        //            foreach (Entity ent in Entities)
        //            {
        //                Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
        //                object CellCode = null;
        //                if (poly != null)
        //                {
        //                    if (poly.AdditionalDictionary.ContainsKey("Code"))
        //                    {
        //                        poly.AdditionalDictionary.TryGetValue("Code", out CellCode);
        //                    }
        //                }
        //                else
        //                {
        //                    Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine;
        //                    if (lin != null)
        //                    {
        //                        if (lin.AdditionalDictionary.ContainsKey("Code"))
        //                        {
        //                            lin.AdditionalDictionary.TryGetValue("Code", out CellCode);
        //                        }
        //                    }
        //                    else
        //                    {
        //                        Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle;
        //                        if (cir != null)
        //                        {
        //                            if (cir.AdditionalDictionary.ContainsKey("Code"))
        //                            {
        //                                cir.AdditionalDictionary.TryGetValue("Code", out CellCode);
        //                            }
        //                        }
        //                    }
        //                }
        //                if (CellCode != null)
        //                {
        //                    if (!MyCells.ContainsKey(new Guid(CellCode.ToString())))
        //                    {
        //                        MyCells.Add(new Guid(CellCode.ToString()), new List<Entity>());
        //                        CellsGuid.Add(new Guid(CellCode.ToString()));
        //                        List<Entity> Entities1;
        //                        MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1);
        //                        Entities1.Add(ent);

        //                    }
        //                    else
        //                    {
        //                        List<Entity> Entities1;
        //                        MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1);
        //                        Entities1.Add(ent);
        //                    }

        //                }

        //            }
        //            #endregion

        //            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        //            ObjectIdCollection BusOIs = new ObjectIdCollection();
        //            foreach (Guid _ExistGuid in MyCells.Keys)
        //            {

        //                try
        //                {
        //                    #region Draw different cells
        //                    List<Entity> MyList = null;
        //                    MyCells.TryGetValue(_ExistGuid, out MyList);
        //                    if (MyList != null)
        //                    {
        //                        ObjectIdCollection CurrentCellEntities = new ObjectIdCollection();
        //                        ObjectId CurrentCellObjectId = ObjectId.Null;
        //                        foreach (Entity ent in MyList)
        //                        {
        //                            object MyProductType = null;
        //                            object MYProductCode = null;
        //                            object myCodeGuid = null;
        //                            Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
        //                            if (poly != null)
        //                            {
        //                                if (poly.AdditionalDictionary.ContainsKey("Code"))
        //                                {
        //                                    poly.AdditionalDictionary.TryGetValue("Code", out myCodeGuid);
        //                                }
        //                                if (poly.AdditionalDictionary.ContainsKey("ProductType"))
        //                                {
        //                                    poly.AdditionalDictionary.TryGetValue("ProductType", out MyProductType);
        //                                }
        //                                if (poly.AdditionalDictionary.ContainsKey("ProductCode"))
        //                                {
        //                                    poly.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode);
        //                                }


        //                            }
        //                            else
        //                            {
        //                                Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine;
        //                                if (lin != null)
        //                                {
        //                                    if (lin.AdditionalDictionary.ContainsKey("Code"))
        //                                    {
        //                                        lin.AdditionalDictionary.TryGetValue("Code", out myCodeGuid);
        //                                    }
        //                                    if (lin.AdditionalDictionary.ContainsKey("ProductType"))
        //                                    {
        //                                        lin.AdditionalDictionary.TryGetValue("ProductType", out MyProductType);
        //                                    }
        //                                    if (lin.AdditionalDictionary.ContainsKey("ProductCode"))
        //                                    {
        //                                        lin.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode);
        //                                    }

        //                                }
        //                                else
        //                                {
        //                                    Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle;
        //                                    if (cir != null)
        //                                    {
        //                                        if (cir.AdditionalDictionary.ContainsKey("Code"))
        //                                        {
        //                                            cir.AdditionalDictionary.TryGetValue("Code", out myCodeGuid);
        //                                        }
        //                                        if (cir.AdditionalDictionary.ContainsKey("ProductType"))
        //                                        {
        //                                            cir.AdditionalDictionary.TryGetValue("ProductType", out MyProductType);
        //                                        }
        //                                        if (cir.AdditionalDictionary.ContainsKey("ProductCode"))
        //                                        {
        //                                            cir.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode);
        //                                        }

        //                                    }
        //                                }
        //                            }

        //                            //------------------------
        //                            ObjectId NewCellEntities = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString());
        //                            OIC.Add(NewCellEntities);
        //                            if (MyProductType != null)
        //                            {
        //                                if (Convert.ToInt32(MyProductType) == (int)Atend.Control.Enum.ProductType.Cell)
        //                                {
        //                                    CurrentCellObjectId = NewCellEntities;
        //                                }
        //                                else
        //                                {
        //                                    CurrentCellEntities.Add(NewCellEntities);
        //                                }
        //                            }
        //                            Atend.Base.Acad.AT_INFO CellSubInfo = new Atend.Base.Acad.AT_INFO(NewCellEntities);
        //                            if (myCodeGuid != null)
        //                            {
        //                                CellSubInfo.ParentCode = NodeCode.ToString();
        //                                CellSubInfo.NodeCode = myCodeGuid.ToString();
        //                            }
        //                            else
        //                            {
        //                                CellSubInfo.ParentCode = myCodeGuid.ToString();
        //                                CellSubInfo.NodeCode = "";
        //                            }

        //                            if (MYProductCode != null)
        //                            {
        //                                CellSubInfo.ProductCode = Convert.ToInt32(MYProductCode);
        //                            }
        //                            else
        //                            {
        //                                CellSubInfo.ProductCode = 0;
        //                            }

        //                            if (MyProductType != null)
        //                            {
        //                                CellSubInfo.NodeType = Convert.ToInt32(MyProductType);
        //                                if (Convert.ToInt32(MyProductType) == (int)Atend.Control.Enum.ProductType.Bus)
        //                                {
        //                                    CellSubInfo.ProductCode = Atend.Base.Equipment.EJAckPanel.AccessSelectByCode(ProductCode).MasterProductCode;
        //                                    BusOIs.Add(NewCellEntities);
        //                                    //ed.WriteMessage("Bus OI : {0}\n", NewCellEntities);
        //                                }
        //                            }
        //                            else
        //                            {
        //                                CellSubInfo.NodeType = 0;
        //                            }
        //                            CellSubInfo.Insert();


        //                        }

        //                        if (CurrentCellObjectId != null && CurrentCellEntities.Count != 0)
        //                        {
        //                            foreach (ObjectId oi in CurrentCellEntities)
        //                            {
        //                                Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, CurrentCellObjectId);
        //                            }
        //                        }
        //                    }
        //                    #endregion
        //                }
        //                catch (System.Exception ex)
        //                {
        //                    ed.WriteMessage("Error while drawing: {0} \n", ex.Message);
        //                    return;
        //                }
        //            }
        //            //ed.WriteMessage("Bus Count : {0} \n", BusOIs.Count);

        //            #region Join Buses to each other
        //            foreach (Guid _ExistGuid in MyCells.Keys)
        //            {
        //                try
        //                {

        //                }
        //                catch (System.Exception ex)
        //                {
        //                    ed.WriteMessage("Error while Connect bus to each other: {0} \n", ex.Message);
        //                    return;
        //                }
        //            }
        //            #endregion

        //            //if (BusOIs.Count > 0)
        //            //{
        //            //    for (int BC = 0; BC < BusOIs.Count - 1; BC++)
        //            //    {

        //            //        Atend.Global.Acad.DrawEquips.AcDrawTerminal _AcDrawTerminal = new AcDrawTerminal();
        //            //        _AcDrawTerminal.DrawTerminal(Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(BusOIs[BC])), Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(BusOIs[BC])));


        //            //        //Atend.Base.Acad.AT_INFO BusInfo=new Atend.Base.Acad.AT_INFO(



        //            //    }
        //            //}
        //            #region Group all cells of Middlejack panel

        //            if (NodeCode != Guid.Empty)
        //            {
        //                //ed.WriteMessage("Group all cells of Middlejack panel\n");
        //                ObjectId GroupOI = Atend.Global.Acad.Global.MakeGroup(NodeCode.ToString() + "-MJP", OIC);

        //                Atend.Base.Acad.AT_INFO MiddleGroupInfo = new Atend.Base.Acad.AT_INFO(GroupOI);
        //                MiddleGroupInfo.ParentCode = ParentCode.ToString();
        //                MiddleGroupInfo.NodeCode = NodeCode.ToString();
        //                MiddleGroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.MiddleJackPanel;
        //                MiddleGroupInfo.ProductCode = ProductCode;
        //                MiddleGroupInfo.Insert();

        //                Atend.Base.Acad.AT_SUB.AddToAT_SUB(GroupOI, PostContainerEntity.ObjectId);
        //                Atend.Base.Acad.AT_SUB.AddToAT_SUB(PostContainerEntity.ObjectId, GroupOI);

        //            }
        //            #endregion

        //            #endregion
        //        }
        //        else
        //        {
        //            conti = false;
        //        }
        //    }
        //}


        public void DrawMiddleJackPanel(Entity PostContainerEntity, ref DataRow[] PostEquipInserted)
        {
            Editor ed          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            bool   conti       = true;
            Guid   NodeCode    = new Guid(PostEquipInserted[0]["NodeCode"].ToString());
            Guid   ParentCode  = new Guid(PostEquipInserted[0]["ParentCode"].ToString());
            int    ProductCode = Convert.ToInt32(PostEquipInserted[0]["ProductCode"]);

            Dictionary <Guid, List <Entity> > MyCells = new Dictionary <Guid, List <Entity> >();
            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MiddleJackPanel).Scale;

            DrawMiddleJackPanelJig MidJ = new DrawMiddleJackPanelJig(PostContainerEntity, MyScale);

            MidJ.MiddleJackPanelProductCode = ProductCode;
            MidJ.MiddleJaclPanelParentCode  = ParentCode;
            MidJ.Cells = JackpanelCells;
            PromptResult pr;

            //ed.WriteMessage("------ START MJ {0} -------\n",NodeCode);
            while (conti)
            {
                pr = ed.Drag(MidJ);
                if (pr.Status == PromptStatus.OK)
                {
                    conti = false;
                    #region save data here
                    ObjectIdCollection OIC       = new ObjectIdCollection();
                    List <Guid>        CellsGuid = new List <Guid>();

                    List <Entity> Entities = new List <Entity>();
                    Entities = MidJ.GetEntities();
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                    #region Seprate different cells from each other
                    //ed.WriteMessage("Seprate different cells from each other\n");
                    foreach (Entity ent in Entities)
                    {
                        Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
                        object CellCode = null;
                        if (poly != null)
                        {
                            //ed.WriteMessage("~~~Poly~~~:{0}\n", poly.AdditionalDictionary.ContainsKey("ProductCode"));
                            if (poly.AdditionalDictionary.ContainsKey("Code"))
                            {
                                poly.AdditionalDictionary.TryGetValue("Code", out CellCode);
                            }
                        }
                        else
                        {
                            Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine;
                            if (lin != null)
                            {
                                if (lin.AdditionalDictionary.ContainsKey("Code"))
                                {
                                    lin.AdditionalDictionary.TryGetValue("Code", out CellCode);
                                }
                            }
                            else
                            {
                                Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle;
                                if (cir != null)
                                {
                                    if (cir.AdditionalDictionary.ContainsKey("Code"))
                                    {
                                        cir.AdditionalDictionary.TryGetValue("Code", out CellCode);
                                    }
                                }
                            }
                        }
                        if (CellCode != null)
                        {
                            //ed.WriteMessage("Cellcode:{0}\n", CellCode);
                            if (!MyCells.ContainsKey(new Guid(CellCode.ToString())))
                            {
                                //ed.WriteMessage("\nCell Cuid Code:{0}\n", CellCode.ToString());
                                MyCells.Add(new Guid(CellCode.ToString()), new List <Entity>());
                                CellsGuid.Add(new Guid(CellCode.ToString()));

                                List <Entity> Entities1;
                                MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1);
                                Entities1.Add(ent);
                            }
                            else
                            {
                                List <Entity> Entities1;
                                MyCells.TryGetValue(new Guid(CellCode.ToString()), out Entities1);
                                Entities1.Add(ent);
                            }
                        }
                    }
                    #endregion

                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    foreach (Guid _ExistGuid in MyCells.Keys)
                    {
                        try
                        {
                            #region Draw different cells
                            //if (MyCells.ContainsKey(_ExistGuid))
                            //{
                            //ed.WriteMessage("Cell count : {0} \n", MyCells.Count);
                            List <Entity> MyList = null;
                            MyCells.TryGetValue(_ExistGuid, out MyList);
                            if (MyList != null)
                            {
                                //ed.WriteMessage("~~~~~ Entities found ~~~~~\n");
                                ObjectIdCollection CurrentCellEntities = new ObjectIdCollection();
                                ObjectId           CurrentCellObjectId = ObjectId.Null;
                                foreach (Entity ent in MyList)
                                {
                                    //-----------------------


                                    object MyProductType = null;
                                    object MYProductCode = null;
                                    object myCodeGuid    = null;
                                    Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
                                    if (poly != null)
                                    {
                                        //ed.WriteMessage("~~~POLY~~~{0}\n", poly.AdditionalDictionary.ContainsKey("ProductCode"));
                                        if (poly.AdditionalDictionary.ContainsKey("Code"))
                                        {
                                            poly.AdditionalDictionary.TryGetValue("Code", out myCodeGuid);
                                        }
                                        if (poly.AdditionalDictionary.ContainsKey("ProductType"))
                                        {
                                            poly.AdditionalDictionary.TryGetValue("ProductType", out MyProductType);
                                        }
                                        if (poly.AdditionalDictionary.ContainsKey("ProductCode"))
                                        {
                                            poly.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode);
                                        }
                                    }
                                    else
                                    {
                                        Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine;
                                        if (lin != null)
                                        {
                                            if (lin.AdditionalDictionary.ContainsKey("Code"))
                                            {
                                                lin.AdditionalDictionary.TryGetValue("Code", out myCodeGuid);
                                            }
                                            if (lin.AdditionalDictionary.ContainsKey("ProductType"))
                                            {
                                                lin.AdditionalDictionary.TryGetValue("ProductType", out MyProductType);
                                            }
                                            if (lin.AdditionalDictionary.ContainsKey("ProductCode"))
                                            {
                                                lin.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode);
                                            }
                                        }
                                        else
                                        {
                                            Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle;
                                            if (cir != null)
                                            {
                                                if (cir.AdditionalDictionary.ContainsKey("Code"))
                                                {
                                                    cir.AdditionalDictionary.TryGetValue("Code", out myCodeGuid);
                                                }
                                                if (cir.AdditionalDictionary.ContainsKey("ProductType"))
                                                {
                                                    cir.AdditionalDictionary.TryGetValue("ProductType", out MyProductType);
                                                }
                                                if (cir.AdditionalDictionary.ContainsKey("ProductCode"))
                                                {
                                                    cir.AdditionalDictionary.TryGetValue("ProductCode", out MYProductCode);
                                                }
                                            }
                                        }
                                    }

                                    //------------------------
                                    //ed.WriteMessage("Entity Type:{0}\n", ProductType);
                                    ObjectId NewCellEntities = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString());
                                    OIC.Add(NewCellEntities);
                                    //                                    CurrentCellEntities.Add(NewCellEntities);
                                    if (MyProductType != null)
                                    {
                                        if (Convert.ToInt32(MyProductType) == (int)Atend.Control.Enum.ProductType.Cell)
                                        {
                                            CurrentCellObjectId = NewCellEntities;
                                            //ed.WriteMessage("CurrentCellObjectId was found\n");
                                        }
                                        else
                                        {
                                            CurrentCellEntities.Add(NewCellEntities);
                                        }
                                    }
                                    //ed.WriteMessage("NodeCode : {0}\n", NodeCode);

                                    Atend.Base.Acad.AT_INFO CellSubInfo = new Atend.Base.Acad.AT_INFO(NewCellEntities);
                                    if (myCodeGuid != null)
                                    {
                                        //ed.WriteMessage("cell entity was found\n");
                                        CellSubInfo.ParentCode = NodeCode.ToString(); //CurrentMiddleJackPanelCodeGuid.ToString();
                                        CellSubInfo.NodeCode   = myCodeGuid.ToString();
                                    }
                                    else
                                    {
                                        CellSubInfo.ParentCode = myCodeGuid.ToString();
                                        CellSubInfo.NodeCode   = "";
                                    }
                                    //ed.WriteMessage("2\n");

                                    if (MYProductCode != null)
                                    {
                                        CellSubInfo.ProductCode = Convert.ToInt32(MYProductCode);
                                    }
                                    else
                                    {
                                        CellSubInfo.ProductCode = 0;
                                    }
                                    //ed.WriteMessage("3\n");

                                    if (MyProductType != null)
                                    {
                                        CellSubInfo.NodeType = Convert.ToInt32(MyProductType);
                                    }
                                    else
                                    {
                                        CellSubInfo.NodeType = 0;
                                    }
                                    //ed.WriteMessage("4\n");

                                    CellSubInfo.Insert();
                                }

                                //insert cell sub
                                //ed.WriteMessage("%%% CurrentCellObjectId %%% {0} : {1} \n", CurrentCellObjectId, CurrentCellEntities.Count);
                                if (CurrentCellObjectId != null && CurrentCellEntities.Count != 0)
                                {
                                    //ed.WriteMessage("5:1\n");
                                    //Atend.Base.Acad.AT_SUB cellsub = new Atend.Base.Acad.AT_SUB(CurrentCellObjectId);
                                    foreach (ObjectId oi in CurrentCellEntities)
                                    {
                                        //cellsub.SubIdCollection.Add(oi);
                                        Atend.Base.Acad.AT_SUB.AddToAT_SUB(oi, CurrentCellObjectId);
                                    }
                                    //cellsub.Insert();
                                    //ed.WriteMessage("5:2\n");
                                }
                            }
                            //}
                            // ed.WriteMessage("One Pack Was drawn \n");
                            //}
                            #endregion
                        }
                        catch (System.Exception ex)
                        {
                            ed.WriteMessage("Error while drawing: {0} \n", ex.Message);
                            return;
                        }
                    }

                    #region Group all cells of Middlejack panel

                    if (NodeCode != null)
                    {
                        //ed.WriteMessage("Group all cells of Middlejack panel\n");
                        ObjectId GroupOI = Atend.Global.Acad.Global.MakeGroup(NodeCode.ToString() + "-MJP", OIC);

                        Atend.Base.Acad.AT_INFO MiddleGroupInfo = new Atend.Base.Acad.AT_INFO(GroupOI);
                        MiddleGroupInfo.ParentCode  = ParentCode.ToString();
                        MiddleGroupInfo.NodeCode    = NodeCode.ToString();
                        MiddleGroupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.MiddleJackPanel;
                        MiddleGroupInfo.ProductCode = ProductCode;
                        MiddleGroupInfo.Insert();


                        Atend.Base.Acad.AT_SUB.AddToAT_SUB(GroupOI, PostContainerEntity.ObjectId);
                    }
                    #endregion

                    #endregion
                }
                else
                {
                    conti = false;
                }
            }
        }
コード例 #15
0
ファイル: AcDrawKablsho.cs プロジェクト: ParisaMousavi/ATEND
        public void DrawKablsho()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            //Database db = HostApplicationServices.WorkingDatabase;
            //Point3d TablePosition;
            //ObjectId NewPoleObjectId = ObjectId.Null;
            //ObjectIdCollection NewConsolObjectIds = new ObjectIdCollection();
            //ed.WriteMessage("~~~Design scale :{0}~~~ \n", Atend.Control.Common.SelectedDesignScale);
            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.KablSho).Scale;

            using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                bool           conti       = true;
                int            i           = 0;
                DrawKablshoJig _drawKalamp = new DrawKablshoJig(MyScale);
                ObjectId       ParentOI    = ObjectId.Null;
                string         ParentCode  = string.Empty;

                while (conti)
                {
                    PromptResult pr;

                    pr = ed.Drag(_drawKalamp);

                    if (pr.Status == PromptStatus.OK && !_drawKalamp.GetAngle)
                    {
                        System.Data.DataTable PointContainerList = Atend.Global.Acad.Global.PointInsideWhichEntity(new Point3d(_drawKalamp.BasePoint.X, _drawKalamp.BasePoint.Y, 0));
                        System.Data.DataTable Parents            = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.KablSho);
                        foreach (System.Data.DataRow dr in PointContainerList.Rows)
                        {
                            DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", Convert.ToInt32(dr["Type"])));
                            if (drs.Length != 0)
                            {
                                ParentOI   = new ObjectId(new IntPtr(Convert.ToInt32(dr["ObjectId"])));
                                ParentCode = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI).NodeCode;
                                //ed.WriteMessage("Value assigned $$$$$$$$$$$$$$$$$\n");
                            }
                        }


                        _drawKalamp.GetPoint = false;
                        _drawKalamp.GetAngle = true;
                    }
                    else if (pr.Status == PromptStatus.OK && _drawKalamp.GetAngle)
                    {
                        conti = false;
                        List <Entity> entities = _drawKalamp.GetEntities();


                        if (SaveKablshoData())
                        {
                            foreach (Entity ent in entities)
                            {
                                ObjectId HOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                                Atend.Base.Acad.AT_INFO headerInfo = new Atend.Base.Acad.AT_INFO(HOI);
                                headerInfo.NodeCode    = KablshoPack.Code.ToString();
                                headerInfo.NodeType    = KablshoPack.Type;
                                headerInfo.ProductCode = eKablsho.Code;
                                if (ParentOI != ObjectId.Null)
                                {
                                    headerInfo.ParentCode = ParentCode;
                                }
                                else
                                {
                                    headerInfo.ParentCode = "";
                                }
                                headerInfo.Insert();

                                if (ParentOI != ObjectId.Null)
                                {
                                    Atend.Base.Acad.AT_SUB KablshoSub = new Atend.Base.Acad.AT_SUB(HOI);
                                    KablshoSub.SubIdCollection.Add(ParentOI);
                                    KablshoSub.Insert();

                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(HOI, ParentOI);
                                }
                            }
                        }
                    }
                    else
                    {
                        conti = false;
                    }
                }
            }
        }
コード例 #16
0
        public bool ChangeBranchInfo()
        {
            OleDbConnection  conection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);
            OleDbTransaction transaction;
            Editor           ed = Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                conection.Open();
                transaction = conection.BeginTransaction();
                try
                {
                    int ConductorCounter   = 0;
                    int SelfkeeperCounter  = 0;
                    int GroundCabelCounter = 0;

                    foreach (Atend.Base.Design.DBranch branch in dBranch)
                    {
                        ObjectId obj = Atend.Global.Acad.UAcad.GetBranchByGuid(branch.Code);
                        Atend.Base.Acad.AT_INFO atInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(obj);

                        #region Conductor
                        if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor))
                        {
                            Atend.Base.Equipment.EConductor CondPhase   = Atend.Base.Equipment.EConductor.SelectByXCode(CondTip[ConductorCounter].PhaseProductXCode);
                            Atend.Base.Equipment.EConductor CondNeutral = Atend.Base.Equipment.EConductor.SelectByXCode(CondTip[ConductorCounter].NeutralProductXCode);
                            Atend.Base.Equipment.EConductor CondNight   = Atend.Base.Equipment.EConductor.SelectByXCode(CondTip[ConductorCounter].NightProductXCode);

                            if (!CondPhase.AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Failed");
                            }

                            if (!CondNeutral.AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Failed");
                            }
                            if (!CondNight.AccessInsert(transaction, conection, true, true))
                            {
                            }
                            CondTip[ConductorCounter].PhaseProductCode   = CondPhase.Code;
                            CondTip[ConductorCounter].NeutralProductCode = CondNeutral.Code;
                            CondTip[ConductorCounter].NightProductCode   = CondNight.Code;

                            if (!CondTip[ConductorCounter].AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Tip Failed");
                            }

                            branch.ProductCode = CondTip[ConductorCounter].Code;
                            branch.Number      = CondTip[ConductorCounter].Description;
                            atInfo.ProductCode = condTip[ConductorCounter].Code;
                            if (branch.AccessUpdate(transaction, conection))
                            {
                                Atend.Global.Acad.DrawEquips.AcDrawConductor.ChangeCounductorComment(obj, CondTip[ConductorCounter].Description);
                                atInfo.Insert();
                            }
                            else
                            {
                                throw new System.Exception("Insert Branch Failed");
                            }
                            ConductorCounter++;
                        }
                        #endregion


                        #region SelfKeeper
                        if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper))
                        {
                            Atend.Base.Equipment.ESelfKeeper SelfPhase   = Atend.Base.Equipment.ESelfKeeper.SelectByXCode(SelfTip[SelfkeeperCounter].PhaseProductxCode);
                            Atend.Base.Equipment.ESelfKeeper SelfNeutral = Atend.Base.Equipment.ESelfKeeper.SelectByXCode(SelfTip[SelfkeeperCounter].NeutralProductxCode);
                            Atend.Base.Equipment.ESelfKeeper SelfNight   = Atend.Base.Equipment.ESelfKeeper.SelectByXCode(SelfTip[SelfkeeperCounter].NightProductxCode);

                            if (!SelfPhase.AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Failed");
                            }

                            if (!SelfNeutral.AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Failed");
                            }
                            if (!SelfNight.AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Failed");
                            }
                            SelfTip[SelfkeeperCounter].PhaseProductCode   = SelfPhase.Code;
                            SelfTip[SelfkeeperCounter].NeutralProductCode = SelfNeutral.Code;
                            SelfTip[SelfkeeperCounter].NightProductCode   = SelfNight.Code;

                            if (!SelfTip[SelfkeeperCounter].AccessInsert(transaction, conection))
                            {
                                throw new System.Exception("Insert Tip Failed");
                            }

                            branch.ProductCode = SelfTip[SelfkeeperCounter].Code;
                            branch.Number      = SelfTip[SelfkeeperCounter].Description;
                            atInfo.ProductCode = SelfTip[SelfkeeperCounter].Code;

                            if (branch.AccessUpdate(transaction, conection))
                            {
                                Atend.Global.Acad.DrawEquips.AcDrawSelfKeeper.ChangeCabelComment(obj, SelfTip[SelfkeeperCounter].Description);
                                atInfo.Insert();
                            }
                            else
                            {
                                throw new System.Exception("Insert Branch Failed");
                            }

                            SelfkeeperCounter++;
                        }
                        #endregion


                        #region GroundCabel
                        if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabel))
                        {
                            Atend.Base.Equipment.EGroundCabel GroundPhase   = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundTip[GroundCabelCounter].PhaseProductXCode);
                            Atend.Base.Equipment.EGroundCabel GroundNeutral = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundTip[GroundCabelCounter].NeutralProductXCode);
                            //Atend.Base.Equipment.EGroundCabel GroundNight = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundTip[GroundCabelCounter].NightProductxCode);

                            if (!GroundPhase.AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Failed");
                            }

                            if (!GroundNeutral.AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Failed");
                            }
                            //if (!GroundNight.AccessInsert(transaction, conection, true, true))
                            //{
                            //    throw new System.Exception("Insert Failed");

                            //}
                            GroundTip[GroundCabelCounter].PhaseProductCode   = GroundPhase.Code;
                            GroundTip[GroundCabelCounter].NeutralProductCode = GroundNeutral.Code;
                            //GroundTip[GroundCabelCounter].NightProductCode = GroundNight.Code;

                            if (!GroundTip[GroundCabelCounter].AccessInsert(transaction, conection, true, true))
                            {
                                throw new System.Exception("Insert Tip Failed");
                            }

                            branch.ProductCode = GroundTip[GroundCabelCounter].Code;
                            branch.Number      = GroundTip[GroundCabelCounter].Description;
                            atInfo.ProductCode = GroundTip[GroundCabelCounter].Code;
                            if (branch.AccessUpdate(transaction, conection))
                            {
                                Atend.Global.Acad.DrawEquips.AcDrawGroundCabel.ChangeCabelComment(obj, GroundTip[GroundCabelCounter].Description);
                                atInfo.Insert();
                            }
                            else
                            {
                                throw new System.Exception("Insert Branch Failed");
                            }
                            GroundCabelCounter++;
                        }
                        #endregion
                    }
                }
                catch (System.Exception ex)
                {
                    ed.WriteMessage("Error In 01={0}\n", ex.Message);
                    transaction.Rollback();
                    conection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex1)
            {
                ed.WriteMessage("Error in 02={0}\n", ex1.Message);
                conection.Close();
                return(false);
            }
            transaction.Commit();
            conection.Close();
            return(true);
        }
コード例 #17
0
        public void DrawKalamp()
        {
            Document doc            = Application.DocumentManager.MdiActiveDocument;
            Editor   ed             = doc.Editor;
            double   MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Kalamp).Scale;
            double   MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Kalamp).CommentScale;

            using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                bool          conti       = true;
                int           i           = 0;
                DrawKalampJig _drawKalamp = new DrawKalampJig(MyScale);
                ObjectId      ParentOI    = ObjectId.Null;
                string        ParentCode  = string.Empty;

                while (conti)
                {
                    PromptResult pr;
                    pr = ed.Drag(_drawKalamp);
                    if (pr.Status == PromptStatus.OK && !_drawKalamp.GetAngle)
                    {
                        System.Data.DataTable PointContainerList = Atend.Global.Acad.Global.PointInsideWhichEntity(new Point3d(_drawKalamp.BasePoint.X, _drawKalamp.BasePoint.Y, 0));
                        System.Data.DataTable Parents            = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Kalamp);
                        foreach (System.Data.DataRow dr in PointContainerList.Rows)
                        {
                            DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", Convert.ToInt32(dr["Type"])));
                            if (drs.Length != 0)
                            {
                                ParentOI   = new ObjectId(new IntPtr(Convert.ToInt32(dr["ObjectId"])));
                                ParentCode = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI).NodeCode;
                                //ed.WriteMessage("Value assigned $$$$$$$$$$$$$$$$$\n");
                            }
                        }



                        _drawKalamp.GetPoint = false;
                        _drawKalamp.GetAngle = true;
                    }
                    else if (pr.Status == PromptStatus.OK && _drawKalamp.GetAngle)
                    {
                        conti = false;
                        List <Entity> entities = _drawKalamp.GetEntities();


                        if (SaveKalampData())
                        {
                            foreach (Entity ent in entities)
                            {
                                string LayerName = "";
                                if (eClamp.VoltageLevel == 400)
                                {
                                    LayerName = Atend.Control.Enum.AutoCadLayerName.LOW_AIR.ToString();
                                }
                                else
                                {
                                    LayerName = Atend.Control.Enum.AutoCadLayerName.MED_AIR.ToString();
                                }
                                ObjectId KOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, LayerName);

                                Atend.Base.Acad.AT_INFO KalampInfo = new Atend.Base.Acad.AT_INFO(KOI);
                                KalampInfo.NodeCode    = ClampPack.Code.ToString();
                                KalampInfo.NodeType    = ClampPack.Type;
                                KalampInfo.ProductCode = eClamp.Code;
                                if (ParentOI != ObjectId.Null)
                                {
                                    KalampInfo.ParentCode = ParentCode;
                                }
                                else
                                {
                                    KalampInfo.ParentCode = "";
                                }
                                KalampInfo.Insert();


                                ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(ClampPack.Number, Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(KOI)), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());


                                Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi);
                                textInfo.ParentCode  = ClampPack.Code.ToString();
                                textInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                                textInfo.NodeCode    = "";
                                textInfo.ProductCode = 0;
                                textInfo.Insert();

                                Atend.Base.Acad.AT_SUB.AddToAT_SUB(TextOi, KOI);


                                if (ParentOI != ObjectId.Null)
                                {
                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(ParentOI, KOI);
                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(KOI, ParentOI);
                                }
                            }
                        }
                    }
                    else
                    {
                        conti = false;
                    }
                }
            }
        }
コード例 #18
0
ファイル: AcDrawLight.cs プロジェクト: ParisaMousavi/ATEND
        //~~~~~~~~~~~~~~~~~~~~~~~~ methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

        public void DrawLigth()
        {
            Editor             ed    = Application.DocumentManager.MdiActiveDocument.Editor;
            bool               conti = true;
            ObjectIdCollection NewDrawnCollection = new ObjectIdCollection();
            //ObjectId ConsolElseOI = ObjectId.Null, ConnectionOI = ObjectId.Null, RodOI = ObjectId.Null, RodTriangeOI = ObjectId.Null;

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Light).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Light).CommentScale;

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect Container :");
            PromptEntityResult  per = ed.GetEntity(peo);

            if (per.Status == PromptStatus.OK)
            {
                System.Data.DataTable   Parents = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Light);
                Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId);
                DataRow[] drs = Parents.Select(string.Format("SoftwareCode={0}", Convert.ToInt32(at_info.NodeType)));
                if (drs.Length > 0)
                {
                    DrawLightJig _DrawLightJig;
                    _DrawLightJig = new DrawLightJig(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId), MyScale);
                    while (conti)
                    {
                        //p = LineSeg.GetClosestPointTo(LineEntity.StartPoint).Point;

                        _DrawLightJig.CenterPoint01   = per.PickedPoint;
                        _DrawLightJig.PartOneIsActive = false;
                        PromptResult pr = ed.Drag(_DrawLightJig);
                        if (pr.Status == PromptStatus.OK && !_DrawLightJig.PartOneIsActive)
                        {
                            //pr = ed.Drag(_DrawLightJig);
                            conti = false;
                            //ed.WriteMessage("1 \n");
                            #region Save Data Here

                            List <Entity> Entities = _DrawLightJig.GetEntities();
                            //ed.WriteMessage("2 \n");
                            if (SaveLightData(new Guid(at_info.NodeCode)))
                            {
                                //---------------------
                                //ObjectId ConsolElseOI = ObjectId.Null;
                                foreach (Entity ent in Entities)
                                {
                                    ObjectId newDrawnoi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.LOW_AIR.ToString());
                                    ////////Atend.Global.Acad.AcadJigs.MyPolyLine mPoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
                                    ////////if (mPoly != null)
                                    ////////{
                                    ////////    //ed.WriteMessage("POLY LINE FOUND\n");
                                    ////////    if (mPoly.AdditionalDictionary.ContainsKey("ProductType"))
                                    ////////    {
                                    ////////        object ProductType = null;
                                    ////////        mPoly.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                    ////////        if (ProductType != null)
                                    ////////        {
                                    ////////            if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.ConsolElse)
                                    ////////            {
                                    ////////                ConsolElseOI = newDrawnoi;
                                    ////////                Atend.Base.Acad.AT_INFO ConsolElseInfo = new Atend.Base.Acad.AT_INFO(newDrawnoi);
                                    ////////                ConsolElseInfo.ParentCode = at_info.NodeCode;
                                    ////////                ConsolElseInfo.NodeCode = LightPack.Code.ToString();
                                    ////////                ConsolElseInfo.NodeType = Convert.ToInt32(ProductType);
                                    ////////                ConsolElseInfo.ProductCode = 0;
                                    ////////                ConsolElseInfo.Insert();
                                    ////////            }
                                    ////////        }
                                    ////////    }
                                    ////////}
                                    NewDrawnCollection.Add(newDrawnoi);
                                }

                                //////if (ConsolElseOI != ObjectId.Null)
                                //////{

                                //////    Atend.Base.Acad.AT_SUB ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConsolElseOI);
                                //////    foreach (ObjectId oi in NewDrawnCollection)
                                //////    {
                                //////        if (oi != ConsolElseOI)
                                //////        {
                                //////            //ed.WriteMessage("ConsolElseSubOI:{0}\n", oi);
                                //////            ConsolElseSub.SubIdCollection.Add(oi);
                                //////        }
                                //////    }
                                //////    ConsolElseSub.SubIdCollection.Add(per.ObjectId);
                                //////    ConsolElseSub.Insert();
                                //////}
                                //---------------------



                                foreach (ObjectId oi in NewDrawnCollection)
                                {
                                    //if (oi != ConsolElseOI)
                                    //{
                                    Atend.Base.Acad.AT_INFO a = new Atend.Base.Acad.AT_INFO(oi);
                                    a.ParentCode  = at_info.NodeCode;
                                    a.NodeCode    = LightPack.Code.ToString();
                                    a.NodeType    = (int)Atend.Control.Enum.ProductType.Light;
                                    a.ProductCode = LightPack.ProductCode;;
                                    a.Insert();
                                    // }
                                }



                                ObjectId NewCreatedGroup = Atend.Global.Acad.Global.MakeGroup(LightPack.Code.ToString(), NewDrawnCollection);
                                ObjectId txtOI           = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(eLight.Comment, new Point3d(_DrawLightJig.CenterPoint02.X, _DrawLightJig.CenterPoint02.Y, 0), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                                Atend.Base.Acad.AT_INFO GroupInfo1 = new Atend.Base.Acad.AT_INFO(txtOI);
                                GroupInfo1.ParentCode  = LightPack.Code.ToString();
                                GroupInfo1.NodeCode    = "";
                                GroupInfo1.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                                GroupInfo1.ProductCode = 0;
                                GroupInfo1.Insert();


                                Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(NewCreatedGroup);
                                GroupInfo.ParentCode  = at_info.NodeCode;
                                GroupInfo.NodeCode    = LightPack.Code.ToString();
                                GroupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Light;
                                GroupInfo.ProductCode = LightPack.ProductCode;
                                GroupInfo.Insert();


                                Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewCreatedGroup, per.ObjectId);
                                Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(NewCreatedGroup);
                                GroupSub.SubIdCollection.Add(per.ObjectId);
                                GroupSub.SubIdCollection.Add(txtOI);
                                GroupSub.Insert();
                            }


                            #endregion
                        }
                        else
                        {
                            conti = false;
                        }
                    }
                }
                else
                {
                    string s = "";
                    foreach (DataRow dr in Parents.Rows)
                    {
                        s = s + Atend.Base.Design.DProductProperties.AccessSelectByCodeDrawable(Convert.ToInt32(dr["ContainerCode"])).ProductName + "-";
                    }
                    Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification();
                    notification.Title = "ÇÊÕÇáÇÊ ãÌÇÒ";
                    notification.Msg   = s;
                    notification.infoCenterBalloon();
                }
            }//prompt status ok
        }
コード例 #19
0
        //~~~~~~~~~~~~~~~~ METHODS ~~~~~~~~~~~~~~~~~~~~~//

        public static void DrawForbidenArea()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            Editor              ed          = doc.Editor;
            Matrix3d            ucs         = ed.CurrentUserCoordinateSystem;
            DrawForbidenAreaJig jig         = new DrawForbidenAreaJig(ucs);
            ObjectIdCollection  ForbidenIds = new ObjectIdCollection();

            bool bSuccess = true, bComplete = false;

            do
            {
                PromptResult res = ed.Drag(jig);
                bSuccess = (res.Status == PromptStatus.OK);
                if (bSuccess)
                {
                    Polyline pl = jig.GetEntity() as Polyline;
                    if (pl != null)
                    {
                        if (pl.NumberOfVertices == 1)
                        {
                            Point3d CurrentPoint        = new Point3d(pl.GetPoint3dAt(pl.NumberOfVertices - 1).X, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Y, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Z);
                            Point3d AcceptedCenterPoint = CurrentPoint;
                            pl.SetPointAt(0, new Point2d(AcceptedCenterPoint.X, AcceptedCenterPoint.Y));
                            jig.AddLatestVertex();
                        }
                        else
                        {
                            jig.AddLatestVertex();
                        }
                    }
                }
                bComplete = (res.Status == PromptStatus.None);
                if (bComplete)
                {
                    Polyline pl = jig.GetEntity() as Polyline;
                    if (pl != null)
                    {
                        jig.RemoveLastVertex();
                        Point3d CurrentPoint        = new Point3d(pl.GetPoint3dAt(pl.NumberOfVertices - 1).X, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Y, pl.GetPoint3dAt(pl.NumberOfVertices - 1).Z);
                        Point3d AcceptedCenterPoint = CurrentPoint;
                        pl.SetPointAt(pl.NumberOfVertices - 1, new Point2d(AcceptedCenterPoint.X, AcceptedCenterPoint.Y));
                    }
                }
            } while (bSuccess && !bComplete);
            if (bComplete)
            {
                Polyline CableEntity = jig.GetEntity() as Polyline;
                if (CableEntity != null)
                {
                    if (CableEntity.GetPoint3dAt(CableEntity.NumberOfVertices - 1) == CableEntity.GetPoint3dAt(0))
                    {
                        CableEntity.Closed = true;
                    }
                    else
                    {
                        Point2d p2 = CableEntity.GetPoint2dAt(0);
                        CableEntity.AddVertexAt(CableEntity.NumberOfVertices, p2, 0, 0, 0);
                        CableEntity.Closed = true;
                    }

                    ObjectId ForbidenOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(CableEntity, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                    ForbidenIds.Add(ForbidenOI);
                    Atend.Base.Acad.AT_INFO forbidenInfo = new Atend.Base.Acad.AT_INFO(ForbidenOI);
                    forbidenInfo.ParentCode  = "";
                    forbidenInfo.NodeCode    = "";
                    forbidenInfo.ProductCode = 0;
                    forbidenInfo.NodeType    = (int)Atend.Control.Enum.ProductType.ForbiddenArea;
                    forbidenInfo.Angle       = 0;
                    forbidenInfo.Insert();

                    #region forbiden area
                    Transaction tr = doc.TransactionManager.StartTransaction();
                    using (tr)
                    {
                        // Check the entity is a closed curve
                        DBObject obj = tr.GetObject(CableEntity.ObjectId, OpenMode.ForRead);
                        Curve    cur = obj as Curve;
                        if (cur != null && cur.Closed == false)
                        {
                            //ed.WriteMessage("\nLoop must be a closed curve.");
                        }
                        else
                        {
                            // We'll add the hatch to the model space
                            BlockTable       bt  = (BlockTable)tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead);
                            BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                            Hatch            hat = new Hatch();
                            hat.SetDatabaseDefaults();
                            // Firstly make it clear we want a gradient fill
                            hat.HatchObjectType = HatchObjectType.GradientObject;
                            //Let's use the pre-defined spherical gradient
                            //LINEAR, CYLINDER, INVCYLINDER, SPHERICAL, INVSPHERICAL, HEMISPHERICAL, INVHEMISPHERICAL, CURVED, and INVCURVED.
                            hat.SetGradient(GradientPatternType.PreDefinedGradient, "LINEAR");
                            // We're defining two colours
                            hat.GradientOneColorMode = false;
                            GradientColor[] gcs = new GradientColor[2];
                            // First colour must have value of 0
                            gcs[0] = new GradientColor(Color.FromRgb(0, 0, 255), 0);
                            // Second colour must have value of 1
                            gcs[1] = new GradientColor(Color.FromRgb(47, 165, 208), 1);
                            hat.SetGradientColors(gcs);
                            // Add the hatch to the model space
                            // and the transaction
                            ObjectId hatId = btr.AppendEntity(hat);
                            tr.AddNewlyCreatedDBObject(hat, true);
                            // Add the hatch loop and complete the hatch
                            ObjectIdCollection ids = new ObjectIdCollection();
                            ids.Add(CableEntity.ObjectId);
                            hat.Associative = true;
                            hat.AppendLoop(HatchLoopTypes.Default, ids);
                            hat.EvaluateHatch(true);
                            tr.Commit();

                            Atend.Base.Acad.AT_INFO forbidenInfo1 = new Atend.Base.Acad.AT_INFO(hatId);
                            forbidenInfo1.ParentCode  = "";
                            forbidenInfo1.NodeCode    = "";
                            forbidenInfo1.ProductCode = 0;
                            forbidenInfo1.NodeType    = (int)Atend.Control.Enum.ProductType.ForbiddenArea;
                            forbidenInfo1.Angle       = 0;
                            forbidenInfo1.Insert();


                            ForbidenIds.Add(hatId);
                        }
                    }
                    #endregion

                    Atend.Global.Acad.Global.MakeGroup(Guid.NewGuid().ToString(), ForbidenIds);
                }
            }
        }
コード例 #20
0
ファイル: AcDrawKhazan.cs プロジェクト: ParisaMousavi/ATEND
        public bool UpdateKhazanData(Guid EXCode)
        {
            Editor           ed = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbTransaction aTransaction;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();
                try
                {
                    try
                    {
                        KhazanPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode);
                        if (!UseAccess)
                        {
                            if (!eKhazanTip.AccessInsert(aTransaction, aConnection, true, true))
                            {
                                throw new System.Exception("KhazanTip.Insert failed");
                            }
                        }
                        KhazanPack.IsExistance = Existance;
                        KhazanPack.ProjectCode = ProjectCode;
                        KhazanPack.ProductCode = eKhazanTip.Code;
                        KhazanPack.Number      = "";
                        if (KhazanPack.AccessUpdate(aTransaction, aConnection))
                        {
                            Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);
                            atinfo.ProductCode = eKhazanTip.Code;
                            atinfo.Insert();
                            //Atend.Global.Acad.UAcad.ChangeMText(selectedObjectId, eKhazanTip.Name);
                            ChangeComment(selectedObjectId, eKhazanTip.Description);
                        }
                        else
                        {
                            throw new System.Exception("KhazanPack.AccessInsert2 failed");
                        }
                        //++++++++++++++++++++++++++++++
                        if (!UseAccess)
                        {
                            //WENT TO
                            //if (!Atend.Base.Equipment.EContainerPackage.SentFromLocalToAccess(eKhazanTip.XCode, (int)Atend.Control.Enum.ProductType.BankKhazan, eKhazanTip.Code, aTransaction, aConnection))
                            //{
                            //    throw new System.Exception("SentFromLocalToAccess failed");
                            //}
                        }
                        //++++++++++++++++++++++++++++++
                    }
                    catch (System.Exception ex1)
                    {
                        ed.WriteMessage("ERROR UpdateKhazanData(transaction) 001 : {0} \n", ex1.Message);
                        aTransaction.Rollback();
                        aConnection.Close();
                        return(false);
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR UpdateKhazanData(transaction) 01 : {0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR UpdateKhazanData 01 : {0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }
            aTransaction.Commit();
            aConnection.Close();
            return(true);
        }
コード例 #21
0
        //update in tehran 7/15
        public void DrawDisconnector()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            System.Data.DataTable ParentList = Atend.Global.Acad.UAcad.DetermineParent((int)Atend.Control.Enum.ProductType.Disconnector);

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Disconnector).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Disconnector).CommentScale;


            PromptEntityOptions peo1 = new PromptEntityOptions("Select first node:");
            PromptEntityResult  per  = ed.GetEntity(peo1);

            if (per.Status == PromptStatus.OK)
            {
                Atend.Base.Acad.AT_INFO Info1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId);
                DataRow[] drs = ParentList.Select(string.Format("SoftwareCode={0}", Info1.NodeType));
                if (drs.Length != 0)
                {
                    PromptEntityOptions peo2 = new PromptEntityOptions("Select second node:");
                    PromptEntityResult  per1 = ed.GetEntity(peo2);
                    if (per1.Status == PromptStatus.OK)
                    {
                        Atend.Base.Acad.AT_INFO Info2 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per1.ObjectId);
                        DataRow[] drs1 = ParentList.Select(string.Format("SoftwareCode={0}", Info2.NodeType));
                        if (drs1.Length != 0 && Info1.ParentCode == Info2.ParentCode)
                        {
                            DrawDisconnectorJig _DrawDisconnectorJig = new DrawDisconnectorJig(MyScale);
                            List <Entity>       ents = _DrawDisconnectorJig.GetDemo(
                                Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId)),
                                Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(per1.ObjectId)));

                            if (SaveDisConnectorData())
                            {
                                ObjectIdCollection OIC = new ObjectIdCollection();
                                //ed.WriteMessage("go for each\n");
                                foreach (Entity ent in ents)
                                {
                                    ObjectId TerminalOI = ObjectId.Null;
                                    ObjectId KetOI      = ObjectId.Null;
                                    ObjectId NOI        = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                                    Atend.Global.Acad.AcadJigs.MyLine terminal = ent as Atend.Global.Acad.AcadJigs.MyLine;
                                    if (terminal != null)
                                    {
                                        object ProductType = null;
                                        if (terminal.AdditionalDictionary.TryGetValue("ProductType", out ProductType))
                                        {
                                            if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.Terminal)
                                            {
                                                //ed.WriteMessage("terminal aws found\n");
                                                if (ProductType != null)
                                                {
                                                    TerminalOI = NOI;
                                                }
                                            }
                                            else if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.Key)
                                            {
                                                //ed.WriteMessage("Key aws found\n");
                                                if (ProductType != null)
                                                {
                                                    KetOI = NOI;
                                                }
                                            }
                                        }
                                    }
                                    OIC.Add(NOI);

                                    if (TerminalOI == ObjectId.Null)
                                    {
                                        if (KetOI == ObjectId.Null)
                                        {
                                            //ed.WriteMessage("TerminalOI == null\n");
                                            Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                            groupInfo.NodeCode    = DisConnectorPack.Code.ToString();
                                            groupInfo.ParentCode  = "";
                                            groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Disconnector;
                                            groupInfo.ProductCode = DisConnectorPack.ProductCode;
                                            groupInfo.Insert();
                                        }
                                        else
                                        {
                                            //ed.WriteMessage("KEYOI != null\n");
                                            Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                            groupInfo.NodeCode    = DisConnectorPack.Code.ToString();
                                            groupInfo.ParentCode  = "";
                                            groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Key;
                                            groupInfo.ProductCode = DisConnectorPack.ProductCode;
                                            groupInfo.Insert();
                                        }
                                    }
                                    else
                                    {
                                        //ed.WriteMessage("TerminalOI != null\n");
                                        Atend.Base.Acad.AT_INFO groupInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                        groupInfo.NodeCode    = DisConnectorPack.Code.ToString();
                                        groupInfo.ParentCode  = "";
                                        groupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Terminal;
                                        groupInfo.ProductCode = DisConnectorPack.ProductCode;
                                        groupInfo.Insert();
                                    }
                                }

                                ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(DisConnectorPack.Code.ToString(), OIC);

                                Atend.Base.Acad.AT_INFO groupInfo1 = new Atend.Base.Acad.AT_INFO(GOI);
                                groupInfo1.NodeCode    = DisConnectorPack.Code.ToString();
                                groupInfo1.ParentCode  = "";
                                groupInfo1.NodeType    = (int)Atend.Control.Enum.ProductType.Disconnector;
                                groupInfo1.ProductCode = DisConnectorPack.ProductCode;
                                groupInfo1.Insert();


                                ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(
                                    Atend.Global.Acad.UAcad.WriteNote(eDisConnector.Comment,
                                                                      _DrawDisconnectorJig.MyCenterPoint
                                                                      , MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()
                                    );

                                Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi);
                                textInfo.NodeCode    = "";
                                textInfo.ParentCode  = DisConnectorPack.Code.ToString();
                                textInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                                textInfo.ProductCode = 0;
                                textInfo.Insert();

                                Atend.Base.Acad.AT_SUB groupSub = new Atend.Base.Acad.AT_SUB(GOI);
                                groupSub.SubIdCollection.Add(per.ObjectId);
                                groupSub.SubIdCollection.Add(per1.ObjectId);
                                groupSub.SubIdCollection.Add(TextOi);
                                groupSub.Insert();

                                Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per.ObjectId);
                                Atend.Base.Acad.AT_SUB.AddToAT_SUB(GOI, per1.ObjectId);
                            }
                        } //if (drs1.Length != 0)
                    }     //if (per1.Status == PromptStatus.OK)
                }         //if (drs.Length != 0)
            }             //if (per.Status == PromptStatus.OK )
        }
コード例 #22
0
        //update from tehran 7/15
        public void DrawJumper()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            PromptEntityOptions peo = new PromptEntityOptions("");
            PromptEntityResult  perOne, perTwo;
            ObjectId            SharedPole = ObjectId.Null;

            Atend.Base.Acad.AT_INFO conductorInfo;
            Atend.Base.Acad.AT_INFO conductorInfo1;

            #region Conductor One


            peo.Message = "\nSelect First Conductor : ";
            perOne      = ed.GetEntity(peo);
            if (perOne.Status == PromptStatus.OK)
            {
                conductorInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(perOne.ObjectId);
                if (conductorInfo.ParentCode != "NONE" && (conductorInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor || conductorInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper || conductorInfo.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel))
                {
                    JumperBtranch.LeftNodeCode = new Guid(conductorInfo.NodeCode);
                    #region Conductor Two
                    peo.Message = "\nSelect Second Conductor : ";
                    perTwo      = ed.GetEntity(peo);
                    if (perTwo.Status == PromptStatus.OK)
                    {
                        conductorInfo1 = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(perTwo.ObjectId);
                        if (conductorInfo1.ParentCode != "NONE" && (conductorInfo1.NodeType == (int)Atend.Control.Enum.ProductType.Conductor || conductorInfo1.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper || conductorInfo1.NodeType == (int)Atend.Control.Enum.ProductType.GroundCabel))
                        {
                            JumperBtranch.RightNodeCode = new Guid(conductorInfo1.NodeCode);
                            JumperBtranch.Number        = "Jumper";
                            ObjectIdCollection     FirstConductorPole  = new ObjectIdCollection();
                            Atend.Base.Acad.AT_SUB firstConductorSub   = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(perOne.ObjectId);
                            ObjectIdCollection     SecondConductorPole = new ObjectIdCollection();
                            Atend.Base.Acad.AT_SUB SecondConductorSub  = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(perTwo.ObjectId);
                            foreach (ObjectId oi in firstConductorSub.SubIdCollection)
                            {
                                //Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi);
                                //if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Consol)
                                //{
                                Atend.Base.Acad.AT_SUB at_sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi);
                                foreach (ObjectId oii in at_sub.SubIdCollection)
                                {
                                    Atend.Base.Acad.AT_INFO at_poleinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oii);

                                    if (at_poleinfo.ParentCode != "NONE" && at_poleinfo.NodeType == (int)Atend.Control.Enum.ProductType.Pole)
                                    {
                                        FirstConductorPole.Add(oii);
                                    }
                                }

                                // }
                            }
                            foreach (ObjectId oi in SecondConductorSub.SubIdCollection)
                            {
                                //Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi);
                                //if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Consol)
                                //{
                                Atend.Base.Acad.AT_SUB at_sub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(oi);
                                foreach (ObjectId oii in at_sub.SubIdCollection)
                                {
                                    Atend.Base.Acad.AT_INFO at_poleinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oii);
                                    if (at_poleinfo.ParentCode != "NONE" && at_poleinfo.NodeType == (int)Atend.Control.Enum.ProductType.Pole)
                                    {
                                        SecondConductorPole.Add(oii);
                                    }
                                }

                                //}
                            }

                            foreach (ObjectId oi in FirstConductorPole)
                            {
                                foreach (ObjectId oii in SecondConductorPole)
                                {
                                    if (oi == oii)
                                    {
                                        SharedPole = oi;
                                    }
                                }
                            }



                            // draw arc
                            if (SharedPole != ObjectId.Null)
                            {
                                //Entity ContainerEntity = Atend.Global.Acad.UAcad.GetEntityByObjectID(SharedPole);
                                //Polyline p = ContainerEntity as Polyline;
                                //Point3d CenterPoint = Atend.Global.Acad.UAcad.CenterOfEntity(p);
                                Point3d StartPoint = perOne.PickedPoint;;
                                Point3d EndPoint   = perTwo.PickedPoint;

                                Line firstLine  = (Line)Atend.Global.Acad.UAcad.GetEntityByObjectID(perOne.ObjectId);
                                Line secondLine = (Line)Atend.Global.Acad.UAcad.GetEntityByObjectID(perTwo.ObjectId);
                                if (firstLine != null && secondLine != null)
                                {
                                    //ed.WriteMessage("\nGET CLOSEST POINT \n");
                                    LineSegment3d ls1 = new LineSegment3d(firstLine.StartPoint, firstLine.EndPoint);
                                    LineSegment3d ls2 = new LineSegment3d(secondLine.StartPoint, secondLine.EndPoint);

                                    StartPoint = ls1.GetClosestPointTo(StartPoint).Point;
                                    EndPoint   = ls2.GetClosestPointTo(EndPoint).Point;

                                    PointOnCurve3d pp = ls1.GetClosestPointTo(StartPoint);
                                    if (pp.IsOn(StartPoint))
                                    {
                                    }

                                    pp = ls2.GetClosestPointTo(EndPoint);
                                    if (pp.IsOn(EndPoint))
                                    {
                                    }
                                }

                                Entity a = CreateArcEntity(StartPoint, EndPoint);
                                a.LayerId = firstLine.LayerId;
                                JumperBtranch.ProductCode = conductorInfo.ProductCode;
                                if (SaveJumperData())
                                {
                                    ObjectId NewArc = Atend.Global.Acad.UAcad.DrawEntityOnScreen(a, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                                    Atend.Base.Acad.AT_INFO jumperinfo = new Atend.Base.Acad.AT_INFO(NewArc);
                                    jumperinfo.NodeCode   = JumperBtranch.Code.ToString();
                                    jumperinfo.ParentCode = "";
                                    ed.WriteMessage("   *** JUMPER PCODE : {0} \n", conductorInfo.ProductCode);
                                    jumperinfo.ProductCode = conductorInfo.ProductCode;
                                    jumperinfo.NodeType    = (int)Atend.Control.Enum.ProductType.Jumper;
                                    jumperinfo.Angle       = 0;
                                    jumperinfo.Insert();


                                    Atend.Base.Acad.AT_SUB jumperSub = new Atend.Base.Acad.AT_SUB(NewArc);
                                    //ed.WriteMessage("JUMPER : {0}\n",perOne.ObjectId);
                                    jumperSub.SubIdCollection.Add(perOne.ObjectId);
                                    //ed.WriteMessage("JUMPER : {0}\n", perTwo.ObjectId);
                                    jumperSub.SubIdCollection.Add(perTwo.ObjectId);
                                    jumperSub.Insert();

                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewArc, perOne.ObjectId);
                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewArc, perTwo.ObjectId);
                                }
                            }
                        }
                        else
                        {
                            return;
                        }
                    }//if (perTwo.Status == PromptStatus.OK)
                    else
                    {
                        return;
                    }

                    #endregion
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }

            #endregion
        }
コード例 #23
0
ファイル: AcDrawBreaker.cs プロジェクト: ParisaMousavi/ATEND
        public bool UpdatebreakerData(Guid EXCode)
        {
            Editor           ed = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbTransaction aTransaction;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();
                try
                {
                    BreakerPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode);
                    if (!UseAccess)
                    {
                        if (!eBreaker.AccessInsert(aTransaction, aConnection, true, true))
                        {
                            throw new System.Exception("eBreaker.AccessInsert failed");
                        }
                        //if (!Atend.Base.Equipment.EOperation.SentFromLocalToAccess(eBreaker.XCode, (int)Atend.Control.Enum.ProductType.Breaker, eBreaker.Code, aTransaction, aConnection))
                        //{
                        //    throw new System.Exception("operation failed");
                        //}
                    }
                    BreakerPack.IsExistance = Existance;
                    BreakerPack.ProductCode = eBreaker.Code;
                    BreakerPack.ProjectCode = ProjectCode;
                    BreakerPack.Number      = "";
                    if (BreakerPack.AccessUpdate(aTransaction, aConnection))
                    {
                        Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);// id);
                        atinfo.ProductCode = eBreaker.Code;
                        atinfo.Insert();
                        ChangeComment(Atend.Global.Acad.UAcad.GetEntityGroup(selectedObjectId), eBreaker.Comment);
                    }
                    else
                    {
                        throw new System.Exception("BreakerPack.AccessInsert2 failed");
                    }

                    if (!DKeyStatus.Update(aTransaction, aConnection))
                    {
                        throw new System.Exception("dKeyStatus.AccessUpdate Failed");
                    }


                    if (!UseAccess)
                    {
                        //if (Br.Code == -1)
                        //{
                        //WENT TO
                        //if (!Atend.Base.Equipment.EContainerPackage.SentFromLocalToAccess(eBreaker.XCode, (int)Atend.Control.Enum.ProductType.Breaker, eBreaker.Code, aTransaction, aConnection))
                        //{
                        //    throw new System.Exception("SentFromLocalToAccess failed");
                        //}
                        //}
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR UpdateBreaker 01(transaction) : {0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR UpdateBreaker 01 : {0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }

            aTransaction.Commit();
            aConnection.Close();
            return(true);
        }
コード例 #24
0
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        public void DrawTransformer(Entity PostContainerEntity)
        {
            Editor ed    = Application.DocumentManager.MdiActiveDocument.Editor;
            bool   conti = true;

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Transformer).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Transformer).CommentScale;


            DrawTransformerJig transformerJig = new DrawTransformerJig(PostContainerEntity, MyScale);
            PromptResult       pr;

            while (conti)
            {
                pr = ed.Drag(transformerJig);
                if (pr.Status == PromptStatus.OK)
                {
                    conti = false;

                    #region Save data here

                    List <Entity> Entities = transformerJig.GetEntities();
                    if (NodeCode != null && ParentCode != null)
                    {
                        ObjectIdCollection OIC = new ObjectIdCollection();

                        foreach (Entity ent in Entities)
                        {
                            ObjectId NewEntOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString());

                            Atend.Base.Acad.AT_INFO EntInfo = new Atend.Base.Acad.AT_INFO(NewEntOI);
                            EntInfo.ParentCode = ParentCode.ToString(); // TransformerParent.ToString();
                            EntInfo.NodeCode   = "";


                            Atend.Global.Acad.AcadJigs.MyPolyLine poly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
                            object ProductType = null;
                            if (poly != null)
                            {
                                if (poly.AdditionalDictionary.ContainsKey("ProductType"))
                                {
                                    poly.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                }
                            }
                            else
                            {
                                Atend.Global.Acad.AcadJigs.MyLine lin = ent as Atend.Global.Acad.AcadJigs.MyLine;
                                if (lin != null)
                                {
                                    if (lin.AdditionalDictionary.ContainsKey("ProductType"))
                                    {
                                        lin.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                    }
                                }
                                else
                                {
                                    Atend.Global.Acad.AcadJigs.MyCircle cir = ent as Atend.Global.Acad.AcadJigs.MyCircle;
                                    if (cir != null)
                                    {
                                        if (cir.AdditionalDictionary.ContainsKey("ProductType"))
                                        {
                                            cir.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                        }
                                    }
                                }
                            }



                            if (ProductType != null)
                            {
                                EntInfo.NodeType = Convert.ToInt32(ProductType);
                            }
                            else
                            {
                                EntInfo.NodeType = 0;
                            }
                            EntInfo.ProductCode = 0;
                            EntInfo.Insert();

                            OIC.Add(NewEntOI);
                        }

                        ObjectId TransformerGroupOI = Atend.Global.Acad.Global.MakeGroup(NodeCode.ToString(), OIC);

                        Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(TransformerGroupOI);
                        GroupInfo.ParentCode  = ParentCode.ToString();
                        GroupInfo.NodeCode    = NodeCode.ToString();
                        GroupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Transformer;
                        GroupInfo.ProductCode = ProductCode;
                        GroupInfo.Insert();

                        string   comment = string.Format("Tr: {0} KVR", Atend.Base.Equipment.ETransformer.AccessSelectByCode(ProductCode).Capaciy);
                        ObjectId TextOi  = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(comment,
                                                                                                                        new Point3d(transformerJig.MyCenterPoint.X,
                                                                                                                                    transformerJig.MyCenterPoint.Y,
                                                                                                                                    transformerJig.MyCenterPoint.Z)
                                                                                                                        , MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                        Atend.Base.Acad.AT_INFO TextInfo = new Atend.Base.Acad.AT_INFO(TextOi);
                        TextInfo.ParentCode  = NodeCode.ToString();
                        TextInfo.NodeCode    = "";
                        TextInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                        TextInfo.ProductCode = 0;
                        TextInfo.Insert();

                        //ed.WriteMessage("ADD TO POST TRANSFORMER\n");
                        Atend.Base.Acad.AT_SUB.AddToAT_SUB(TransformerGroupOI, PostContainerEntity.ObjectId);
                        Atend.Base.Acad.AT_SUB.AddToAT_SUB(PostContainerEntity.ObjectId, TransformerGroupOI);
                        Atend.Base.Acad.AT_SUB.AddToAT_SUB(TextOi, TransformerGroupOI);
                    }


                    #endregion
                }
                else
                {
                    conti = false;
                }
            }
        }//
コード例 #25
0
        public void DrawStreetBoxUpdate()
        {
            bool         Conti = true;
            PromptResult pr;
            Editor       ed = Application.DocumentManager.MdiActiveDocument.Editor;

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.StreetBox).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.StreetBox).CommentScale;


            DrawStreetBoxJig DSB = new DrawStreetBoxJig(eStreetBoxPhuse.Count, MyScale);

            while (Conti)
            {
                pr = ed.Drag(DSB);
                if (pr.Status == PromptStatus.OK)
                {
                    Conti = false;
                    List <Entity> ENTS = DSB.GetEntities();

                    //if (SaveStreetBoxData())
                    //{

                    ObjectIdCollection OIC = new ObjectIdCollection();

                    foreach (Entity ent in ENTS)
                    {
                        object ProductType = null;
                        Atend.Global.Acad.AcadJigs.MyPolyLine mPoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
                        if (mPoly != null)
                        {
                            //ed.WriteMessage("POLY\n");
                            if (mPoly.AdditionalDictionary.ContainsKey("ProductType"))
                            {
                                mPoly.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                //ed.WriteMessage("PT:{0}\n", Convert.ToInt32(ProductType));
                            }
                        }
                        else
                        {
                            Atend.Global.Acad.AcadJigs.MyLine mLine = ent as Atend.Global.Acad.AcadJigs.MyLine;
                            if (mLine != null)
                            {
                                //ed.WriteMessage("Line\n");
                                if (mLine.AdditionalDictionary.ContainsKey("ProductType"))
                                {
                                    mLine.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                    //ed.WriteMessage("PT:{0}\n", Convert.ToInt32(ProductType));
                                }
                            }
                            else
                            {
                                Atend.Global.Acad.AcadJigs.MyCircle mCircle = ent as Atend.Global.Acad.AcadJigs.MyCircle;
                                if (mCircle != null)
                                {
                                    if (mCircle.AdditionalDictionary.ContainsKey("ProductType"))
                                    {
                                        mCircle.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                        //ed.WriteMessage("PT:{0}\n",Convert.ToInt32(ProductType));
                                    }
                                }
                            }
                        }

                        //~~~~~~~~~~~~~~~~~~~~~~~~~~~

                        ObjectId NewDrawnOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString());
                        OIC.Add(NewDrawnOI);

                        Atend.Base.Acad.AT_INFO info = new Atend.Base.Acad.AT_INFO(NewDrawnOI);
                        info.ParentCode  = "";
                        info.ProductCode = StreetBoxPack.ProductCode;
                        info.NodeCode    = StreetBoxPack.Code.ToString();
                        if (ProductType != null)
                        {
                            info.NodeType = Convert.ToInt32(ProductType);
                        }
                        else
                        {
                            info.NodeType = 0;
                        }
                        info.Insert();

                        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    }

                    //text will add here
                    ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(
                        Atend.Global.Acad.UAcad.WriteNote(eStreetBox.Comment, new Point3d(DSB.MyBasePoint.X, DSB.MyBasePoint.Y, DSB.MyBasePoint.Z), MyCommentScale)
                        , Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()
                        );
                    OIC.Add(TextOi);

                    Atend.Base.Acad.AT_INFO Textinfo = new Atend.Base.Acad.AT_INFO(TextOi);
                    Textinfo.ParentCode  = StreetBoxPack.Code.ToString();
                    Textinfo.ProductCode = 0;
                    Textinfo.NodeCode    = "";
                    Textinfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                    Textinfo.Insert();



                    ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(Guid.NewGuid().ToString(), OIC);
                    if (GOI != ObjectId.Null)
                    {
                        Atend.Base.Acad.AT_INFO GInfo = new Atend.Base.Acad.AT_INFO(GOI);
                        GInfo.ParentCode  = "";
                        GInfo.NodeCode    = StreetBoxPack.Code.ToString();
                        GInfo.NodeType    = (int)Atend.Control.Enum.ProductType.StreetBox;
                        GInfo.ProductCode = StreetBoxPack.ProductCode;
                        GInfo.Insert();

                        //Atend.Base.Acad.AT_SUB StreetboxSub = new Atend.Base.Acad.AT_SUB(GOI);
                        //StreetboxSub.SubIdCollection.Add(TextOi);
                        //StreetboxSub.Insert();
                    }

                    //}
                }
                else
                {
                    Conti = false;
                }
            }
        }
コード例 #26
0
        //MOUSAVI->AutoPoleInstallation
        public ObjectId DrawKalamp(Point3d CenterPoint, ObjectId ParentOI)
        {
            Editor   ed       = Application.DocumentManager.MdiActiveDocument.Editor;
            ObjectId HeaderOI = ObjectId.Null;

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Kalamp).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Kalamp).CommentScale;


            double BaseX = CenterPoint.X - 2.5;
            double BaseY = CenterPoint.Y;

            Atend.Global.Acad.AcadJigs.MyPolyLine pLine = new Atend.Global.Acad.AcadJigs.MyPolyLine();
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0);
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY - 5), 0, 0, 0);
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX + 5, BaseY), 0, 0, 0);
            pLine.AddVertexAt(pLine.NumberOfVertices, new Point2d(BaseX, BaseY + 5), 0, 0, 0);
            pLine.Closed = true;


            if (ParentOI != ObjectId.Null)
            {
                Atend.Base.Acad.AT_INFO ParentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI);
                ClampPack.ParentCode = Atend.Base.Design.DPackage.AccessSelectByNodeCode(new Guid(ParentInfo.NodeCode)).Code;
                //ed.WriteMessage("parent code :{0}", ParentInfo.NodeCode);
            }
            if (SaveKalampData())
            {
                string LayerName = "";
                if (eClamp.VoltageLevel == 400)
                {
                    LayerName = Atend.Control.Enum.AutoCadLayerName.LOW_AIR.ToString();
                }
                else
                {
                    LayerName = Atend.Control.Enum.AutoCadLayerName.MED_AIR.ToString();
                }

                Matrix3d trans1 = Matrix3d.Scaling(MyScale, CenterPoint);
                pLine.TransformBy(trans1);


                HeaderOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(pLine, LayerName);

                Atend.Base.Acad.AT_INFO at_info = new Atend.Base.Acad.AT_INFO(HeaderOI);
                //ed.WriteMessage("ParentCode For connection Point: {0}\n", ParentInfo.NodeCode);
                if (ParentOI != ObjectId.Null)
                {
                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(HeaderOI, ParentOI);

                    Atend.Base.Acad.AT_INFO ParentInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ParentOI);
                    at_info.ParentCode = ParentInfo.NodeCode;
                }
                else
                {
                    at_info.ParentCode = "";
                }
                at_info.NodeCode    = ClampPack.Code.ToString();
                at_info.NodeType    = (int)Atend.Control.Enum.ProductType.Kalamp;
                at_info.ProductCode = eClamp.Code;
                at_info.Insert();

                Atend.Base.Acad.AT_SUB ConnectionPSub = new Atend.Base.Acad.AT_SUB(HeaderOI);
                ConnectionPSub.SubIdCollection.Add(ParentOI);
                ConnectionPSub.Insert();


                ObjectId TextOi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(ClampPack.Number, Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(HeaderOI)), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                Atend.Base.Acad.AT_INFO textInfo = new Atend.Base.Acad.AT_INFO(TextOi);
                textInfo.ParentCode  = ClampPack.Code.ToString();
                textInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                textInfo.NodeCode    = "";
                textInfo.ProductCode = 0;
                textInfo.Insert();

                Atend.Base.Acad.AT_SUB.AddToAT_SUB(TextOi, HeaderOI);
            }
            return(HeaderOI);
        }
コード例 #27
0
        public void DrawWeekJackPanel(Entity PostContainerEntity, int CellCount, ref DataRow[] PostEquipInserted)
        {
            Editor ed          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            bool   conti       = true;
            Guid   NodeCode    = new Guid(PostEquipInserted[0]["NodeCode"].ToString());
            Guid   ParentCode  = new Guid(PostEquipInserted[0]["ParentCode"].ToString());
            int    ProductCode = Convert.ToInt32(PostEquipInserted[0]["ProductCode"]);


            double MyScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.WeekJackPanel).Scale;

            //ed.WriteMessage("DrawWeekJackPanel 01 \n");
            DrawWeekJackPanelJig MidJ = new DrawWeekJackPanelJig(PostContainerEntity, CellCount, MyScale, ref PostEquipInserted);
            PromptResult         pr;

            while (conti)
            {
                pr = ed.Drag(MidJ);
                if (pr.Status == PromptStatus.OK)
                {
                    conti = false;
                    #region save data here
                    ObjectIdCollection OIC       = new ObjectIdCollection();
                    ObjectIdCollection HeadersOI = new ObjectIdCollection();

                    //ed.WriteMessage("DrawWeekJackPanel 02 \n");
                    List <Entity> Entities = new List <Entity>();
                    //ed.WriteMessage("DrawWeekJackPanel 03 \n");
                    Entities = MidJ.GetEntities();
                    //ed.WriteMessage("DrawWeekJackPanel 04 \n");
                    foreach (Entity ent in Entities)
                    {
                        Atend.Global.Acad.AcadJigs.MyPolyLine HeaderCablePoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
                        //ed.WriteMessage("DrawWeekJackPanel 05 \n");
                        if (HeaderCablePoly != null)
                        {
                            ObjectId hoi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.LOW_GROUND.ToString());
                            HeadersOI.Add(hoi);
                            OIC.Add(hoi);
                            //ed.WriteMessage("DrawWeekJackPanel 06 \n");
                        }
                        else
                        {
                            ObjectId NOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_GROUND.ToString());
                            if (NOI != ObjectId.Null)
                            {
                                OIC.Add(NOI);
                                Atend.Base.Acad.AT_INFO HeaderInfo = new Atend.Base.Acad.AT_INFO(NOI);
                                HeaderInfo.ParentCode  = NodeCode.ToString();
                                HeaderInfo.NodeCode    = "";
                                HeaderInfo.NodeType    = (int)Atend.Control.Enum.ProductType.WeekJackPanel;
                                HeaderInfo.ProductCode = 0;
                                HeaderInfo.Insert();
                            }
                            //ed.WriteMessage("DrawWeekJackPanel 07 \n");
                        }
                    }



                    try
                    {
                        foreach (ObjectId HeaderOI in HeadersOI)
                        {
                            Atend.Base.Acad.AT_INFO HeaderInfo = new Atend.Base.Acad.AT_INFO(HeaderOI);
                            //ed.WriteMessage("Header Parent :{0}\n", p.CodeGuid);
                            HeaderInfo.ParentCode  = NodeCode.ToString();
                            HeaderInfo.NodeCode    = "";
                            HeaderInfo.NodeType    = (int)Atend.Control.Enum.ProductType.HeaderCabel;
                            HeaderInfo.ProductCode = 0;
                            HeaderInfo.Insert();
                        }

                        ObjectId WeekGroup = Atend.Global.Acad.Global.MakeGroup(NodeCode.ToString(), OIC);

                        if (WeekGroup != ObjectId.Null)
                        {
                            Atend.Base.Acad.AT_INFO WeekInfo = new Atend.Base.Acad.AT_INFO(WeekGroup);
                            //ed.WriteMessage(">>>>>>Header Parent :{0} , WeekCode :{1} \n", p.ParentCode, p.CodeGuid);
                            WeekInfo.ParentCode  = ParentCode.ToString();
                            WeekInfo.NodeCode    = NodeCode.ToString();
                            WeekInfo.NodeType    = (int)Atend.Control.Enum.ProductType.WeekJackPanel;
                            WeekInfo.ProductCode = ProductCode;
                            WeekInfo.Insert();

                            //ed.WriteMessage("ADD TO POST WEEK\n");
                            Atend.Base.Acad.AT_SUB.AddToAT_SUB(WeekGroup, PostContainerEntity.ObjectId);
                            Atend.Base.Acad.AT_SUB.AddToAT_SUB(PostContainerEntity.ObjectId, WeekGroup);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        ed.WriteMessage("Error DrawWeekJackPanel : {0} \n", ex.Message);
                    }
                    #endregion
                }
            }
        }
コード例 #28
0
        public bool UpdateStreetBoxData(Guid EXCode)
        {
            Editor           ed = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbTransaction aTransaction;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();
                try
                {
                    StreetBoxPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode);
                    if (!UseAccess)
                    {
                        if (!eStreetBox.AccessInsert(aTransaction, aConnection, true, true))
                        {
                            throw new System.Exception("eStreetBox.AccessInsert failed");
                        }
                        else
                        {
                            foreach (Atend.Base.Equipment.EStreetBoxPhuse sbPhuses in eStreetBoxPhuse)
                            {
                                if (!sbPhuses.AccessInsert(aTransaction, aConnection, true, true))
                                {
                                    throw new System.Exception("eStreetBoxPhuse.AccessInsert failed");
                                }
                            }
                        }

                        foreach (Atend.Base.Equipment.EStreetBoxPhuse SelectedStreetBoxPhuse in eStreetBoxPhuse)
                        {
                            Atend.Base.Equipment.EPhuse phuse = Atend.Base.Equipment.EPhuse.SelectByXCode(SelectedStreetBoxPhuse.PhuseXCode);
                            if (phuse.Code != -1)
                            {
                                if (!phuse.AccessInsert(aTransaction, aConnection, true, true))
                                {
                                    throw new System.Exception("ePhuse.AccesInsert failed");
                                }
                                SelectedStreetBoxPhuse.PhuseCode     = phuse.Code;
                                SelectedStreetBoxPhuse.StreetBoxCode = eStreetBox.Code;
                                if (!SelectedStreetBoxPhuse.AccessInsert(aTransaction, aConnection, true, true))
                                {
                                    throw new System.Exception("EStreetBoxPhuseInsert failed");
                                }
                            }
                            else
                            {
                                throw new System.Exception("EPhuse.SelectByXCode failed");
                            }
                        }
                    }
                    StreetBoxPack.IsExistance = Existance;
                    StreetBoxPack.ProductCode = eStreetBox.Code;
                    StreetBoxPack.ProjectCode = ProjectCode;
                    StreetBoxPack.Number      = "";
                    if (StreetBoxPack.AccessUpdate(aTransaction, aConnection))
                    {
                        Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);
                        atinfo.ProductCode = eStreetBox.Code;
                        atinfo.Insert();
                    }
                    else
                    {
                        throw new System.Exception("StreetBoxPack.AccessInsert2 failed");
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR UpdateStreetBox 01(transaction) : {0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR UpdateStreetBox 01 : {0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }
            aTransaction.Commit();
            DeleteStreetBox(selectedObjectId);
            DrawStreetBoxUpdate();
            aConnection.Close();
            return(true);
        }
コード例 #29
0
        //~~~~~~~~~~~~~~~~~~~~~~~~~ methods ~~~~~~~~~~~~~~~~~~~~~~~~~~//

        public void DrawMeasuredJackPanel()
        {
            Editor ed             = Application.DocumentManager.MdiActiveDocument.Editor;
            bool   conti          = true;
            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MeasuredJackPanel).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.MeasuredJackPanel).CommentScale;
            DrawMeasuredJackPanelJig _DrawMeasuredJackPanelJig = new DrawMeasuredJackPanelJig(MyScale);
            PromptResult             pr;

            while (conti)
            {
                pr = ed.Drag(_DrawMeasuredJackPanelJig);
                if (pr.Status == PromptStatus.OK)
                {
                    conti = false;
                    //draw entity on screen
                    List <Entity> entities = _DrawMeasuredJackPanelJig.GetEntities();
                    if (SaveMeasuredJackPanelData())
                    {
                        ObjectIdCollection OIC = new ObjectIdCollection();
                        foreach (Entity ent in entities)
                        {
                            OIC.Add(Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString()));
                            Atend.Base.Acad.AT_INFO information = new Atend.Base.Acad.AT_INFO(OIC[OIC.Count - 1]);
                            information.Angle       = 0;
                            information.NodeCode    = MeasuredPack.Code.ToString();
                            information.NodeType    = (int)Atend.Control.Enum.ProductType.MeasuredJackPanel;
                            information.ParentCode  = "";
                            information.ProductCode = eMeasuredJackPanel.Code;
                            information.Insert();
                        }

                        ObjectId GOI = Atend.Global.Acad.Global.MakeGroup(MeasuredPack.Code.ToString(), OIC);
                        Atend.Base.Acad.AT_INFO information1 = new Atend.Base.Acad.AT_INFO(GOI);
                        information1.Angle       = 0;
                        information1.NodeCode    = MeasuredPack.Code.ToString();
                        information1.NodeType    = (int)Atend.Control.Enum.ProductType.MeasuredJackPanel;
                        information1.ParentCode  = "";
                        information1.ProductCode = eMeasuredJackPanel.Code;
                        information1.Insert();


                        eMeasuredJackPanel.Comment += " : " + eMeasuredJackPanel.Count.ToString();
                        ObjectId txtOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(eMeasuredJackPanel.Comment, new Point3d(_DrawMeasuredJackPanelJig.BasePoint.X, _DrawMeasuredJackPanelJig.BasePoint.Y, 0), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());

                        Atend.Base.Acad.AT_INFO GroupInfo1 = new Atend.Base.Acad.AT_INFO(txtOI);
                        GroupInfo1.ParentCode  = MeasuredPack.Code.ToString();
                        GroupInfo1.NodeCode    = "";
                        GroupInfo1.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                        GroupInfo1.ProductCode = 0;
                        GroupInfo1.Insert();

                        Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(GOI);
                        GroupSub.SubIdCollection.Add(txtOI);
                        GroupSub.Insert();
                    }
                }
                else
                {
                    conti = false;
                }
            }
        }
コード例 #30
0
        public void DrawRod()
        {
            Editor             ed    = Application.DocumentManager.MdiActiveDocument.Editor;
            bool               conti = true;
            ObjectIdCollection NewDrawnCollection = new ObjectIdCollection();
            //ObjectId ConsolElseOI = ObjectId.Null, ConnectionOI = ObjectId.Null, RodOI = ObjectId.Null, RodTriangeOI = ObjectId.Null;

            double MyScale        = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Rod).Scale;
            double MyCommentScale = Atend.Base.Design.DProductProperties.AccessSelectBySoftwareCode((int)Atend.Control.Enum.ProductType.Rod).CommentScale;

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect Container :");
            PromptEntityResult  per = ed.GetEntity(peo);

            if (per.Status == PromptStatus.OK)
            {
                DrawRodJig drawRod;
                Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId);
                if (at_info.ParentCode != "NONE" && (at_info.NodeType == (int)Atend.Control.Enum.ProductType.Pole || at_info.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip))
                {
                    drawRod = new DrawRodJig(Atend.Global.Acad.UAcad.GetEntityByObjectID(per.ObjectId), MyScale);
                    while (conti)
                    {
                        PromptResult pr = ed.Drag(drawRod);

                        if (pr.Status == PromptStatus.OK && drawRod.PartOneIsActive)
                        {
                            drawRod.PartOneIsActive = false;
                            pr = ed.Drag(drawRod);

                            if (pr.Status == PromptStatus.OK && !drawRod.PartOneIsActive)
                            {
                                conti = false;
                                //ed.WriteMessage("1 \n");
                                #region Save Data Here

                                List <Entity> Entities = drawRod.GetEntities();
                                //ed.WriteMessage("2 \n");
                                if (SaveRodData(at_info.NodeCode))
                                {
                                    // ed.WriteMessage("3 \n");

                                    //foreach (Entity ent in Entities)
                                    //{
                                    //    NewDrawnCollection.Add(DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MID_AIR.ToString()));
                                    //}

                                    //---------------------
                                    ObjectId ConsolElseOI = ObjectId.Null;
                                    foreach (Entity ent in Entities)
                                    {
                                        ObjectId newDrawnoi = Atend.Global.Acad.UAcad.DrawEntityOnScreen(ent, Atend.Control.Enum.AutoCadLayerName.MED_AIR.ToString());
                                        Atend.Global.Acad.AcadJigs.MyPolyLine mPoly = ent as Atend.Global.Acad.AcadJigs.MyPolyLine;
                                        if (mPoly != null)
                                        {
                                            //ed.WriteMessage("POLY LINE FOUND\n");
                                            if (mPoly.AdditionalDictionary.ContainsKey("ProductType"))
                                            {
                                                object ProductType = null;
                                                mPoly.AdditionalDictionary.TryGetValue("ProductType", out ProductType);
                                                if (ProductType != null)
                                                {
                                                    if (Convert.ToInt32(ProductType) == (int)Atend.Control.Enum.ProductType.ConsolElse)
                                                    {
                                                        ConsolElseOI = newDrawnoi;
                                                        Atend.Base.Acad.AT_INFO ConsolElseInfo = new Atend.Base.Acad.AT_INFO(newDrawnoi);
                                                        ConsolElseInfo.ParentCode  = at_info.NodeCode;
                                                        ConsolElseInfo.NodeCode    = RodPack.Code.ToString();
                                                        ConsolElseInfo.NodeType    = Convert.ToInt32(ProductType);
                                                        ConsolElseInfo.ProductCode = 0;
                                                        ConsolElseInfo.Insert();
                                                    }
                                                }
                                            }
                                        }
                                        NewDrawnCollection.Add(newDrawnoi);
                                    }

                                    //NewDrawnCollection.Add(Atend.Global.Acad.UAcad.DrawEntityOnScreen(
                                    //Atend.Global.Acad.Global.WriteNoteMText(
                                    //    Atend.Base.Equipment.ERod.SelectByCode(Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode).Comment,
                                    //    new Point3d(drawRod.CenterPoint02.X + 10, drawRod.CenterPoint02.Y, 0)),
                                    //    Atend.Control.Enum.AutoCadLayerName.MID_AIR.ToString()));


                                    if (ConsolElseOI != ObjectId.Null)
                                    {
                                        Atend.Base.Acad.AT_SUB ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConsolElseOI);
                                        foreach (ObjectId oi in NewDrawnCollection)
                                        {
                                            if (oi != ConsolElseOI)
                                            {
                                                //ed.WriteMessage("ConsolElseSubOI:{0}\n", oi);
                                                ConsolElseSub.SubIdCollection.Add(oi);
                                            }
                                        }
                                        ConsolElseSub.SubIdCollection.Add(per.ObjectId);
                                        ConsolElseSub.Insert();
                                    }
                                    //---------------------



                                    foreach (ObjectId oi in NewDrawnCollection)
                                    {
                                        if (oi != ConsolElseOI)
                                        {
                                            Atend.Base.Acad.AT_INFO a = new Atend.Base.Acad.AT_INFO(oi);
                                            a.ParentCode  = at_info.NodeCode;
                                            a.NodeCode    = RodPack.Code.ToString();
                                            a.NodeType    = (int)Atend.Control.Enum.ProductType.Rod;
                                            a.ProductCode = RodPack.ProductCode;;
                                            a.Insert();
                                        }
                                    }

                                    //for (int i = 1; i <= 4; i++)
                                    //{

                                    //    ed.WriteMessage("4 \n");
                                    //    switch (i)
                                    //    {

                                    //        case 1:
                                    //            ed.WriteMessage("5 \n");
                                    //            #region Draw & Save ConsolElse Here
                                    //            ConsolElseOI = DrawAndSaveConsolElse(Entities);
                                    //            #endregion
                                    //            break;
                                    //        case 2:
                                    //            ed.WriteMessage("6 \n");
                                    //            #region Draw & Save Connection Here
                                    //            ConnectionOI = DrawAndSaveConnection(Entities);
                                    //            #endregion
                                    //            break;
                                    //        case 3:
                                    //            ed.WriteMessage("7 \n");
                                    //            #region Draw & Save Rod Here
                                    //            RodOI = DrawAndSaveRod(Entities);
                                    //            #endregion
                                    //            break;
                                    //        case 4:
                                    //            ed.WriteMessage("8 \n");
                                    //            #region Draw & Save RodTriangle Here
                                    //            RodTriangeOI = DrawAndSaveRodTriangle(Entities);
                                    //            #endregion
                                    //            break;
                                    //    }

                                    //}

                                    //save additional data here

                                    //ed.WriteMessage("9 \n");
                                    //Atend.Base.Acad.AT_INFO ConsolElseInfo = new Atend.Base.Acad.AT_INFO(ConsolElseOI);
                                    //ConsolElseInfo.ParentCode = at_info.NodeCode;
                                    //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString();
                                    //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod;
                                    //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode;
                                    //ConsolElseInfo.Insert();


                                    //ed.WriteMessage("10 \n");
                                    //Atend.Base.Acad.AT_SUB ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConsolElseOI);
                                    //ConsolElseSub.SubIdCollection.Add(ConnectionOI);
                                    //ConsolElseSub.Insert();


                                    //``````````````````````````
                                    //ed.WriteMessage("11 \n");
                                    //ConsolElseInfo = new Atend.Base.Acad.AT_INFO(ConnectionOI);
                                    //ConsolElseInfo.ParentCode = at_info.NodeCode;
                                    //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString();
                                    //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod;
                                    //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode;
                                    //ConsolElseInfo.Insert();


                                    //ed.WriteMessage("12 \n");
                                    //ConsolElseSub = new Atend.Base.Acad.AT_SUB(ConnectionOI);
                                    //ConsolElseSub.SubIdCollection.Add(ConsolElseOI);
                                    //ConsolElseSub.SubIdCollection.Add(RodOI);
                                    //ConsolElseSub.Insert();

                                    //```````````````````````````````````````````

                                    //ed.WriteMessage("13 \n");
                                    //ConsolElseInfo = new Atend.Base.Acad.AT_INFO(RodOI);
                                    //ConsolElseInfo.ParentCode = at_info.NodeCode;
                                    //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString();
                                    //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod;
                                    //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode;
                                    //ConsolElseInfo.Insert();


                                    //ed.WriteMessage("14 \n");
                                    //ConsolElseSub = new Atend.Base.Acad.AT_SUB(RodOI);
                                    //ConsolElseSub.SubIdCollection.Add(ConnectionOI);
                                    //ConsolElseSub.SubIdCollection.Add(RodTriangeOI);
                                    //ConsolElseSub.Insert();

                                    //```````````````````````````````````````````
                                    //ed.WriteMessage("15 \n");
                                    //ConsolElseInfo = new Atend.Base.Acad.AT_INFO(RodTriangeOI);
                                    //ConsolElseInfo.ParentCode = at_info.NodeCode;
                                    //ConsolElseInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString();
                                    //ConsolElseInfo.NodeType = (int)Atend.Control.Enum.ProductType.Rod;
                                    //ConsolElseInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.ProductCode;
                                    //ConsolElseInfo.Insert();

                                    //--------------------------
                                    //ed.WriteMessage("Number of Entity : {0} \n", NewDrawnCollection.Count);

                                    ObjectId NewCreatedGroup =
                                        Atend.Global.Acad.Global.MakeGroup(RodPack.Code.ToString(), NewDrawnCollection);


                                    //Atend.Base.Equipment.ERod ERodForComment = Atend.Base.Equipment.ERod.SelectByCode(RodPack.ProductCode);

                                    //ed.WriteMessage("scale:{0} comment:{1}\n",MyCommentScale,ERod.Comment);
                                    ObjectId txtOI = Atend.Global.Acad.UAcad.DrawEntityOnScreen(Atend.Global.Acad.UAcad.WriteNote(ERod.Comment, new Point3d(drawRod.CenterPoint02.X, drawRod.CenterPoint02.Y, 0), MyCommentScale), Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());
                                    //ed.WriteMessage("text was writen\n");

                                    Atend.Base.Acad.AT_INFO GroupInfo1 = new Atend.Base.Acad.AT_INFO(txtOI);
                                    GroupInfo1.ParentCode  = RodPack.Code.ToString();
                                    GroupInfo1.NodeCode    = "";
                                    GroupInfo1.NodeType    = (int)Atend.Control.Enum.ProductType.Comment;
                                    GroupInfo1.ProductCode = 0;
                                    GroupInfo1.Insert();


                                    //Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(NewCreatedGroup);
                                    //GroupInfo.ParentCode = at_info.NodeCode;
                                    //GroupInfo.NodeCode = Atend.Base.Acad.AcadGlobal.dPackageForRod.Code.ToString();
                                    //GroupInfo.NodeType = (int)Atend.Control.Enum.ProductType.BankKhazan;
                                    //GroupInfo.ProductCode = Atend.Base.Acad.AcadGlobal.dPackageForKhazanTip.ProductCode;
                                    //GroupInfo.Insert();



                                    //    Atend.Base.Equipment.EKhazanTip khazanTip = Atend.Base.Equipment.EKhazanTip.SelectByCode(
                                    //        Atend.Base.Acad.AcadGlobal.dPackageForKhazanTip.ProductCode);


                                    //    ObjectId txtOI = DrawEntityOnScreen(
                                    //    Atend.Global.Acad.UAcad.WriteNote(khazanTip.Description, drawKhazan.GetCommentPoSition()),
                                    //    Atend.Control.Enum.AutoCadLayerName.GENERAL.ToString());


                                    Atend.Base.Acad.AT_INFO GroupInfo = new Atend.Base.Acad.AT_INFO(NewCreatedGroup);
                                    GroupInfo.ParentCode  = at_info.NodeCode;
                                    GroupInfo.NodeCode    = RodPack.Code.ToString();
                                    GroupInfo.NodeType    = (int)Atend.Control.Enum.ProductType.Rod;
                                    GroupInfo.ProductCode = RodPack.ProductCode;
                                    GroupInfo.Insert();


                                    Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewCreatedGroup, per.ObjectId);
                                    //ed.WriteMessage("PoleOI for KHazan:{0}", per.ObjectId);
                                    Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(NewCreatedGroup);
                                    GroupSub.SubIdCollection.Add(per.ObjectId);
                                    //ed.WriteMessage("TXTOI for KHazan:{0}", txtOI);
                                    GroupSub.SubIdCollection.Add(txtOI);
                                    GroupSub.Insert();


                                    //    Atend.Base.Acad.AT_SUB.AddToAT_SUB(NewCreatedGroup, per.ObjectId);

                                    //    Atend.Base.Acad.AT_SUB GroupSub = new Atend.Base.Acad.AT_SUB(NewCreatedGroup);
                                    //    GroupSub.SubIdCollection.Add(per.ObjectId);
                                    //    GroupSub.SubIdCollection.Add(txtOI);
                                    //    GroupSub.Insert();
                                }


                                #endregion
                            }
                            else
                            {
                                conti = false;
                            }
                        }
                        else
                        {
                            conti = false;
                        }
                    }
                }
            }
        }