[E3 library] How to highlight a device by coding
Hello,
I'm using the e3 library with Visual Studio to connect an existing project in E3 ViewerPlus.
For the moment, i success to get signals information and now i needs devices information to highligth a specific device
I have got the list of devices ids with the following code but I cannot found how to draw a rectangle on the device or highlight the device, could you please help me ?
int nSignal = m_e3Job.GetSignalIds(ref lstSignal);
for (int k = 1; k < nSignal; k++)
{
string strSignalId = ((object[])lstSignal)[k].ToString();
e3Signal = m_e3Job.CreateSignalObject();
e3Signal.SetId(Convert.ToInt32(strSignalId));
int nNbSeg = e3Signal.GetNetSegmentIds(ref lstSegments);
for (int n = 1; n <= nNbSeg; n++)
{
string strSegId = ((object[])lstSegments)[n].ToString();
e3Segment = m_e3Job.CreateNetSegmentObject();
e3Segment.SetId(Convert.ToInt32(strSegId));
int nNbSymbol = e3Segment.GetConnectedSymbolIds(ref lstConSymbol);
for (int q = 1; q <= nNbSymbol; q++)
{
e3PinO = m_e3Job.CreatePinObject();
string strSegId2 = ((object[])lstConSymbol)[q].ToString();
e3PinO.SetId(Convert.ToInt32(strSegId2));
int nNbDevice = e3PinO.GetDevicePinIds(ref lstDevices);
for (int dev = 1; dev <= nNbDevice; dev++)
{
string strDeviceId = ((object[])lstDevices)[dev].ToString();
e3Device = m_e3Job.CreateDeviceObject();
e3Device.SetId(Convert.ToInt32(strDeviceId));
}}}}
Thanks
-
Jump is a command which automatically opens the sheet which the particular device is located and highlights it. Dev refers to the device object. The .Jump method, according the help, is the way to do that via scripting.
I am not sure if I grasp the scope of what your trying to do but the highlight is not permanent; it is removed when you jump tp a new device. (i.e. you can't highlight multiple devices at once)
-
Thank you, I have try this solution with the following code (nId containing the device id)
IDeviceInterface e3SelDevice = m_e3Job.CreateDeviceObject();
e3SelDevice.SetId(nId);
int nRet = e3SelDevice.Jump();But I can't see something on the scheme and the Jump function return 1.
Do you think this value is ok or not ok ?
-
Sorry, I read the help file on this again; it looks like the jump command, when used in a script, only works with E3.panel stuff.
If you can get the coordinates of the devices symbol being used, probably though the SymbolInterface, you draw a rectangle or something around it. Use Dev.GetSymbolIds. That is may only other suggestion.
-
To highlight device symbol on the sheet you would do it like this:
dynamic symbol = job.CreateSymbolObject(); // ISymbolInterface instead of dynamic if you want autocomplete
symbol.SetId(nId) // nId contains the device Id
var symId = symbol.GetID(); // need to get symbol Id
job.JumpToId(symId);
-
Hello,
Thank you @Tyler Smith, with your solution I success to highlight a device.
But, now my application users want to configure the color for the device highlighted.
So, I search how to draw a rectangle over the existing device.
Do you have an idea ?
I success to get X and Y coordinates of my device with the following source code:
dynamic symbol = m_e3Job.CreateSymbolObject(); // ISymbolInterface instead of dynamic if you want autocomplete
symbol.SetId(Convert.ToInt32(strDeviceId)); //the device Id
var symId = symbol.GetID(); // need to get symbol Id
symbol.GetSchemaLocation(ref refX, ref refY, ref refGrid);
Please sign in to leave a comment.
Comments
10 comments