Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public CrossType PointInPipe(Point3d point)
        {
            Polyline p  = new Polyline();
            Point3d  s  = mline.VertexAt(0);
            Point3d  e  = mline.VertexAt(1);
            Vector3d u  = (e - s).GetNormal();
            Vector3d n  = u.RotateBy(0.5 * Math.PI, Vector3d.ZAxis);
            Point3d  p1 = s + n * this.Width;
            Point3d  p2 = e + n * this.Width;
            Point3d  p3 = e - n * this.Width;
            Point3d  p4 = s - n * this.Width;

            p.AddVertexAt(0, Utils.Utility.Point3DTo2D(p1), 0, 0, 0);
            p.AddVertexAt(1, Utils.Utility.Point3DTo2D(p2), 0, 0, 0);
            p.AddVertexAt(2, Utils.Utility.Point3DTo2D(p3), 0, 0, 0);
            p.AddVertexAt(3, Utils.Utility.Point3DTo2D(p4), 0, 0, 0);
            p.AddVertexAt(4, Utils.Utility.Point3DTo2D(p1), 0, 0, 0);

            bool isInner = Utils.Utility.PointInPolygon(point, p);

            if (!isInner)
            {
                return(CrossType.CrossNone);
            }
            else
            {
                double v1 = Math.Abs((point - s).DotProduct(u));
                if (v1 < Width)
                {
                    return(CrossType.CrossNone);
                }
                double v2 = Math.Abs((e - point).DotProduct(u));
                if (v2 < Width)
                {
                    return(CrossType.CrossNone);
                }
                return(CrossType.CrossMid);
            }
        }