Author Topic: How do I find the package a graph belongs to?  (Read 4240 times)

Assuming I've found my current graph using getGraphFromGraphViewID  how can I find it's package in order to do stuff like create resources.

Is there a good way to do this?


I haven't been able to find a way to get the package object directly from the graph object.

You can, however, iterate through all the packages and see if the URL of your graph matches the URL of child resources in each package:
Code: [Select]
def find_package_of_graph(self, graph):
    for pkg in self.context.getSDApplication().getPackageMgr().getUserPackages():
        if pkg.findResourceFromUrl(graph.getUrl()):
            return pkg

Now I've finally got back to work on this I just wanted to say thanks -  works great :)