Beispiel #1
0
        //找到复用梁
        public List <string> GetItemAsync(string kval)
        {
            List <string>      vs     = new List <string>();
            MxDrawSelectionSet select = new MxDrawSelectionSet();
            MxDrawResbuf       filter = new MxDrawResbuf();

            filter.AddStringEx("TEXT,MTEXT", 5020);
            select.Select2(MCAD_McSelect.mcSelectionSetAll, null, null, null, filter);
            for (int i = 0; i < select.Count; i++)
            {
                MxDrawEntity entity = select.Item(i);
                if (entity == null)
                {
                    continue;
                }
                if (entity.ObjectName == "McDbText")
                {
                    MxDrawText tx = entity as MxDrawText;
                    if (tx.TextString.Trim() != "" && kval.Contains(tx.TextString))
                    {
                        vs.Add(tx.handle);
                    }
                }
            }
            return(vs);
        }
Beispiel #2
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());
        }
Beispiel #3
0
        //选择范围
        private void T1007()
        {
            axMxDrawX1.DynWorldDraw += AxMxDrawX1_DynWorldDraw;//添加动态画框事件
            axMxDrawX1.AddLayer("tkbox");
            MxDrawPoint pt1 = axMxDrawX1.GetPoint(false, 0, 0, "开始坐标...") as MxDrawPoint;

            if (pt1 == null)
            {
                return;
            }
            MxDrawUiPrPoint scpt = new MxDrawUiPrPoint();

            scpt.message   = "终点坐标...";
            scpt.basePoint = pt1;
            scpt.setUseBasePt(false);
            var spdata = scpt.InitUserDraw("SelectRangeBox");

            axMxDrawX1.SetSysVarLong("ORTHOMODE", 0);
            spdata.SetPoint("BasePoint", pt1);
            if (scpt.go() != MCAD_McUiPrStatus.mcOk)
            {
                return;
            }
            spdata.Draw();

            //放大
            axMxDrawX1.ZoomWindow(pt1.x, pt1.y, spdata.DragPoint.x, spdata.DragPoint.y);
            PublicValue = new
            {
                Lx = pt1.x,
                Ly = pt1.y,
                Lz = pt1.z,
                Rx = spdata.DragPoint.x,
                Ry = spdata.DragPoint.y,
                Rz = spdata.DragPoint.z
            };
            //删除选择框
            MxDrawSelectionSet ss     = new MxDrawSelectionSet();
            MxDrawResbuf       filter = new MxDrawResbuf();

            filter.AddStringEx("tkbox", 8);
            ss.Select(MCAD_McSelect.mcSelectionSetAll, null, null, filter);
            for (int i = 0; i < ss.Count; i++)
            {
                axMxDrawX1.Erase(ss.Item(i).ObjectID);
            }
            //删掉画框的图层
            MxDrawDatabase          database = axMxDrawX1.GetDatabase() as MxDrawDatabase;
            IMxDrawLayerTableRecord layer    = database.GetLayerTable().GetAt("tkbox", false);

            if (layer != null)
            {
                layer.Erase();
            }
            return;
        }
Beispiel #4
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());
        }
Beispiel #5
0
        private void AxMxDrawX1_MouseEvent1(object sender, _DMxDrawXEvents_MouseEventEvent e)
        {
            if (e.lType == 2 && (Control.ModifierKeys & Keys.Control) == Keys.Control)
            {
                MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet();
                MxDrawResbuf       filter          = new MxDrawResbuf();
                filter.AddStringEx("HLT_BEAM_CLINE", 8);
                MxDrawPoint point = new MxDrawPoint
                {
                    x = e.dX,
                    y = e.dY,
                };
                mxDrawSelection.SelectAtPoint(point, filter);
                if (mxDrawSelection.Count > 0)
                {
                    axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(0).ObjectID);

                    onePeaceEdit.LineID = mxDrawSelection.Item(0).handle;
                }
                axMxDrawX1.MouseEvent -= AxMxDrawX1_MouseEvent1;
            }
        }
Beispiel #6
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);
        }
