Esempio n. 1
0
        public void UpdateStartPoint(Point3d startPoint)
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr           = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                DBDictionary     mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                //mline 在修改后界面上不会自动更新,不知道是不是一个bug,所以在这里我们将线段先删除再插入
                Mline lastLine = (Mline)tr.GetObject(BaseObjectId, OpenMode.ForWrite, false);
                HeatSource.HeatSourceLayoutApp.currentSolution.PipeLines.Remove(BaseObjectId);
                lastLine.Erase();
                Mline newLine = new Mline();
                if (this.Style == Solution.PipeLineStyle.AnyConnectedBuilding)
                {
                    newLine.Style = mlineStyleDic.GetAt("PIPELINE");
                }
                else
                {
                    newLine.Style = mlineStyleDic.GetAt("PIPELINEW");
                }
                newLine.Normal = Vector3d.ZAxis;
                newLine.Scale  = GetLineScale();
                newLine.AppendSegment(startPoint);
                newLine.AppendSegment(lastLine.VertexAt(1));
                //lastLine.RemoveLastSegment(endPoint);
                BaseObjectId = btr.AppendEntity(newLine);
                tr.AddNewlyCreatedDBObject(newLine, true);
                tr.Commit();
                mline = newLine;
                HeatSource.HeatSourceLayoutApp.currentSolution.PipeLines.Add(BaseObjectId, this);
                this.Save();
            }
        }
Esempio n. 2
0
        public PipeLine(Point3d p1, Point3d p2, bool NoSave, Solution sol, bool needId)
            : base(needId)
        {
            this.OwnSolution = sol;
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                mline = new Mline();
                DBDictionary mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                this.Style = OwnSolution.CurrentLineStyle;
                if (this.Style == Solution.PipeLineStyle.AnyConnectedBuilding)
                {
                    mline.Style = mlineStyleDic.GetAt("PIPELINE");
                }
                else
                {
                    mline.Style = mlineStyleDic.GetAt("PIPELINEW");
                }
                mline.Normal = Vector3d.ZAxis;
                mline.Scale  = GetLineScale();
                this.Width   = GetLineScale() / 2;
                mline.AppendSegment(p1);
                mline.AppendSegment(p2);
            }
        }
Esempio n. 3
0
        public PipeLine(Point3d p1, Point3d p2, Solution sol, bool needId) : base(needId)
        {
            this.BaseObjectId        = ObjectId.Null;
            this.OwnSolution         = sol;
            this.HeadConnectedObject = null;
            this.TailConnectedObject = null;
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                mline = new Mline();
                BlockTableRecord btr           = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                DBDictionary     mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                this.Style = OwnSolution.CurrentLineStyle;
                if (this.Style == Solution.PipeLineStyle.AnyConnectedBuilding)
                {
                    mline.Style = mlineStyleDic.GetAt("PIPELINE");
                }
                else
                {
                    mline.Style = mlineStyleDic.GetAt("PIPELINEW");
                }
                mline.Normal = Vector3d.ZAxis;
                mline.Scale  = GetLineScale();
                this.Width   = GetLineScale() / 2;
                mline.AppendSegment(p1);
                mline.AppendSegment(p2);
                this.BaseObjectId = btr.AppendEntity(mline);
                tr.AddNewlyCreatedDBObject(mline, true);
                tr.Commit();
                OwnSolution.PipeLines.Add(this.BaseObjectId, this);
            }
        }
Esempio n. 4
0
        protected override bool Update()
        {
            if (ptcurrent != null)
            {
                Mline mline = Entity as Mline;

                if (count == 1)
                {
                    mline.AppendSegment(ptcurrent);
                    ptlast = ptcurrent;
                    count  = 2;
                    pts.Add(ptlast);
                    return(true);
                }
                //Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("c=" + count + ",n=" + mline.NumberOfVertices);

                if (count == mline.NumberOfVertices)
                {
                    pts.RemoveAt(count);
                    mline.RemoveLastSegment(ptlast);
                    mline.AppendSegment(ptcurrent);
                    ptlast = ptcurrent;
                    pts.Add(ptlast);
                }
                else if (count == (mline.NumberOfVertices + 1))
                {
                    //pts.RemoveAt(count);
                    mline.AppendSegment(ptcurrent);
                    pts.Add(ptlast);
                }
            }
            return(true);
        }
Esempio n. 5
0
        public void RetriveMline()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                this.mline = (Mline)tr.GetObject(BaseObjectId, OpenMode.ForRead, false);
                tr.Dispose();
            }
        }
Esempio n. 6
0
        public mline(Point3d point, Vector3d normal) : base(new Mline())
        {
            Mline mline = Entity as Mline;

            mline.Normal     = normal;
            mline.ColorIndex = 1;
            mline.Style      = Application.DocumentManager.MdiActiveDocument.Database.CmlstyleID;
            mline.AppendSegment(point);
            pts.Add(point);
            ptlast = point;
            count  = 1;
        }
Esempio n. 7
0
        public List <Point3d> GetConnectedPipePoints(int index)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            using (Transaction trans = ed.Document.Database.TransactionManager.StartTransaction())
            {
                Mline          ent = (Mline)trans.GetObject(this.ConnectedPipes[index].BaseObjectId, OpenMode.ForRead);
                List <Point3d> v   = new List <Point3d>();
                v.Add(ent.VertexAt(0));
                v.Add(ent.VertexAt(1));
                v.Sort(new ComparePoint(CenterPoint));
                return(v);
            }
        }
