Last modified 3 years ago
This section is a brief collection of common pitfalls on using avango. Feel free to add your comments here.
- Avango is not thread safe! Only create avango objects in a single thread, otherwise you will run into serious trouble. In case you have to create objects in multiple threads, create dummy/container objects (e.g. OSG objects) and convert them in the main thread into avango objects.
- avango.script.Script (Python):
- You cannot accept any parameters (except self) in the constructor
- Keep in mind that subclasses of Script should export its complete state in form of fields.
- Field connections from Python classes which are no FieldContainers:
- You cannot connect a FieldContainer inside a Python class which is not a container itself (e.g. a script node)
- For example:
class Foo(object): FooItem = avango.SFBool() def foobar(self): self.FooItem.connect_from(some_target_fieldcontainer_here) # DOES NOT WORK
- instead, use a small workaround:
class FooHelper(avango.script.Script): FooItem = avango.SFBool() class Foo(object): def foobar(self): self.helper = FooHelper() self.helper.FooItem.connect_from(some_target_fieldcontainer_here) # WORKS self.my_bool = self.helper.FooItem self.my_bool.value = True
- Calling constructor on base class in Python:
- Please keep in mind for a base class constructor invocation to use the proper way in Python:
super(FooDerivedClass, self).__init__(self, ...)
- Do not try to invoke it with (unless you know what you do):
FooBaseClass.__init__(self, ...)
- Please keep in mind for a base class constructor invocation to use the proper way in Python:
- Never use the AV_FC_INIT macro with two leading colons. E.g.: Use
and NOT
AV_FC_INIT(av::osg::Group, ims::PlaneGrid, true);
AV_FC_INIT(::av::osg::Group, ims::PlaneGrid, true);
- Adding an include path to the build environment (or more precise to all environments which are created after the execution of this statement) can be done by:
avango.build.Environment.prepend_include_path(Dir("<folder>").abspath)
