public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiApp = commandData.Application; var app = commandData.Application.Application; var uiDoc = commandData.Application.ActiveUIDocument; var doc = commandData.Application.ActiveUIDocument.Document; var view = doc.ActiveView; if (view.ViewType != ViewType.FloorPlan && view.ViewType != ViewType.Elevation) { PmSoft.Common.Controls.PMMessageBox.Show("需选择二维视图或者图纸"); return(Result.Cancelled); } //TODO0817 增加功能面板启动时获取字体高度 VLTransactionHelper.DelegateTransaction(doc, "获取字体高度", () => { PAContext.LoadFamilySymbols(doc); return(true); }); PAContext.LoadTextHeight(doc); PipeAnnotationForm form = new PipeAnnotationForm(new PipeAnnotationCmd(uiApp)); System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.Retry; while ((result = form.ShowDialog()) == System.Windows.Forms.DialogResult.Retry) { switch (form.ActionType) { case ActionType.SelectSinglePipe: var selectedId = uiDoc.Selection.PickObject(ObjectType.Element, new PipeFramingFilter()).ElementId; form.SelectedElementIds.Clear(); form.SelectedElementIds.Add(selectedId); form.FinishSelection(); break; case ActionType.SelectMultiplePipe: var selectedIds = uiDoc.Selection.PickObjects(ObjectType.Element, new PipeFramingFilter()).Select(c => c.ElementId); form.SelectedElementIds.Clear(); form.SelectedElementIds.AddRange(selectedIds); form.FinishSelection(); break; default: break; } } return(Result.Succeeded); }
public override void LoadConfig(Document doc) { IsSuccess = DelegateHelper.DelegateTransaction(doc, "标注族加载", () => { return(PAContext.LoadFamilySymbols(doc)); });// && PipeAnnotationContext.LoadParameterOfSymbols(doc); if (!IsSuccess) { TaskDialog.Show("错误", "加载必要的族时失败"); return; } //PipeAnnotationContext.LoadParameterOfSymbols(doc); DelegateHelper.DelegateTransaction(doc, "加载配置记忆", () => { SettingForSingle = new SinglePipeAnnotationSettings(this); SettingForMultiple = new MultiPipeAnnotationSettings(this); SettingForCommon = new CommonAnnotationSettings(); var data = PAContext.GetSetting(doc); var values = data.Split(Splitter.ToCharArray().First()); if (values.Count() >= 7) { SettingForSingle.LengthFromLine_Milimeter = Convert.ToInt32(values[0]); SettingForSingle.Location = (SinglePipeTagLocation)Enum.Parse(typeof(SinglePipeTagLocation), values[1]); SettingForSingle.NeedLeader = Convert.ToBoolean(values[2]); SettingForMultiple.LengthBetweenPipe_Milimeter = Convert.ToInt32(values[3]); SettingForMultiple.Location = (MultiPipeTagLocation)Enum.Parse(typeof(MultiPipeTagLocation), values[4]); SettingForCommon.IncludeLinkPipe = Convert.ToBoolean(values[5]); SettingForCommon.AutoPreventCollision = Convert.ToBoolean(values[6]); //0728长度过滤 if (values.Count() > 7) { SettingForCommon.MinLength_Milimeter = Convert.ToInt32(values[7]); SettingForCommon.FilterVertical = Convert.ToBoolean(values[8]); } } return(true); }); IsSuccess = true; }