Esempio n. 1
0
        //获取支座
        public MxDrawPolyline GetSeatForRange(MxDrawPoint pt, MxDrawPoint spt)
        {
            double             range1 = 2000, range2 = 300;
            MxDrawSelectionSet collect = new MxDrawSelectionSet();
            MxDrawResbuf       filter  = new MxDrawResbuf();
            MxDrawLayerTable   layer   = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable();
            MxDrawPoint        start   = new MxDrawPoint
            {
                x = pt.x + range1,
                y = pt.y + range1,
                z = pt.z
            };
            MxDrawPoint end = new MxDrawPoint
            {
                x = pt.x - range1,
                y = pt.y - range1,
                z = pt.z
            };

            //Program.MainForm.axMxDrawX1.DrawLine(start.x, start.y, start.x, start.y);
            //Program.MainForm.axMxDrawX1.DrawLine(start.x, start.y, start.x, end.y);
            //Program.MainForm.axMxDrawX1.DrawLine(start.x, end.y, end.x, end.y);
            //Program.MainForm.axMxDrawX1.DrawLine(end.x, end.y, end.x, start.y);
            //Program.MainForm.axMxDrawX1.DrawLine(end.x, start.y, start.x, start.y);
            collect.Select(MCAD_McSelect.mcSelectionSetCrossing, start, end, filter);
            MxDrawEntity entity;

            //MxDrawLayerTable layer = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable();
            //MxDrawLayerTableRecord dd;
            for (int i = 0; i < collect.Count; i++)
            {
                entity = collect.Item(i);
                if (entity == null)
                {
                    continue;
                }
                if (entity.ObjectName == "McDbPolyline")
                {
                    MxDrawPolyline         polyline = entity as MxDrawPolyline;
                    MxDrawLayerTableRecord dd       = layer.GetAt(entity.Layer);
                    if (dd.Color.colorIndex != 9)
                    {
                        MxDrawPoint st = polyline.GetStartPoint();
                        MxDrawPoint et = polyline.GetEndPoint();
                        if (st.x == et.x && st.y == et.y)
                        {
                            return(polyline);
                        }
                    }
                }
            }
            return(new MxDrawPolyline());
        }
Esempio n. 2
0
        //获取梁线
        public MxDrawLine GetLineForRange(MxDrawLine et)
        {
            MxDrawPoint        pt      = et.GetStartPoint();
            MxDrawPoint        ept     = et.GetEndPoint();
            MxDrawLayerTable   layer   = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable();
            MxDrawSelectionSet collect = new MxDrawSelectionSet();
            MxDrawResbuf       filter  = new MxDrawResbuf();
            MxDrawLine         entity;
            MxDrawLine         result   = new MxDrawLine();
            double             distance = 100000000;

            collect.Select(MCAD_McSelect.mcSelectionSetAll, null, null, filter);
            for (int i = 0; i < collect.Count; i++)
            {
                entity = collect.Item(i) as MxDrawLine;
                if (entity == null)
                {
                    continue;
                }
                MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer);
                if (entity.ObjectName == "McDbLine" && entity.handle != et.handle && dd.Color.colorIndex != 1)
                {
                    //double rs1 = MathSience.pointToLineDistance(entity.GetStartPoint(), entity.GetEndPoint(), pt.x, pt.y);
                    //double rs2 = MathSience.pointToLineDistance(entity.GetStartPoint(), entity.GetEndPoint(), ept.x, ept.y);
                    double rs1 = MathSience.DistanceForPointToABLine(pt.x, pt.y, entity.GetStartPoint(), entity.GetEndPoint());
                    double rs2 = MathSience.DistanceForPointToABLine(ept.x, ept.y, entity.GetStartPoint(), entity.GetEndPoint());
                    if (rs1 <= distance)
                    {
                        distance = rs1;
                        result   = entity;
                    }
                    if (rs2 <= distance)
                    {
                        distance = rs2;
                        result   = entity;
                    }
                }
            }
            return(result);
        }
Esempio n. 3
0
        private void Delete_layer()
        {
            MxDrawSelectionSet scn    = new MxDrawSelectionSet();
            MxDrawResbuf       filter = new MxDrawResbuf();

            filter.AddStringEx("HLT_BEAM_CLINE", 8);
            scn.Select(MCAD_McSelect.mcSelectionSetWindow, null, null, filter);
            for (int i = 0; i < scn.Count; i++)
            {
                scn.Item(i).Erase();
            }
            // 得到数据库对象.
            MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase();
            // 得到层表.
            MxDrawLayerTable layerTable = database.GetLayerTable();
            // 得到层。
            MxDrawLayerTableRecord layer = layerTable.GetAt("HLT_BEAM_CLINE", false);

            if (layer != null)
            {
                layer.Erase();
            }
        }
