/// <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); }
/// <summary> /// 步骤模仿 /// </summary> /// <param name="bref"></param> /// <param name="result">是否有旋转操作</param> /// <returns></returns> public static bool Jig(Entity bref, bool result) { try { var jigger = new BlockJig(bref, result); PromptResult pr = null; pr = PublicMethod.Instance.Editor.Drag(jigger); if (pr.Status != PromptStatus.OK) { return(false); } jigger.mCurJigFactorNumber++; PublicMethod.Instance.Editor.Drag(jigger); return(true); } catch { return(false); } }