Esempio n. 8
0
        public bool StartDraw(out bool status)
        {
            status = false;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;

            if (this.startPoint == null)
            {
                PromptPointOptions opt = new PromptPointOptions("\n 选择管道的初始点");
                PromptPointResult  res = ed.GetPoint(opt);
                if (res.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                if (res.Status != PromptStatus.OK)
                {
                    return(false);
                }
                this.startPoint = res.Value;
            }
            mline = new Mline();
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                mline.Style = mlineStyleDic.GetAt("MLINEJIG");
            }
            mline.Normal = Vector3d.ZAxis;
            mline.Scale  = PipeLine.GetScale();
            mline.AppendSegment((Point3d)this.startPoint);
            mline.AppendSegment((Point3d)this.startPoint);
            PromptResult res2 = ed.Drag(this);

            if (res2.Status == PromptStatus.OK)
            {
                return(true);
            }
            else if (res2.Status == PromptStatus.Cancel || res2.Status == PromptStatus.None)
            {
                if (res2.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                return(false);
            }
            return(true);
        }
        public bool StartDraw(out bool status)
        {
            status = false;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;
            if (this.startPoint == null)
            {

                PromptPointOptions opt = new PromptPointOptions("\n 选择管道的初始点");
                PromptPointResult res = ed.GetPoint(opt);
                if(res.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                if (res.Status != PromptStatus.OK)
                {
                    return false;
                }
                this.startPoint = res.Value;
            }
            mline = new Mline();
            using(Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                mline.Style = mlineStyleDic.GetAt("MLINEJIG");
            }
            mline.Normal = Vector3d.ZAxis;
            mline.Scale = PipeLine.GetScale();
            mline.AppendSegment((Point3d)this.startPoint);
            mline.AppendSegment((Point3d)this.startPoint);
            PromptResult res2 = ed.Drag(this);
            if (res2.Status == PromptStatus.OK)
            {
                return true;
            }
            else if (res2.Status == PromptStatus.Cancel || res2.Status == PromptStatus.None)
            {
                if(res2.Status == PromptStatus.Cancel)
                {
                    status = true;
                }
                return false;
            }
            return true;
        }
Esempio n. 10
0
        public void CancelHighlight()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    try
                    {
                        BlockTableRecord btr           = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                        DBDictionary     mlineStyleDic = (DBDictionary)tr.GetObject(db.MLStyleDictionaryId, OpenMode.ForRead);
                        if (mline.Style == mlineStyleDic.GetAt("HIGHLIGHT") || mline.Style == mlineStyleDic.GetAt("HIGHLIGHTW"))
                        {
                            Mline newmline = new Mline();
                            if (this.Style == Solution.PipeLineStyle.AnyConnectedBuilding)
                            {
                                newmline.Style = mlineStyleDic.GetAt("PIPELINE");
                            }
                            else
                            {
                                newmline.Style = mlineStyleDic.GetAt("PIPELINEW");
                            }
                            newmline.Normal = Vector3d.ZAxis;
                            newmline.Scale  = GetLineScale();
                            this.Width      = GetLineScale() / 2;
                            newmline.AppendSegment(this.Point(0));
                            newmline.AppendSegment(this.Point(1));
                            this.Delete();
                            this.BaseObjectId = btr.AppendEntity(newmline);
                            tr.AddNewlyCreatedDBObject(newmline, true);
                            tr.Commit();
                            mline = newmline;
                            OwnSolution.PipeLines.Add(this.BaseObjectId, this);
                            this.Save();
                        }
                    }
                    catch (Exception e)
                    {
                        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.Message);
                    }
                }
            }
        }
Esempio n. 11
0
        public ILineString ReadLineString(Mline multiLine)
        {
            var coordinateList = new CoordinateList();
            int num            = multiLine.NumberOfVertices - 1;

            for (int i = 0; i <= num; i++)
            {
                coordinateList.Add(this.ReadCoordinate(multiLine.VertexAt(i)), this.AllowRepeatedCoordinates);
            }
            if (multiLine.IsClosed)
            {
                coordinateList.Add(coordinateList[0]);
            }
            if (coordinateList.Count > 1)
            {
                return(this.GeometryFactory.CreateLineString(coordinateList.ToCoordinateArray()));
            }
            return(LineString.Empty);
        }
Esempio n. 12
0
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            Document doc              = Application.DocumentManager.MdiActiveDocument;
            Editor   ed               = doc.Editor;
            Mline    mline            = Entity as Mline;
            JigPromptPointOptions ppo = new JigPromptPointOptions("\n 请指定下一点");

            ppo.Keywords.Add(" ", " ", " ");
            ppo.Keywords.Default = " ";
            ppo.UseBasePoint     = true;
            if (mline.NumberOfVertices > 1)
            {
                ppo.BasePoint = mline.VertexAt(mline.NumberOfVertices - 2);
            }
            else
            {
                ppo.BasePoint = ptlast;
            }
            PromptPointResult ppr = prompts.AcquirePoint(ppo);

            ptcurrent = ppr.Value;
            if (ptcurrent == ptlast)
            {
                return(SamplerStatus.NoChange);
            }
            if (ppr.Status == PromptStatus.Keyword)
            {
                if (ppr.StringResult == " ")
                {
                    count++;
                }
                else
                {
                    return(SamplerStatus.OK);
                }
            }
            if (ppr.Status == PromptStatus.OK)
            {
                return(SamplerStatus.OK);
            }
            return(SamplerStatus.NoChange);
        }
Esempio n. 13
0
        public double CalculateLength()
        {
            double res = 0;

            if (BaseObjectId == ObjectId.Null)
            {
                return(0);
            }
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Mline    line = (Mline)tr.GetObject(BaseObjectId, OpenMode.ForRead, false);
                Point3d  s    = mline.VertexAt(0);
                Point3d  e    = mline.VertexAt(1);
                Vector3d v    = e - s;
                res = v.Length * HeatSourceLayoutApp.globalProperty.GraphScale;
                tr.Dispose();
            }
            return(res);
        }