Beispiel #7
0
 private void axMxDrawX1_MxKeyUp(object sender, AxMxDrawXLib._DMxDrawXEvents_MxKeyUpEvent e)
 {
     //ESC取消掉执行此功能
     if (e.lVk == 27)
     {
         bar_state.state = false;
     }
     //shift切换选择
     if (e.lVk == 16)
     {
         if (bar_state.id == 1001)
         {
             MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet();
             MxDrawResbuf       filter          = new MxDrawResbuf();
             mxDrawSelection.CurrentSelect(filter);
             if (mxDrawSelection.Count > 0)
             {
                 axMxDrawX1.AddCurrentSelect(mxDrawSelection.Item(objID).ObjectID, true, true);
             }
         }
     }
 }
Beispiel #8
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();
            }
        }
Beispiel #9
0
        //鼠标点击事件
        private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e)
        {
            /*
             * 事件类型,1鼠标移动,2是鼠标左键按下,3是鼠标右键按下,4是鼠标左键双击
             * 5是鼠标左键释放 6是鼠标右键释放 7是鼠标中键按下 8是鼠标中键释放
             * 9是鼠标中键双击 10是鼠标中键滚动
             */

            switch (e.lType)
            {
            case 4:    //左键选择元素图层--所有元素
                //if(bar_state.state==true&& bar_state.id == 1001)
            {
                MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet();
                MxDrawResbuf       filter          = new MxDrawResbuf();
                MxDrawPoint        point           = new MxDrawPoint();
                point.x = e.dX; point.y = e.dY;
                mxDrawSelection.SelectAtPoint(point, filter);
                if (mxDrawSelection.Count > 0)
                {
                    MxDrawEntity entity = mxDrawSelection.Item(1);
                    //MxDrawLayerTable layer = (axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable();
                    //MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer);
                    if (entity.ObjectName == "McDbLine")
                    {
                        MessageBox.Show(JsonConvert.SerializeObject(new
                            {
                                handle = entity.handle,
                                ID     = entity.ObjectID,
                                Line   = entity.ObjectName,
                                B      = entity.LineType,
                                pt1    = ((MxDrawLine)entity).GetStartPoint(),
                                pt2    = ((MxDrawLine)entity).GetEndPoint(),
                                //color=dd.Color.colorIndex
                            }));
                    }
                    else
                    {
                        MessageBox.Show(JsonConvert.SerializeObject(new
                            {
                                handle = entity.handle,
                                ID     = entity.ObjectID,
                                Line   = entity.ObjectName,
                                B      = entity.LineType,
                                rotate = ((MxDrawText)entity).Rotation
                                         //pt1 = ((MxDrawLine)entity).GetStartPoint(),
                                         //pt2 = ((MxDrawLine)entity).GetEndPoint(),
                                         //color=dd.Color.colorIndex
                            }));
                    }
                    //double c=Models.MathSience.DistanceForPointToABLine(121324.953422, 33700.002475, ((MxDrawLine)entity).GetStartPoint(),((MxDrawLine)entity).GetEndPoint());
                    //double c1 = Algorithm.MathSience.GetAngle(new MxDrawPoint { x = 121324.95342187915, y = 54350.00279569807 }, ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                    double c1 = Algorithm.MathSience.GetLineK(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                    MessageBox.Show(c1.ToString());
                    //double c = Algorithm.MathSience.GetAngle2(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                    //MxDrawLine line = axMxDrawX1.HandleToObject("61FCB") as MxDrawLine;
                    //PointF point1 = Algorithm.MathSience.point_intersection(line.GetStartPoint(), line.GetEndPoint(), ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint());
                }
            }
            break;
            }
        }
Beispiel #10
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("");
            };
        }
