Exemplo n.º 1
0
 def _get_vector_line(self):
     """Should return the vector line, if any, otherwise None!
     :rtype: T <= AbstractVectorLine
     """
     line_type = vs.GetLSN(self._object_handle)
     return ObjectRepository().get(vs.Index2Name(
         line_type * -1)) if line_type < 0 else None
Exemplo n.º 2
0
 def instance(self) -> AbstractKeyedObject:
     """Will return the instance, represented by PluginObject, or None if in definition 'mode'.
     :rtype: PluginObject
     """
     succeeded, name, plugin_handle, record_handle, wall_handle = vs.GetCustomObjectInfo(
     )
     return ObjectRepository().get(plugin_handle) if succeeded else None
Exemplo n.º 3
0
 def _get_vector_fill(self):
     """Should return the vector fill, if any, otherwise None!
     :rtype: T <= AbstractVectorFill
     """
     # We'll get the correct pref index through the currently set fill type.
     pref_index = {4: 530, 5: 528, 6: 508, 7: 518}.get(vs.GetPrefInt(529), 0)
     return None if pref_index == 0 else ObjectRepository().get(vs.Index2Name(vs.GetPrefLongInt(pref_index) * -1))
Exemplo n.º 4
0
 def create(name: str):
     """Creates a new class with the given name.
     :rtype: Clazz
     """
     active_clazz = vs.ActiveClass()
     vs.NameClass(name)
     vs.NameClass(active_clazz)
     return ObjectRepository().get(name)
Exemplo n.º 5
0
 def get(self) -> set:
     """Get all objects that meet the criteria set.
     :rtype: set(AbstractKeyedObject)
     """
     objects = set()
     vs.ForEachObject(
         lambda h: objects.add(ObjectRepository().get(h)),
         ' & '.join('(%s)' % c for c in self.__criteria))
     return objects
Exemplo n.º 6
0
 def _get_vector_fill(self):
     """Should return the vector fill, if any, otherwise None!
     :rtype: T <= AbstractVectorFill
     """
     has_vector_fill, name = vs.GetVectorFill(self._object_handle)
     return ObjectRepository().get(name) if has_vector_fill else None
Exemplo n.º 7
0
"""The DLibrary package, which serves as OOP wrapper around vs calls, to make plugin development way easier.

This file should contain only setup stuff, and will only be executed once when VW starts up.
"""
from dlibrary.document import HatchVectorFill, TileVectorFill, ImageVectorFill, GradientVectorFill, Clazz, LineStyle, \
    SymbolDefinition, RecordDefinition
from dlibrary.object import Rectangle, Locus, Symbol, Group, PluginObject
from dlibrary.object_base import ObjectRepository, ObjectTypeEnum

__author__ = 'Dieter Geerts <*****@*****.**>'
__version__ = '2017.1.0'
__license__ = 'MIT'

ObjectRepository().register(ObjectTypeEnum.HATCH_FILL_DEFINITION,
                            HatchVectorFill)
ObjectRepository().register(ObjectTypeEnum.TILE_FILL_DEFINITION,
                            TileVectorFill)
ObjectRepository().register(ObjectTypeEnum.IMAGE_FILL_DEFINITION,
                            ImageVectorFill)
ObjectRepository().register(ObjectTypeEnum.GRADIENT_FILL_DEFINITION,
                            GradientVectorFill)
ObjectRepository().register(ObjectTypeEnum.LINE_STYLE_DEFINITION, LineStyle)
ObjectRepository().register(ObjectTypeEnum.CLASS_DEFINITION, Clazz)
ObjectRepository().register(ObjectTypeEnum.RECORD_DEFINITION, RecordDefinition)
ObjectRepository().register(ObjectTypeEnum.SYMBOL_DEFINITION, SymbolDefinition)
ObjectRepository().register(ObjectTypeEnum.LOCUS, Locus)
ObjectRepository().register(ObjectTypeEnum.RECTANGLE, Rectangle)
ObjectRepository().register(ObjectTypeEnum.GROUP, Group)
ObjectRepository().register(ObjectTypeEnum.SYMBOL, Symbol)
ObjectRepository().register(ObjectTypeEnum.PLUGIN_OBJECT, PluginObject)
Exemplo n.º 8
0
 def get_or_create(name: str):
     """Gets the class, creates if not found.
     :rtype: Clazz
     """
     clazz = ObjectRepository().get(name)
     return clazz if clazz is not None and isinstance(clazz, Clazz) else Clazz.create(name)