diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs index dbd80fe..0829f69 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorModel.cs @@ -81,5 +81,19 @@ OnPropertyChanged(nameof(AxisNo)); } } + + private string _occPartId; + /// + /// 部件ID + /// + public string OccPartId + { + get => _occPartId; + set + { + _occPartId = value; + OnPropertyChanged(nameof(OccPartId)); + } + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/BaseAppExt.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/BaseAppExt.cs new file mode 100644 index 0000000..c5d13ab --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/BaseAppExt.cs @@ -0,0 +1,12 @@ +using EPLAN.Harness.AppCore; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils +{ + public static class BaseAppExt + { + public static BaseApp GetApplication() + { + return BaseApp.ActiveApplication; + } + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs index 83a48b4..a23fc85 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs @@ -150,9 +150,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel { return Task.CompletedTask; } - var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId); + var designer = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId); // 获取所有存在的 - var wires = doc.GetOrganizerOccurrences(doc.ID); + var wires = designer.GetOrganizerOccurrences(designer.ID); //OriWires = wires.ToList(); // 所有的线材 // OccCableForked 多芯线? 对应设计器中Cables(电缆)下的内容 @@ -200,8 +200,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel .OrderBy(it => it?.CableName ?? "")]; Wires = StuffData(cables); + designer.SelectSet.NodeSelected += SelectSet_NodeSelected; return Task.CompletedTask; } + + private void SelectSet_NodeSelected(object sender, EPLAN.Harness.Common.Events.EventArgs e) + { + if (e != null) + { + + } + } + public string GetLectotypeName(string libraryName) { if (libraryName.Contains("&")) @@ -462,12 +472,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel FlexMessageBox.Error(ex.Message); } } - public void ToMotorSource(string motorName, string cableName) + public void ToMotorSource(string motorId, string cableName) { try { var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId); - var part = doc.GetOccurrenceByName(motorName, typeof(OccSubPart)); + var part = doc.GetOccurrenceByID(motorId); var cable = doc.GetOccurrenceByName(cableName, typeof(OccCableForked)); if (part != null) { @@ -475,7 +485,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel var oriOcc = SelfControler.FindInstance(part.ID); oriOcc.SetVisibility(true, null); doc.SelectSet.Add(oriOcc.Children.First()); - if (cable != null) + if (!string.IsNullOrEmpty(cableName) && cable != null) { var cableOcc = SelfControler.FindInstance(cable.ID); cableOcc.SetVisibility(true, null); @@ -510,6 +520,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel { MotorModelStr = part.Name, AxisNo = axisNo, + OccPartId = part.ID, IsError = string.IsNullOrEmpty(axisNo) }; if (motorPowerData != null)