Пример #1
0
        //支座与L1最远交点共点梁线
        public MxDrawLine GetXpoint(MxDrawPoint pts, MxDrawPoint pte, MxDrawPolyline seat)
        {
            MxDrawPoints       pty     = new MxDrawPoints();
            MxDrawSelectionSet collect = new MxDrawSelectionSet();

            for (int i = 0; i < seat.NumVerts; i++)
            {
                MxDrawPoint temp1 = seat.GetPointAt(i);
                temp1.x = Math.Round(temp1.x, 6);
                temp1.y = Math.Round(temp1.y, 6);
                double angle = MathSience.GetAngle2(pts, pte);
                if ((angle < 3 && angle > -2) || Math.Round(Math.Abs(angle)) == 180)//左右
                {
                    if (Math.Round(pts.x, 6) != temp1.x && Math.Round(pte.x, 6) != temp1.x)
                    {
                        pty.Add2(temp1);
                    }
                }
                if ((angle > 80 && angle < 95) || (angle < -80 && angle > -95))//上下
                {
                    if (Math.Round(pts.y, 6) != temp1.y && Math.Round(pte.y, 6) != temp1.y)
                    {
                        pty.Add2(temp1);
                    }
                }
            }
            if (pty.Count > 1)
            {
                PointF ptx = MathSience.point_intersection(pts, pte, pty.Item(0), pty.Item(1));
                collect.AllSelect();
                for (int i = 0; i < collect.Count; i++)
                {
                    MxDrawLine line = collect.Item(i) as MxDrawLine;
                    if (line == null)
                    {
                        continue;
                    }
                    if (line.ObjectName == "McDbLine")
                    {
                        MxDrawPoint t1 = line.StartPoint;
                        MxDrawPoint t2 = line.EndPoint;
                        MxDrawPoint tp = new MxDrawPoint
                        {
                            x = ptx.X,
                            y = ptx.Y
                        };
                        if (Math.Abs(Math.Round(t1.x) - ptx.X) < 1.5 && Math.Abs(Math.Round(t1.y) - ptx.Y) < 1.5)
                        {
                            return(line);
                        }
                        else if (Math.Abs(Math.Round(t2.x) - ptx.X) < 1.5 && Math.Abs(Math.Round(t2.y) - ptx.Y) < 1.5)
                        {
                            return(line);
                        }
                    }
                }
            }
            return(new MxDrawLine());
        }
Пример #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);
        }
