Example #1
0
        /// <summary>
        /// 绘制线设备
        /// </summary>
        /// <param name="layerId"></param>
        /// <param name="_esymb"></param>
        /// <param name="color"> </param>
        /// <param name="strLineType"></param>
        /// <param name="lineWidth"></param>
        /// <param name="xmlDbManager"> </param>
        public static void AddLineSymbol(ObjectId layerId, ElectronSymbol _esymb, Color color, string strLineType, double lineWidth, XmlDBManager xmlDbManager)
        {
            var index = 0;

            try
            {
                AddBasePoint(_esymb);
                var symbolEventArgs = GetSymbolExecution(_esymb, lineWidth, color, xmlDbManager);
                var line            = DCadApi.SetPolyline(layerId, symbolEventArgs.color, strLineType);
                foreach (var point in (_esymb.G3E_GEOMETRY as LineString).Points)
                {
                    line.AddVertexAt(index, new Point2d(point.X, point.Y), 0.0,
                                     symbolEventArgs.lineWidth / MapConfig.Instance.earthscale,
                                     symbolEventArgs.lineWidth / MapConfig.Instance.earthscale);
                    index++;
                }

                DCadApi.AddLabelPinchPoint(line);
                var objectId = PublicMethod.Instance.ToModelSpace(line);
                PublicMethod.Instance.dicObjIds.Add(objectId, _esymb);
                //是否是其他馈线
                if (!_esymb.KxType)
                {
                    PublicMethod.Instance.AddDBSymbolFinder(objectId, _esymb);
                    var extents = line.GeometricExtents;
                    DCadApi.AddDBSymbolLTTIDFinder(_esymb, extents, symbolEventArgs.SBMC, objectId);
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
        }
Example #2
0
 private static ObjectId AddToModelSpace(BlockReference reference)
 {
     //添加夹点
     DCadApi.AddPinchPoint(reference);
     //添加符号-标注标记
     DCadApi.AddLabelPinchPoint(reference);
     //添加到模型空间
     return(PublicMethod.Instance.ToModelSpace(reference));
 }
Example #3
0
        /// <summary>
        /// 添加标注
        /// </summary>
        /// <param name="g3eObject"></param>
        /// <param name="labelFlagFno"></param>
        /// <param name="labelClassName"></param>
        /// <param name="G3E_CNO"></param>
        /// <param name="lea"></param>
        /// <returns></returns>
        public static bool AddLabel(G3EObject g3eObject, int labelFlagFno, string labelClassName, int G3E_CNO, LabelEventArgs lea)
        {
            var result = false;

            try
            {
                var values  = SimpleDBSymbolsConfig.Instance.DBSymbol.SingleOrDefault(o => o.G3E_FNO == g3eObject.G3E_FNO);
                var layerID = DCadApi.addLayer(string.Format("{0}标注", values.OtherProperty.LayerName));

                var lbHeight = lea.lbHeight / MapConfig.Instance.earthscale;

                var mText = AddText(lea.lbText, Point3d.Origin, 0, lbHeight, layerID, lea.color);
                if (BlockJig.Jig(mText, true))
                {
                    DCadApi.AddPinchPoint(mText);
                    DCadApi.AddLabelPinchPoint(mText);
                    var objId = PublicMethod.Instance.ToModelSpace(mText);
                    var mpt   = ConvertGeometry.Instance.GetMultipoint(objId);
                    //查询原设备删除的标注
                    var labelPt = DBEntityFinder.Instance.GetDBEntityByG3efidOrClassName(g3eObject.G3E_FID, labelClassName, EntityState.Delete);
                    //原设备删除
                    if (labelPt != null)
                    {
                        var labelObject = DBEntityFinder.Instance.GetEraseStateLabel(g3eObject.G3E_FID, labelFlagFno);
                        if (!labelObject.Key.IsNull)
                        {
                            //删除缓存
                            DBSymbolFinder.Instance.Remove(labelObject.Key);
                        }
                        var pt = labelPt.Clone() as ElectronSymbol;
                        pt.G3E_GEOMETRY = mpt;
                        pt.IsErased     = false;
                        pt.EntityState  = EntityState.Update;
                        DBManager.Instance.Update(pt);
                        UpdateLabelLB(pt);

                        //新增
                        PublicMethod.Instance.AddDBSymbolFinder(objId, pt);
                    }
                    else
                    {
                        ErasedCacheLabel(labelClassName, g3eObject.G3E_FID);
                        var pt = CreateLabel(g3eObject, mpt, labelClassName, G3E_CNO, labelFlagFno);
                        PublicMethod.Instance.AddDBSymbolFinder(objId, pt);
                    }
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            return(result);
        }
Example #4
0
        private static ObjectId AddEntity(Entity entity, ElectronSymbol _esymb)
        {
            DCadApi.AddPinchPoint(entity);
            DCadApi.AddLabelPinchPoint(entity);
            var objectId = PublicMethod.Instance.ToModelSpace(entity);

            PublicMethod.Instance.dicObjIds.Add(objectId, _esymb);
            using (PublicMethod.Instance.acDoc.LockDocument())
            {
                PublicMethod.Instance.AddDBSymbolFinder(objectId, _esymb);
            }
            return(objectId);
        }
Example #5
0
        private static void AddZxbzSymbol(XmlDBManager xmlDBManager, ElectronTransferModel.V9_4.Gg_gl_zxbz_n zxbzn)
        {
            var zxbzGeom = DBEntityFinder.Instance.GetZxbzGeomByG3e_fid(xmlDBManager, zxbzn.G3E_FID);

            if (zxbzGeom != null)
            {
                //获取坐标
                var point = new Point3d((zxbzGeom.G3E_GEOMETRY as Multipoint).Points[0].X,
                                        (zxbzGeom.G3E_GEOMETRY as Multipoint).Points[0].Y, 0);
                //获取角度
                var rotateAngle = Math.Atan2((zxbzGeom.G3E_GEOMETRY as Multipoint).Points[1].Y,
                                             (zxbzGeom.G3E_GEOMETRY as Multipoint).Points[1].X);

                //杂项标注图层
                var layerID = DCadApi.addLayer("杂项标注");
                //标注大小
                var lbHeight = 0.35 / MapConfig.Instance.earthscale;
                //标注颜色
                var color = CADColor.FromRgb(0, 0, 0);

                if (!string.IsNullOrEmpty(zxbzn.MIF_TEXT))
                {
                    Entity tEntity;
                    var    lb        = DBEntityFinder.Instance.GetLabel_LB(zxbzGeom);
                    var    alignment = DBEntityFinder.Instance.GetG3eAlignment(lb);
                    if (zxbzn.MIF_TEXT.Contains("\n"))
                    {
                        tEntity = SymbolLabel.Mtext(zxbzn.MIF_TEXT, point, rotateAngle, lbHeight, layerID);
                    }
                    else
                    {
                        tEntity = SymbolLabel.AddText(zxbzn.MIF_TEXT, point, rotateAngle, lbHeight, layerID, color,
                                                      alignment);
                    }
                    DCadApi.AddPinchPoint(tEntity);
                    DCadApi.AddLabelPinchPoint(tEntity);
                    //添加到当前模型中
                    var objectId = PublicMethod.Instance.ToModelSpace(tEntity);
                    zxbzGeom.IsErased   = false;
                    zxbzGeom.EntityType = EntityType.ZxLabel;
                    PublicMethod.Instance.AddDBSymbolFinder(objectId, zxbzGeom);
                }
            }
        }
Example #6
0
        private void AddZxbz()
        {
            var ssdw   = ComBox_SSDW.Text;
            var bzlx   = ComBox_BZLX.Text;
            var bzText = TXT_BZNR.Text.Trim();

            if (string.IsNullOrEmpty(bzlx))
            {
                MessageBox.Show("标注类型不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (!string.IsNullOrEmpty(bzText))
            {
                //if (!DBEntityFinder.Instance.HasZxbz(entityArgs.g3eObject.G3E_FID.ToString()))
                //{
                isInsert        = true;
                Btn_Add.Enabled = false;
                //杂项标注图层
                var layerID = DCadApi.addLayer("杂项标注");
                //标注大小
                var lbHeight = 0.35 / MapConfig.Instance.earthscale;
                //标注颜色
                var color = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 0, 0);
                ViewHelper.zxLabelManagerPs.KeepFocus = false;
                Entity mText;
                if (bzText.Contains("\n"))
                {
                    mText = SymbolLabel.Mtext(bzText, Point3d.Origin, 0, lbHeight, layerID);
                    //if (!PublicMethod.Instance.MultTextStyleId.IsNull)
                    //    ((MText)mText).TextStyleId = PublicMethod.Instance.MultTextStyleId;
                }
                else
                {
                    mText = SymbolLabel.AddText(bzText, Point3d.Origin, 0, lbHeight, layerID, color);
                }
                if (BlockJig.Jig(mText, true))
                {
                    isInsert = false;
                    DCadApi.AddPinchPoint(mText);
                    DCadApi.AddLabelPinchPoint(mText);
                    //添加到当前模型中
                    var objId = PublicMethod.Instance.ToModelSpace(mText);
                    //转换成空间坐标
                    var            mpt = ConvertGeometry.Instance.GetMultipoint(objId);
                    ElectronSymbol pt  = null;
                    //添加杂标数据
                    var result = InsertDBEntity.InsertZXBZ(entityArgs.g3eObject.G3E_FID, bzText, bzlx, ssdw, mpt, ref pt);
                    if (pt != null)
                    {
                        //保存记录
                        DBSymbolFinder.Instance.Add(objId, pt);
                    }
                    var message = result ? "新增成功!" : "新增失败!";
                    ViewHelper.zxLabelManagerPs.KeepFocus = true;
                    PublicMethod.Instance.ShowMessage(message);
                }
                Btn_Add.Enabled = true;
                //}
                //else
                //    MessageBox.Show("杂项标注已添加!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                TXT_BZNR.Focus();
                MessageBox.Show("标注内容不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }