NxShell Link color based on Objects
-
Hello,
I am adding links to my maps using nxshell.
With the following code the link is not reflecting the Object status.from java.util import ArrayList ltype = NetworkMapLink.NORMAL cd = NetworkMapLink(ltype,4885,4943) sList = ArrayList() sList.add(4917) sList.add(4943) cd.setStatusObjects(sList) cd.setRouting(NetworkMapLink.ROUTING_DIRECT) cd.setColorSource(LinkConfig.COLOR_SOURCE_OBJECT_STATUS) amap = s.findObjectById(5036) mapPage = amap.createMapPage() mapPage.addLink(cd) data = NXCObjectModificationData(5036) data.setMapContent(mapPage.getElements(), mapPage.getLinks()) s.modifyObject(data)There is a LinkConfig object but I don't see how it should be applied to the Links:
lc = cd.getConfig() lc.setColorSource(LinkConfig.COLOR_SOURCE_OBJECT_STATUS) lc.setObjectStatusList(sList) -
There's a couple of minor things that are causing issues here. NetworkMapLink expects IDs within map, not netxms object IDs, so there's a function to convert. And we need to explicitly specify that IDs of status-providing nodes are of type "Long". Here's an example of working script:
from java.util import ArrayList from java.lang import Long amap = s.findObjectById(2722) mapPage = amap.createMapPage() cd = NetworkMapLink(NetworkMapLink.NORMAL, mapPage.findObjectElement(672).id, mapPage.findObjectElement(674).id) sList = ArrayList() sList.add(Long(674)) sList.add(Long(672)) cd.setStatusObjects(sList) cd.setRouting(NetworkMapLink.ROUTING_DIRECT) cd.setColorSource(LinkConfig.COLOR_SOURCE_OBJECT_STATUS) mapPage.addLink(cd) data = NXCObjectModificationData(2722) data.setMapContent(mapPage.getElements(), mapPage.getLinks()) s.modifyObject(data)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login