Beispiel #11
0
        private void makeAutoImgBtn_Click(object sender, RoutedEventArgs e)
        {
            //先进行参数计算
            //每一开深度,三开底部和煤层顶板的距离
            double oneKai = 30;

            if (wanQuDaiTb.Text.Trim().Equals(""))
            {
                MessageBox.Show("未计算弯曲带高度,请修正再尝试井型设计");
                return;
            }
            double twoKai = double.Parse(wanQuDaiTb.Text) + 20;

            int meiIndex = layers.Count - 1;
            for (; meiIndex >= 0; meiIndex--)
            {
                if (layers[meiIndex].yanXing.Equals("煤"))
                {
                    break;
                }
            }
            if (meiIndex <= 0)
            {
                MessageBox.Show("岩层数据有误,请修正再尝试自动设计");
                tabControl.SelectedItem = gridinputTabItem;
                return;
            }
            double threeKai = layers[meiIndex - 1].leiJiShenDu - 10;
            double threeToMei = 10;

            //局部固井的深度值
            double jbgjShendu = double.Parse(wanQuDaiTb.Text);

            //各级套管外径;水泥环厚度
            double snhHoudu = editZengYi.a1 - editZengYi.aw;

            double tgwj1, tgwj2, tgwj3;
            tgwj1 = keyLayers[0].tgwj;
            tgwj2 = keyLayers[wanQuDaiIndex].tgwj;
            tgwj3 = keyLayers[keyLayers.Count - 1].tgwj;

            //高位位置数量,破坏主因
            string dangerStr = "";
            int dangerCnt = 0;
            ERRORCODE errcode = computeSafe(keyLayers.Count);
            switch (errcode)
            {
                case ERRORCODE.计算成功:
                    for (int i = 0; i < keyLayers.Count; i++)
                    {
                        if (keyLayers[i].jqaqxs < 1)
                        {
                            keyLayers[i].IsDangerous = true;
                            dangerCnt++;
                            dangerStr += "\\P" + dangerCnt + " 深度:" + keyLayers[i].ycsd.ToString("f3") + "m  剪切安全系数低,值为:" + keyLayers[i].jqaqxs.ToString("f3");
                        }
                        else if(keyLayers[i].lsaqxs < 1)
                        {
                            keyLayers[i].IsDangerous = true;
                            dangerCnt++;
                            dangerStr += "\\P" + dangerCnt + " 深度:" + keyLayers[i].ycsd.ToString("f3") + "m  拉伸安全系数低,值为:" + keyLayers[i].lsaqxs.ToString("f3");
                        }
                        else
                        {
                            keyLayers[i].IsDangerous = false;
                        }
                    }
                    break;
                case ERRORCODE.计算异常:
                    MessageBox.Show("因计算安全系数出错,未生成cad图,请检查数据合理性");
                    return;
                case ERRORCODE.没有关键层数据:
                    MessageBox.Show("因没有关键层数据,未生成cad图");
                    return;
            }

            //显示cad
            tabControl.SelectedItem = autoDesignCadTabItem;
            cadViewer.OpenDwgFile("cads/三开-一全固二局固三" + AutoWjfs3 + ".dwg");
            cadViewer.ZoomCenter(2500, 300);
            cadViewer.ZoomScale(1);

            //参数标注
            MxDrawSelectionSet ss = new MxDrawSelectionSet();
            IMxDrawResbuf spFilter = new MxDrawResbuf();
            ss.Select2(MCAD_McSelect.mcSelectionSetAll, null, null, null, null);

            for (int j = 0; j < ss.Count; j++)
            {
                MxDrawEntity ent = ss.Item(j);

                if (ent is MxDrawMText)
                {
                    MxDrawMText mText = (MxDrawMText)ent;
                    string contents = mText.Contents;
                    //MessageBox.Show(contents);
                    //地面井名称
                    if(contents.Contains("地面井名称"))
                    {
                        mText.Contents = contents.Replace("地面井名称", "地面井名称:" + Path.GetFileNameWithoutExtension(FilePath));
                    }
                    //描述
                    else if(contents.Contains("一开结构"))
                    {
                        mText.Contents = contents.Replace("一开结构", "一开结构\\P\\P" + AutoMiaoshu1);
                    }
                    else if(contents.Contains("二开结构")){
                        mText.Contents = contents.Replace("二开结构", "二开结构\\P\\P" + AutoMiaoshu2);
                    }
                    else if(contents.Contains("三开结构")){
                        mText.Contents = contents.Replace("三开结构", "三开结构\\P\\P" + AutoMiaoshu3);
                    }
                    //各级套管深度、局部固井深度、三开底部和煤层顶板的距离
                    else if (contents.Contains("一开深度"))
                    {
                        mText.Contents = contents.Replace("一开深度", oneKai.ToString("f3") + "m");
                    }
                    else if (contents.Contains("二开深度"))
                    {
                        mText.Contents = contents.Replace("二开深度", twoKai.ToString("f3") + "m");
                    }
                    else if (contents.Contains("三开深度"))
                    {
                        mText.Contents = contents.Replace("三开深度", threeKai.ToString("f3") + "m");
                    }
                    else if (contents.Contains("局部固井深度"))
                    {
                        mText.Contents = contents.Replace("局部固井深度", jbgjShendu.ToString("f3") + "m");
                    }
                    else if (contents.Contains("底部到顶板距离"))
                    {
                        mText.Contents = contents.Replace("底部到顶板距离", threeToMei.ToString("f3") + "m");
                    }
                    //各级套管型号和参数
                    else if (contents.Contains("各级套管型号和参数"))
                    {
                        mText.Contents = contents.Replace("各级套管型号和参数", "各级套管型号和参数\\P\\P" +
                            "一开型号:" + AutoTgxh1 + "   外径:" + tgwj1 + "mm" + "\\P" +
                            "二开型号:" + AutoTgxh2 + "   外径:" + tgwj2 + "mm" + "\\P" +
                            "三开型号:" + AutoTgxh3 + "   外径:" + tgwj3 + "mm" );
                    }
                    //固井工艺、完井工艺、水泥环厚度
                    else if (contents.Contains("固井工艺、完井工艺、水泥环厚度"))
                    {
                        mText.Contents = contents.Replace("固井工艺、完井工艺、水泥环厚度", "固井工艺、完井工艺、水泥环厚度\\P\\P" +
                            "一全固二局固三" + AutoWjfs3 + "\\P" +
                            "水泥环厚度:" + snhHoudu + "m");
                    }
                    //高危位置
                    else if (contents.Contains("高危位置"))
                    {
                        mText.Contents = contents.Replace("高危位置", "高危位置数量:" + dangerCnt + "\\P" + dangerStr);
                    }
                }
            }
            cadViewer.ReDraw();
        }
