EBDN - Community - Question & Answers

  Wednesday, 23 December 2020
  1 Replies
  705 Visits
0
Votes
Undo
Hello Team,

Please find the Below code where I'm trying to move device with new position in the existing sheet but its not moving device in the correct position

public static void TransformSymbol(this Sheet sheet, ObjectItem objectitem, SheetPosition position)
{

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 (position.X != 0 || position.Y != 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 = position.X });
op.Add(new ExecuteSheetOperationRecordData() { Qualifier = (int)ExecuteSheetOperationModes.ArgExecSheetRelY, Value = position.Y });

sheet.ExecuteSheetOperation(ref op);
}
}

if (CloseSheet)
sheet.Close();
}

Thanks,
Ramesh