I need to place devices symbols (object symbols) on various mounting plates (dinrails), but before doing so,
I need to know the angle of the mounting plate(Orientation).
The code below demonstrates how to obtain the x, y position of the required object symbols. Could you kindly suggest a solution to read angle aswell?
public static Dictionary<ObjectItem, SheetAttributes> GetDevicePositions(FilterExpression ftexp, ObjectCollection LstOfObjects, Sheet layoutSheet)
{
Dictionary<ObjectItem, SheetAttributes> Dict_ObjSizeInfos = new Dictionary<ObjectItem, SheetAttributes>();
try
{
foreach (ObjectItem reqobject in LstOfObjects)
{
if (reqobject != null)
{
Worksheet ws = null;
ws = layoutSheet.
OpenWorksheet(ftexp, WorksheetOpenBehavior.Deep, new[] { AttributeId.Designation,
AttributeId.TypeDesignation,AttributeId.Comment,AttributeId.AdditionalComment,AttributeId.Material });
foreach (WorksheetRow wsr in ws.Rows.Where(r => r.ObjectItem.Id == reqobject.Id && r.
ObjectItem.Parent.Id == reqobject.Parent.Id))
{
var AssociatedObjectSymbols = wsr.
ObjectItem.SourceAssociations.
Where(x => x.
Role == AssociationRole.NonElectricalSymbol &&
x.
RelatedObject.Parent.Id == layoutSheet.Id);
if (AssociatedObjectSymbols != null)
{
foreach (var AssocObjSymbol in AssociatedObjectSymbols)
{
if (AssocObjSymbol != null && AssocObjSymbol.
RelatedObject != null)
{
double Xaxis = Convert.ToDouble(AssocObjSymbol.
RelatedObject.Attributes.FindById(AttributeId.PositionX).ValueText());
double Yaxis = Convert.ToDouble(AssocObjSymbol.
RelatedObject.Attributes.FindById(AttributeId.PositionY).ValueText());
SheetAttributes pos = new SheetAttributes(Xaxis, Yaxis, CabinetUtilityCls.GetObject_Width(reqobject));
Dict_ObjSizeInfos.Add(reqobject, pos);
AssociatedObjectSymbols = null;
}
}
}
}
if (ws != null)
ws.Dispose();
}
}
}
catch
{
}
finally
{
}
return Dict_ObjSizeInfos;
}