Beispiel #12
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());
        }
Beispiel #13
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());
        }
Beispiel #14
0
        private void FillBeamStruct()
        {
            #region beam
            HLTSmart smart = new HLTSmart();
            //第一步:遍历所有文字,找出满足如下正则表达式的文字,即为集中标注第一行
            List <Regex> regex1 = new List <Regex> {
                //new Regex(@"(KL|L|WKL|WL|KZL|LL|JL|DL)[-]?\d{1,4}")
                new Regex(@"((KL|L|WKL|WL|KZL|LL|JL|DL)(\d{1,4})\([A-Z0-9]{1,4}\)\s)?(\d{1,4})X(\d{1,4})")
            };
            List <Text> texts = new List <Text>();
            //获取dim_text值
            MxDrawText entity;
            foreach (var item in beam.dim_texts)
            {
                entity = Program.MainForm.axMxDrawX1.HandleToObject(item) as MxDrawText;
                if (entity != null)
                {
                    texts.Add(new Text
                    {
                        Position = new Point3d {
                            X = entity.Position.x, Y = entity.Position.y, Z = entity.Position.z
                        },
                        Layer      = entity.Layer,
                        TextString = entity.TextString,
                        Height     = entity.Height,
                        Rotation   = entity.Rotation
                    });
                }
            }
            List <Text> Restexts = smart.GetWord(texts, regex1);
            //第二步:找到后还需验证这个字的左侧定位点 字体高度2倍范围内有无直线(即指示线)
            Point3d            pt     = new Point3d();
            MxDrawSelectionSet select = new MxDrawSelectionSet();
            foreach (var item in Restexts)
            {
                pt = item.Position;
                MxDrawPoint pt1 = new MxDrawPoint
                {
                    x = pt.X - 1 * item.Height,
                    y = pt.Y - 1 * item.Height,
                    z = pt.Z
                };
                MxDrawPoint pt2 = new MxDrawPoint
                {
                    x = pt.X + 1 * item.Height,
                    y = pt.Y + 1 * item.Height,
                    z = pt.Z
                };
                //Program.MainForm.axMxDrawX1.DrawLine(pt.X, pt.Y, pt.X+1, pt.Y+1);
                //Program.MainForm.axMxDrawX1.DrawLine(pt1.x, pt1.y, pt1.x, pt2.y);
                //Program.MainForm.axMxDrawX1.DrawLine(pt1.x, pt2.y, pt2.x, pt2.y);
                //Program.MainForm.axMxDrawX1.DrawLine(pt2.x, pt2.y, pt2.x, pt1.y);
                //Program.MainForm.axMxDrawX1.DrawLine(pt2.x, pt1.y, pt1.x, pt1.y);
                select.Select(MCAD_McSelect.mcSelectionSetCrossing, pt1, pt2, new MxDrawResbuf());
                MxDrawLine  drawEntity; MxDrawPoint pst, ped;
                List <Text> text3 = new List <Text>();
                for (int i = 0; i < select.Count; i++)
                {
                    drawEntity = select.Item(i) as MxDrawLine;
                    //第三步:遍历第二步的结果,逐一按下面计算,例如第n个结果
                    if (drawEntity != null && drawEntity.ObjectName == "McDbLine")
                    {
                        Program.MainForm.axMxDrawX1.TwinkeEnt(drawEntity.ObjectID);
                        pst   = drawEntity.GetStartPoint();
                        ped   = drawEntity.GetEndPoint();
                        text3 = smart.SelectTextByBox(texts, new Point3d
                        {
                            X = pst.x,
                            Y = pst.y,
                            Z = pst.z
                        }, item.Position);
                        //第四步:从第三步结果中逐行用关键字匹配出参数信息
                        Beam beams = new Beam();
                        beams.owner           = new List <string>();
                        beams.Sections        = new List <Beam_Section>();
                        beams.Stirrup_info    = new List <Stirrup_Dim>();
                        beams.Public_Bar      = new List <Rebar_Dim>();
                        beams.Mid_Beam_Rebars = new List <List <Rebar_Dim> >();
                        beams.Waist_Bar       = new List <Rebar_Dim>();
                        beams.Twist_Bar       = new List <Rebar_Dim>();
                        string kval = "";

                        for (int k = 0; k < text3.Count; k++)
                        {
                            //KL14(1A) 300X400
                            kval = Regex.Match(text3[k].TextString, @"(KL|L|WKL|WL|KZL|LL|JL|DL)").Value;
                            if (kval != "")
                            {
                                beams.type  = kval;//(Side_type)Enum.Parse(typeof(Side_type),kval);
                                beams.owner = GetItemAsync(text3[k].TextString);
                            }
                            //梁截面
                            kval = Regex.Match(text3[k].TextString, @"(\d{2,4}~)?(\d{2,4})(x|X)(\d{2,4})(~\d{2,4})?").Value;
                            string[] vals = kval.Split(new char[] { '~', 'x', 'X' });
                            if (kval != "")
                            {
                                if (kval.IndexOf('~') == -1)
                                {
                                    beams.Sections.Add(new Beam_Section
                                    {
                                        a = 1,
                                        b = Convert.ToDouble(vals[0]),
                                        h = Convert.ToDouble(vals[1])
                                    });
                                }
                                else
                                {
                                    if (kval.IndexOf("x", StringComparison.OrdinalIgnoreCase) > kval.IndexOf('~'))
                                    {
                                        //变截面宽  350~450x700
                                        beams.Sections.Add(new Beam_Section
                                        {
                                            a = 1,
                                            b = Convert.ToDouble(vals[0]),
                                            h = Convert.ToDouble(vals[2]),
                                        });
                                        beams.Sections.Add(new Beam_Section
                                        {
                                            a = 1,
                                            b = Convert.ToDouble(vals[1]),
                                            h = Convert.ToDouble(vals[2]),
                                        });
                                    }
                                    else
                                    {
                                        //变截面高   350x650~800
                                        beams.Sections.Add(new Beam_Section
                                        {
                                            a = 1,
                                            b = Convert.ToDouble(vals[0]),
                                            h = Convert.ToDouble(vals[1]),
                                        });
                                        beams.Sections.Add(new Beam_Section
                                        {
                                            a = 1,
                                            b = Convert.ToDouble(vals[0]),
                                            h = Convert.ToDouble(vals[2]),
                                        });
                                    }
                                }
                                continue;
                            }
                            //箍筋   Φ12@100/200(4)
                            kval = Regex.Match(text3[k].TextString, @"((%%130)|(%%131)|(%%132))(\d{1,3})@(\d{2,3})(/\d{2,3})?\(\d{1,2}\)").Value;
                            if (kval != "")
                            {
                                beams.Stirrup_info.Add(new Stirrup_Dim
                                {
                                    D  = Convert.ToDouble(kval.Substring(5, kval.IndexOf('@') - 5)),
                                    Se = Convert.ToDouble(SplitStr(kval, kval.IndexOf('@'), "/(")),
                                    Sa = Convert.ToDouble(SplitStr(kval, kval.IndexOf('/'), "((")),
                                    n  = Convert.ToInt32(SplitStr(kval, kval.IndexOf('('), "))"))
                                });
                                continue;
                            }
                            //通长钢筋   4Φ20;7Φ20 3/4
                            kval = Regex.Match(text3[k].TextString, @"^[A-Z]{0}(\(?\d{1,3}%%132\d{1,3}\)?)(\+\(?\d{1,3}%%132\d{1,3}\))?;?(\(?\d{1,3}%%132\d{1,3}\)?)?\s?(/?(\d{1,3})?)*").Value;
                            if (kval != "")
                            {
                                string[] sp1 = kval.Split(';');
                                for (int v = 0; v < sp1.Count(); v++)
                                {
                                    string[] sp2 = sp1[v].Split('+');
                                    for (int f = 0; f < sp2.Count(); f++)
                                    {
                                        sp2[f] = sp2[f].Replace("(", "");
                                        sp2[f] = sp2[f].Replace(")", "");
                                        sp2[f] = sp2[f].Replace("%%132", "|");
                                        string[]         sp3  = sp2[f].Split('|');
                                        List <Rebar_Dim> Bdim = new List <Rebar_Dim>();
                                        if (sp2[f].IndexOf('/') == -1)
                                        {
                                            int c = 0;
                                            if (sp2.Count() > 1)
                                            {
                                                c = f + 1;
                                            }
                                            if (v == 1)
                                            {
                                                Bdim.Add(new Rebar_Dim
                                                {
                                                    C = c,
                                                    n = Convert.ToInt32(sp3[0]),
                                                    D = Convert.ToInt32(sp3[1])
                                                });
                                            }
                                            else
                                            {
                                                beams.Public_Bar.Add(new Rebar_Dim
                                                {
                                                    C = c,
                                                    n = Convert.ToInt32(sp3[0]),
                                                    D = Convert.ToInt32(sp3[1])
                                                });
                                            }
                                        }
                                        else
                                        {
                                            sp3[1] = sp3[1].Split(' ')[0];
                                            string   xi  = sp2[f].Substring(sp2[f].IndexOf(' '));
                                            string[] sp4 = xi.Trim().Split('/');
                                            for (int s = 0; s < sp4.Count(); s++)
                                            {
                                                if (v == 1)
                                                {
                                                    Bdim.Add(new Rebar_Dim
                                                    {
                                                        n = Convert.ToInt32(sp4[s]),
                                                        D = Convert.ToInt32(sp3[1])
                                                    });
                                                }
                                                else
                                                {
                                                    beams.Public_Bar.Add(new Rebar_Dim
                                                    {
                                                        n = Convert.ToInt32(sp4[s]),
                                                        D = Convert.ToInt32(sp3[1])
                                                    });
                                                }
                                            }
                                        }
                                        beams.Mid_Beam_Rebars.Add(Bdim);
                                    }
                                }
                                continue;
                            }
                            //腰筋   G4Φ12+N4Φ12
                            kval = Regex.Match(text3[k].TextString, @"(\+?(G|N)\d{1,3}%%132\d{1,3})*").Value;
                            if (kval != null)
                            {
                                string[] sp1 = kval.Split('+');
                                for (int c = 0; c < sp1.Length; c++)
                                {
                                    sp1[c] = sp1[c].Replace("%%132", "|");
                                    string[] sp2 = sp1[c].Split('|');
                                    if (sp2.Length == 2)
                                    {
                                        char G = sp2[0][0];
                                        int  N = Convert.ToInt32(sp2[0].Substring(1));
                                        int  C = 0; if (sp1.Length == 2)
                                        {
                                            C = c + 1;
                                        }
                                        if (G == 'G')
                                        {
                                            beams.Waist_Bar.Add(new Rebar_Dim
                                            {
                                                n = N,
                                                C = C,
                                                D = Convert.ToDouble(sp2[1])
                                            });
                                        }
                                        if (G == 'N')
                                        {
                                            beams.Twist_Bar.Add(new Rebar_Dim
                                            {
                                                n = N,
                                                C = C,
                                                D = Convert.ToDouble(sp2[1])
                                            });
                                        }
                                    }
                                }
                                continue;
                            }
                            //标高  (-0.150)
                            kval = Regex.Match(text3[k].TextString, @"(\(?-?\d{1,3}.\d{3}\)?)").Value;
                            if (kval != null)
                            {
                                kval           = kval.Replace("(", "");
                                kval           = kval.Replace(")", "");
                                beams.Sections = beams.Sections.Select(x => { x.H = Convert.ToDouble(kval); return(x); }).ToList();
                            }
                        }
                        beam.beams.Add(beams);
                        beams.side_lines = new List <string>();
                        //识别梁
                        //1.集中标注指示线两个端点分别找到垂直距离最近的梁线,两者最近的就是第一根梁线L1

                        MxDrawLine LT1;
                        MxDrawLine L1 = GetLineForRange(drawEntity);
                        beams.side_lines.Add(L1.handle);
                        //L1 = Program.MainForm.axMxDrawX1.HandleToObject("61FBA") as MxDrawLine;
                        LT1 = L1;
                        for (int c1 = 0; c1 < 2; c1++)
                        {
                            //2.L1有两个点P1,P2,先从P1开始如下步骤,完了之后再P2
                            //3.找距离P1点2000内的支座线,并且L1与支座线交点距离P1小于300,若有结果则按3.2若无结果按3.1
                            L1 = LT1;
                            Program.MainForm.axMxDrawX1.TwinkeEnt(L1.ObjectID);
                            int cs = 0;
                            do
                            {
                                if (c1 == 1)
                                {
                                    MxDrawPoint temp = L1.StartPoint;
                                    L1.StartPoint = L1.EndPoint;
                                    L1.EndPoint   = temp;
                                }
                                MxDrawPolyline seat  = GetSeatForRange(L1.EndPoint, L1.StartPoint);
                                MxDrawLine     L2    = new MxDrawLine();
                                MxDrawLine     L2s   = new MxDrawLine();
                                MxDrawLine     Rline = new MxDrawLine();
                                if (seat.handle != "0")
                                {
                                    //有结果3.2
                                    L2    = GetparallelLine(L1);
                                    Rline = GetXpoint(L1.EndPoint, L1.StartPoint, seat);
                                    L1    = Rline;
                                    beams.side_lines.Add(L2.handle);
                                    beams.side_lines.Add(Rline.handle);
                                }
                                else
                                {
                                    //无结果3.1
                                    L2s = GetMoreLine(L1);
                                    L2  = GetparallelLine(L1);
                                    L1  = L2s;
                                    beams.side_lines.Add(L2s.handle);
                                }
                                //3.1 找到另一根梁线L2,L2的两个端点之一与P1最近且距离小于600且两线角度差别不超过2度,找到后凭L2另一个端点重复3

                                /*3.2 说明一段梁结束,去寻找这段梁已识别梁线的平行线,即水平距离小于梁宽的1.5倍且两线相关,
                                 * 再寻找与这些梁线共点且角度差别小于40度的梁线,找完写入beam;
                                 * 然后用3的支座线与L1求到最远相关交点P3,求与P3最近的梁线,且角度差别小于40度,用这根新梁线远端点作为P1重复3
                                 */
                                cs++;
                                //Program.MainForm.axMxDrawX1.StopAllTwinkeEnt();
                                Program.MainForm.axMxDrawX1.TwinkeEnt(L1.ObjectID);
                                Program.MainForm.axMxDrawX1.TwinkeEnt(L2s.ObjectID);
                                Program.MainForm.axMxDrawX1.TwinkeEnt(seat.ObjectID);
                                Program.MainForm.axMxDrawX1.TwinkeEnt(L2.ObjectID);
                                Program.MainForm.axMxDrawX1.TwinkeEnt(Rline.ObjectID);
                                if (cs > 10)
                                {
                                    break;
                                }
                            } while (L1.handle != "0");
                        }
                        //break;
                    }
                }
            }
            #endregion over
        }