I’d like to use some of the helper functions scattered throughout com.inductiveautomation.ignition from within Python. In this specific case com.inductiveautomation.ignition.common has QualifiedPathUtils and I’d love to access the toTagPathNew method.
Is there a way of accessing the com.inductiveautomation.ignition packages? I’ve gone through the documentation and it mentions access Java libraries, but it’s not clear if or how I could access com.inductiveautomation.ignition packages?
I did seem to be able to import the package, but perhaps my syntax is wrong:
If you import without the optional from clause, you have to refer to the imported objects by their full name. Such an import just makes the namespace available.
Use this syntax instead:
from com.inductiveautomation.ignition.common import QualifiedPathUtils
Note that jython cannot do wildcard imports of java classes. Each class you want to use must be named in an import statement.
The import behavior you were expecting corresponds to java’s import something.something.*;. But in java, an import is really just syntactical sugar for programmer convenience. A java programmer can always spell out full class names without any import statement.
Python/jython doesn’t work this way. In python/jython, import is a fundamental operation that makes other packages available within the scope, optionally removing a package prefix or renaming the object into the new scope.