Пример #3
0
        //选择集
        private void AxMxDrawX1_MouseEvent(object sender, _DMxDrawXEvents_MouseEventEvent e)
        {
            MxDrawPoint start = new MxDrawPoint(), end = new MxDrawPoint();

            if (PublicValue != null)
            {
                dynamic c = PublicValue;
                start.x = c.Lx;
                start.y = c.Ly;
                start.z = c.Lz;
                end.x   = c.Rx;
                end.y   = c.Ry;
                end.z   = c.Rz;
            }
            {
                MxDrawSelectionSet mxDrawSelection;
                MxDrawResbuf       filter;
                MxDrawPoint        point;
                if (e.lType == 2 && (Control.ModifierKeys & Keys.Control) == Keys.Control)
                {
                    mxDrawSelection = new MxDrawSelectionSet();
                    filter          = new MxDrawResbuf();
                    point           = new MxDrawPoint();
                    point.x         = e.dX; point.y = e.dY;
                    mxDrawSelection.SelectAtPoint(point, filter);
                    //MessageBox.Show(mxDrawSelection.Count.ToString());
                    if (mxDrawSelection.Count > 0)
                    {
                        if (start.x != 0 && end.x != 0)
                        {
                            if (!MathSience.IsContains(point, start, end))
                            {
                                return;
                            }
                        }
                        //MessageBox.Show(mxDrawSelection.Item(0).handle.ToString());
                        axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(0).ObjectID);
                        if (BeamType == "change_line")
                        {
                            if (beam.beam.side_lines.Find(x => x == mxDrawSelection.Item(0).handle) == null)
                            {
                                beam.beam.side_lines.Add(mxDrawSelection.Item(0).handle);
                            }
                            else
                            {
                                axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID);
                                beam.beam.side_lines.Remove(mxDrawSelection.Item(0).handle);
                            }
                        }
                        if (BeamType == "change_dim")
                        {
                            if (beam.beam.dim_texts.Find(x => x == mxDrawSelection.Item(0).handle) == null)
                            {
                                beam.beam.dim_texts.Add(mxDrawSelection.Item(0).handle);
                            }
                            else
                            {
                                axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID);
                                beam.beam.dim_texts.Remove(mxDrawSelection.Item(0).handle);
                            }
                        }
                        if (BeamType == "change_seat")
                        {
                            if (beam.beam.seat_lines.Find(x => x == mxDrawSelection.Item(0).handle) == null)
                            {
                                beam.beam.seat_lines.Add(mxDrawSelection.Item(0).handle);
                            }
                            else
                            {
                                axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID);
                                beam.beam.seat_lines.Remove(mxDrawSelection.Item(0).handle);
                            }
                        }
                    }
                }
                else if (e.lType == 2 && (Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                {
                    //dynamic pt = PublicValue;
                    //MxDrawPoint sp = new MxDrawPoint { x = pt.Lx, y = pt.Ly };
                    //MxDrawPoint ep = new MxDrawPoint { x = pt.Rx, y = pt.Ry };
                    mxDrawSelection = new MxDrawSelectionSet();
                    filter          = new MxDrawResbuf();
                    point           = new MxDrawPoint();
                    point.x         = e.dX; point.y = e.dY;
                    mxDrawSelection.SelectAtPoint(point, filter);
                    if (mxDrawSelection.Count > 0)
                    {
                        MxDrawEntity entity = mxDrawSelection.Item(0);
                        //MessageBox.Show(entity.Layer);
                        filter          = new MxDrawResbuf();
                        mxDrawSelection = new MxDrawSelectionSet();
                        filter.AddStringEx(entity.Layer, 8);//
                        if (start.x == 0)
                        {
                            mxDrawSelection.Select(MCAD_McSelect.mcSelectionSetAll, null, null, filter);//获取此图层元素
                        }
                        else
                        {
                            mxDrawSelection.Select(MCAD_McSelect.mcSelectionSetWindow, start, end, filter);//获取此图层元素
                        }
                        for (int i = 0; i < mxDrawSelection.Count; i++)
                        {
                            axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(i).ObjectID);
                            if (BeamType == "change_line")
                            {
                                if (beam.beam.side_lines.Find(x => x == mxDrawSelection.Item(i).handle) == null)
                                {
                                    beam.beam.side_lines.Add(mxDrawSelection.Item(i).handle);
                                }
                                else
                                {
                                    axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID);
                                    beam.beam.side_lines.Remove(mxDrawSelection.Item(i).handle);
                                }
                            }
                            if (BeamType == "change_dim")
                            {
                                if (beam.beam.dim_texts.Find(x => x == mxDrawSelection.Item(i).handle) == null)
                                {
                                    beam.beam.dim_texts.Add(mxDrawSelection.Item(i).handle);
                                }
                                else
                                {
                                    axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID);
                                    beam.beam.dim_texts.Remove(mxDrawSelection.Item(i).handle);
                                }
                            }
                            if (BeamType == "change_seat")
                            {
                                if (beam.beam.seat_lines.Find(x => x == mxDrawSelection.Item(i).handle) == null)
                                {
                                    beam.beam.seat_lines.Add(mxDrawSelection.Item(i).handle);
                                }
                                else
                                {
                                    axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID);
                                    beam.beam.seat_lines.Remove(mxDrawSelection.Item(i).handle);
                                }
                            }
                            //beam.beam.seat_lines.Add(mxDrawSelection.Item(i).handle);
                            //选中元素
                            //axMxDrawX1.AddCurrentSelect(mxDrawSelection.Item(i).ObjectID, false, false);
                        }
                    }
                }
                //axMxDrawX1.SendStringToExecute("");
            };
        }
Пример #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());
        }
Пример #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());
        }