Esempio n. 4
0
        //获取相邻的梁线
        public MxDrawLine GetMoreLine(MxDrawLine line)
        {
            int range = 600;
            MxDrawSelectionSet collect = new MxDrawSelectionSet();
            MxDrawResbuf       filter  = new MxDrawResbuf();
            MxDrawPoint        start   = line.GetStartPoint();
            MxDrawPoint        end     = line.GetEndPoint();
            MxDrawLayerTable   layer   = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable();

            collect.Select(MCAD_McSelect.mcSelectionSetCrossing, new MxDrawPoint
            {
                x = end.x + range,
                y = end.y + range,
                z = end.z
            }, new MxDrawPoint
            {
                x = end.x - range,
                y = end.y - range,
                z = end.z
            }, filter);
            //获取线判断角度<2
            for (int i = 0; i < collect.Count; i++)
            {
                MxDrawLine entity = collect.Item(i) as MxDrawLine;
                if (entity == null)
                {
                    continue;
                }
                if (entity.handle == line.handle)
                {
                    continue;
                }
                if (entity.ObjectName == "McDbLine")
                {
                    MxDrawLayerTableRecord cd = layer.GetAt(entity.Layer);
                    if (cd.Color.colorIndex != 1)
                    {
                        double angleLine = MathSience.GetAngle(line.EndPoint, entity.StartPoint, entity.EndPoint);
                        if (angleLine < 2)
                        {
                            double angle  = MathSience.GetAngle2(line.GetStartPoint(), line.GetEndPoint());
                            double angle2 = MathSience.GetAngle2(entity.GetStartPoint(), entity.GetEndPoint());
                            if ((angle < 3 && angle > -2) || Math.Abs(Math.Round(angle)) == 180)//左右
                            {
                                if (angle2 < 3 && angle2 > -2)
                                {
                                    if (MathSience.GetDistance(entity.StartPoint.x, entity.StartPoint.y, entity.EndPoint.x, entity.EndPoint.y) > 100)
                                    {
                                        return(entity);
                                    }
                                }
                            }
                            if ((angle > 80 && angle < 95) || (angle < -80 && angle > -95))//上下
                            {
                                if ((angle2 > 80 && angle2 < 95) || (angle2 < -80 && angle2 > -95))
                                {
                                    if (MathSience.GetDistance(entity.StartPoint.x, entity.StartPoint.y, entity.EndPoint.x, entity.EndPoint.y) > 100)
                                    {
                                        return(entity);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(new MxDrawLine());
        }
Esempio n. 5
0
        //获取平行线
        public MxDrawLine GetparallelLine(MxDrawLine line)
        {
            double             range = 600, range2 = 600;
            MxDrawPoint        start  = line.GetStartPoint();
            MxDrawPoint        end    = line.GetEndPoint();
            MxDrawSelectionSet select = new MxDrawSelectionSet();
            MxDrawResbuf       filter = new MxDrawResbuf();
            MxDrawLayerTable   layer  = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable();
            double             angle  = MathSience.GetAngle2(start, end);

            if (angle < 3 && angle > -2)
            {
                range = 0;
            }
            else
            {
                range2 = 0;
            }
            select.Select(MCAD_McSelect.mcSelectionSetCrossing, new MxDrawPoint
            {
                x = start.x - range,
                y = start.y - range2,
                z = start.z
            }, new MxDrawPoint
            {
                x = end.x + range,
                y = end.y + range2,
                z = end.z
            }, filter);
            //Program.MainForm.axMxDrawX1.DrawLine(end.x - range, end.y - range2, end.x - range, end.y+range2);
            //Program.MainForm.axMxDrawX1.DrawLine(end.x - range, end.y + range2, end.x + range, end.y + range2);
            //Program.MainForm.axMxDrawX1.DrawLine(end.x + range, end.y + range2, end.x + range, end.y - range2);
            //Program.MainForm.axMxDrawX1.DrawLine(end.x + range, end.y - range2, end.x - range, end.y - range2);
            for (int i = 0; i < select.Count; i++)
            {
                MxDrawLine entity = select.Item(i) as MxDrawLine;
                if (entity == null)
                {
                    continue;
                }
                if (select.Item(i).ObjectName == "McDbLine")
                {
                    MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer);
                    if (line.handle != entity.handle && dd.Color.colorIndex != 1)
                    {
                        if (MathSience.parallel(entity.GetStartPoint(), entity.GetEndPoint(), line.GetStartPoint(), line.GetEndPoint()))
                        {
                            PointF point = MathSience.point_intersection(line.GetStartPoint(), line.GetEndPoint(), entity.GetStartPoint(), entity.GetEndPoint());
                            //if (point.X==0&&point.Y==0)
                            {
                                var c1 = entity.GetStartPoint();
                                var c2 = entity.GetEndPoint();
                                //if (MathSience.GetPointIsInLine(point, c1, c2, 2))
                                {
                                    return(entity);
                                }
                            }
                        }
                    }
                }
            }
            return(new MxDrawLine());
        }