EBDN - Community - Question & Answers

  Thursday, 21 January 2021
  1 Replies
  731 Visits
0
Votes
Undo
Hello Team,

on deletion of some symbol in the layout sheet I'm trying to rearrange symbol I have achieved this but for rearrange its taking for one cabinet around 9 minutes
but I have N number of Cabinet to generate Drawings N* 9 minutes it will take time to complete …..please help me on how to decrease time for each cabinet to increase macro perfomance

below code I'm using
/ /This function called for different symbol to Rearrange
private void RearrangeMountigRailSymbol(ObjectItem cabinetAssembly, ObjectItem cabinetFunction, FilterExpression filter, double Widthtoadd)
{
List<ObjectItem> ObjItems = cabinetAssembly.FindObjects(filter, SearchBehavior.Deep).ToList();
if (ObjItems.Count() > 0)
{
foreach (var Objitem in ObjItems)
{
Sheet layoutSheet = null;
try
{
layoutSheet = cabinetFunction.SourceAssociations.Where<AssociationItem>((Func<AssociationItem, bool>;)(x => x.Role == AssociationRole.FunctionToSheet &&
x.RelatedObject != null && x.RelatedObject.Attributes.GetAttributeValue(AttributeId.Designation) == "6";)).FirstOrDefault<AssociationItem>().RelatedObject as Sheet;
}
catch
{
layoutSheet = cabinetFunction.SourceAssociations.Where<AssociationItem>((Func<AssociationItem, bool>;)(x => x.Role == AssociationRole.LocationToSheet &&
x.RelatedObject != null && x.RelatedObject.Attributes.GetAttributeValue(AttributeId.Designation) == "6";)).FirstOrDefault<AssociationItem>().RelatedObject as Sheet;
}
layoutSheet.TransformSymbol(objitem, WidthToAdd);
layoutSheet.Close();
ObjItems = null;
}
}
}

//Sheet Operation to Move symbol with respect to relative position
public static void TransformSymbol(this Sheet sheet, ObjectItem objectitem, double widthToAddRelY)
{

bool CloseSheet = !sheet.IsOpened;
if (CloseSheet)
{
sheet.Open(SheetOpenBehavior.AutoSave);
}

if (sheet.IsReadOnly)
throw new ArgumentException("Sheet " + sheet.FullName + " is Read-only";);

var symbol = objectitem.SourceAssociations.Where(s => s.Role == AssociationRole.NonElectricalSymbol && s.RelatedObject.Parent.Id == sheet.Id);
ObjectItem symb = null;
foreach (var s in symbol)
{
symb = s.RelatedObject;
break;
}
if (symb != null)
{
//move
if (widthToAddRelY != 0)
{
IList<ExecuteSheetOperationRecordData> op = new List<ExecuteSheetOperationRecordData>();
op.Add(new ExecuteSheetOperationRecordData() { Qualifier = (int)ExecuteSheetOperationModes.OpExecSheetTransfMoveRel, Value = 0 });
op.Add(new ExecuteSheetOperationRecordData() { Qualifier = (int)ExecuteSheetOperationModes.ArgExecSheetRef2Symbol, Value = symb.Id });
op.Add(new ExecuteSheetOperationRecordData() { Qualifier = (int)ExecuteSheetOperationModes.ArgExecSheetRelX, Value = 0 });
op.Add(new ExecuteSheetOperationRecordData() { Qualifier = (int)ExecuteSheetOperationModes.ArgExecSheetRelY, Value = widthToAddRelY });
sheet.ExecuteSheetOperation(ref op);
}
}

if (CloseSheet)
sheet.Close();
}