phobos.blender.utils package¶
Submodules¶
phobos.blender.utils.blender module¶
phobos.blender.utils.editing module¶
phobos.blender.utils.general module¶
phobos.blender.utils.git module¶
phobos.blender.utils.io module¶
phobos.blender.utils.naming module¶
Contains the utility functions to rename objects, add/remove namespaces etc.
- phobos.blender.utils.naming.addNamespace(obj, namespace=None)¶
Namespaces a given blender object.
- Parameters:
obj (bpy.types.Object) – The object to namespace.
namespace – (Default value = None)
Returns:
- phobos.blender.utils.naming.addNamespaceToName(name, namespace)¶
- Parameters:
name
namespace
Returns:
- phobos.blender.utils.naming.gatherNamespaces(separator='::')¶
Gathers all existing namespaces.
- Parameters:
separator – (Default value = ‘::’)
Returns:
- phobos.blender.utils.naming.getModelName(obj)¶
Returns the name of the model encoded by obj, provided that obj is a valid model root.
If obj does not contain a defined ‘model/name’, the object name is returned with a ‘*’ added ad the start, ensuring that the return value will not be treated as a valid model name.
- Parameters:
obj (bpy.types.Object) – root object of the model
- Returns:
str – modelname of the object or object name with ‘*’ prepended if undefined
- phobos.blender.utils.naming.getObjectName(obj, phobostype=None)¶
Returns the name of an object relevant to Phobos. An optional phobostype parameter can be provided for objects with multiple uses, such as link objects (which also contain joint and motor information). If no phobostype is provided, the phobostype of the object is used. The object name itself is returned, stripped of namespaces.
- Parameters:
obj (bpy.types.Object) – object for which the name is requested
phobostype – phobostype if relevant (e.g. ‘motor’) (Default value = None)
- Returns:
str – The object’s name
- phobos.blender.utils.naming.getUniqueName(newname, names)¶
Generates a new name similar to the Blender internal convention.
This ensures, that the Blender internal limit to object name lengths (63 characters) is matched without omitting the number. That way, unwanted naming behaviour is avoided.
- Parameters:
newname – desired object name
names – list of existing names (e.g. bpy.data.objects)
- Returns:
str – new name that is unique in the Blender namespace
- phobos.blender.utils.naming.isValidModelname(name)¶
Returns if a name contains characters other than alphanumeric, ‘_’ and ‘-‘. Also, empyt strings are not valid model names.
- Parameters:
name (str) – potential name for a model
- Returns:
bool – True if the name is a valid model name according to convention, False if not.
- phobos.blender.utils.naming.removeNamespace(obj)¶
Removes the namespace from an object if present.
- Parameters:
obj (bpy.types.Object) – The object to remove the namespace from.
Returns:
- phobos.blender.utils.naming.replaceNameElement(prop, old, new)¶
For all selected elements in Blender, replace an old part of a string prop*erty with *new.
- Parameters:
prop
old
new
Returns:
- phobos.blender.utils.naming.safelyName(obj, name, phobostype=None)¶
- Assigns a name to an object in a safe way with regard to the internal
name handling in Blender.
If no
phobostype
is provided or the phobostype is the same as the object itself, the actual object is renamed, generating a name that no other object in Blender has, using Blender’s own naming scheme. This prevents Blender to assign the name and change another object’s name that previously held that name.
- Parameters:
obj (bpy.types.Object) – object to rename
name (str) – new name for the object
phobostype (str, optional) – only rename if the specified phobostype is matched (Default value =
None)
- Returns:
new name of the Blender object
- Return type:
str
- phobos.blender.utils.naming.stripNamespaceFromName(name)¶
- Parameters:
name
Returns:
- phobos.blender.utils.naming.toggleNamespace(obj, namespace='')¶
- Parameters:
obj
namespace – (Default value = ‘’)
Returns: