private void selectElement_(Element element) { PenetrVueTask task; if (PenetrVueTask.getFromElement(element, AttrsXDoc, out task) && !taskElemsToRows_.ContainsKey(element) && null == rowsToTasks_.Values.FirstOrDefault(x => x.Oid == task.Oid)) // ? { TaskTable.BeginLoadData(); DataRow row = TaskTable.Rows.Add(); row.SetField(PropKey.CODE, task.Code); row.SetField(PropKey.NAME, task.Name); row.SetField(FieldName.FLANGES, task.FlangesType); row.SetField(FieldName.DIAMETER, task.DiameterTypeStr); row.SetField(FieldName.LENGTH, task.LengthCm); row.SetField <string>(FieldName.REF_POINT1, task.GetRefPointCoords(0)); row.SetField <string>(FieldName.REF_POINT2, task.GetRefPointCoords(1)); row.SetField <string>(FieldName.REF_POINT3, task.GetRefPointCoords(2)); foreach (var pair in task.DataGroupPropsValues) { Sp3dToDataGroupMapProperty dgProp = pair.Key; if (TaskTable.Columns.Contains(dgProp.TargetName)) { row.SetField(dgProp.TargetName, pair.Value); } } taskElemsToRows_.Add(element, row); rowsToTasks_.Add(row, task); TaskTable.AcceptChanges(); TaskTable.EndLoadData(); #if DEBUG //BCOM.Element comEl = ElementHelper.getElementCOM(element); //if (comEl.IsCompundCell()) //{ // var cell = comEl.AsCellElement(); // var cross = ElementHelper.createCrossRound(10, cell.Origin); // var pointEl = ElementHelper.createCircle(10, cell.Origin); // previewTranCon_.AppendCopyOfElement(pointEl); // previewTranCon_.AppendCopyOfElement(cross); //} #endif } }
public bool SetDataGroupInstance() { BCOM.Element bcomElement; FrameList.GetElement(out bcomElement); Element element = bcomElement.ToElement(); using (var catalogEditHandle = new CatalogEditHandle(element, true, true)) { if (catalogEditHandle == null || catalogEditHandle.CatalogInstanceName != null) { return(false); } catalogEditHandle.InsertDataGroupCatalogInstance("Opening", "Opening"); catalogEditHandle.UpdateInstanceDataDefaults(); foreach (var pair in Task.DataGroupPropsValues) { Sp3dToDataGroupMapProperty mapProp = pair.Key; string value = pair.Value; DataGroupProperty prop = catalogEditHandle.GetProperties() .FirstOrDefault(x => x.Xpath == mapProp.TargetXPath); if (prop == null) { prop = new DataGroupProperty( mapProp.TargetName, value, mapProp.ReadOnly, mapProp.Visible); prop.Xpath = mapProp.TargetXPath; catalogEditHandle.Properties.Add(prop); } catalogEditHandle.SetValue(prop, value); } int res = catalogEditHandle.Rewrite((int)BCOM.MsdDrawingMode.Normal); return(res == 0); // TODO решить проблему вылета при команде Modify DataGroup Instance } }
/// <summary> /// Заполнение у элемента проходки свойств DataGroup /// </summary> public static void setDataGroupInstance( BCOM.Element bcomElement, IPenetrTask task) { Element element = ElementHelper.getElement(bcomElement); if (element == null) { return; } task.prepairDataGroup(); var schemas = DataGroupDocument.Instance.CatalogSchemas.Schemas; // НВС для подгрузки схем using (var catalogEditHandle = new CatalogEditHandle(element, true, true)) { if (catalogEditHandle == null || catalogEditHandle.CatalogInstanceName != null) { return; } catalogEditHandle.InsertDataGroupCatalogInstance("EmbeddedPart", "Embedded Part"); catalogEditHandle.UpdateInstanceDataDefaults(); foreach (var pair in task.DataGroupPropsValues) { Sp3dToDataGroupMapProperty mapProp = pair.Key; string value = pair.Value; DataGroupProperty prop = catalogEditHandle.GetProperties() .FirstOrDefault(x => x.Xpath == mapProp.TargetXPath); if (prop == null) { prop = new DataGroupProperty( mapProp.TargetName, value, mapProp.ReadOnly, mapProp.Visible); prop.Xpath = mapProp.TargetXPath; } catalogEditHandle.SetValue(prop, value); catalogEditHandle.Properties.Add(prop); } catalogEditHandle.Rewrite((int)BCOM.MsdDrawingMode.Normal); //foreach (DataGroupProperty property in catalogEditHandle.GetProperties()) //{ // if (property?.Xpath == "EmbPart/@PartCode") // code = property; // else if (property?.Xpath == "EmbPart/@CatalogName") // name = property; //} //if (code != null) // catalogEditHandle.SetValue(code, task.Code); //else { // code = new DataGroupProperty("PartCode", task.Code, false, true); // //code.SchemaName = "EmbPart"; // code.Xpath = "EmbPart/@PartCode"; // catalogEditHandle.Properties.Add(code); //} //catalogEditHandle.SetValue(code, task.Code); //if (name != null) // catalogEditHandle.SetValue(name, task.Name); //else { // name = new DataGroupProperty("CatalogName", task.Name, false, true); // //name.SchemaName = "EmbPart"; // name.Xpath = "EmbPart/@CatalogName"; // catalogEditHandle.Properties.Add(name); //} //catalogEditHandle.SetValue(name, task.Name); //catalogEditHandle.Rewrite((int)BCOM.MsdDrawingMode.Normal); // TODO решить проблему вылета при команде Modify DataGroup Instance } }
private void Addin_SelectionChangedEvent( AddIn sender, AddIn.SelectionChangedEventArgs eventArgs) { try { if (eventArgs.Action == lastSelectionAction_ && eventArgs.FilePosition == lastFilePos_) { return; } switch (eventArgs.Action) { case AddIn.SelectionChangedEventArgs.ActionKind.SetEmpty: previewTranCon_.Reset(); TaskTable.Clear(); taskElemsToRows_.Clear(); rowsToTasks_.Clear(); break; case AddIn.SelectionChangedEventArgs.ActionKind.Remove: { Element element = ElementHelper.getElement(eventArgs); if (taskElemsToRows_.ContainsKey(element)) { DataRow row = taskElemsToRows_[element]; rowsToTasks_.Remove(row); TaskTable.Rows.Remove(row); taskElemsToRows_.Remove(element); } break; } case AddIn.SelectionChangedEventArgs.ActionKind.New: { Element element = ElementHelper.getElement(eventArgs); OpeningTask task; if (OpeningHelper.getFromElement(element, AttrsXDoc, out task) && !taskElemsToRows_.ContainsKey(element)) { DataRow row = TaskTable.Rows.Add(); row.SetField(FieldName.HEIGHT, task.Height); row.SetField(FieldName.WIDTH, task.Width); row.SetField(FieldName.DEPTH, task.Depth); foreach (var pair in task.DataGroupPropsValues) { Sp3dToDataGroupMapProperty dgProp = pair.Key; if (dgProp.Key == FieldName.CODE) { row.SetField(FieldName.CODE, pair.Value); } else if (TaskTable.Columns.Contains(dgProp.TargetName)) { row.SetField(dgProp.TargetName, pair.Value); } } taskElemsToRows_.Add(element, row); rowsToTasks_.Add(row, task); } break; } case AddIn.SelectionChangedEventArgs.ActionKind.SetChanged: { if (lastSelectionAction_ != AddIn.SelectionChangedEventArgs.ActionKind.New) { break; } //TaskSelection.RaiseListChangedEvents = false; //foreach (PenetrVueTask task in tasksBuf_.Values) //{ // //Logger.Log.Info($"Выбор объекта заадния {task.ToString()}"); // TaskSelection.Add(task); //} //tasksBuf_.Clear(); //TaskSelection.RaiseListChangedEvents = true; break; } } //TaskSelection.ResetBindings(); OnPropertyChanged(NP.TaskSelection); } catch (Exception ex) { // todo обработать ex.AddToMessageCenter(); } finally { lastSelectionAction_ = eventArgs.Action; lastFilePos_ = eventArgs.FilePosition; } }