我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用bpy.types.Object()。
def __init__(self, bdata, armature=None): """ bdata might be an Object, DupliObject, Bone or PoseBone. If Bone or PoseBone, armature Object must be provided. """ if isinstance(bdata, Object): self._tag = 'OB' self.name = get_blenderID_name(bdata) self.bdata = bdata self._ref = None elif isinstance(bdata, DupliObject): self._tag = 'DP' self.name = "|".join((get_blenderID_name((bdata.id_data, bdata.object)), "Dupli", self._get_dup_num_id(bdata))) self.bdata = bdata.object self._ref = bdata.id_data else: # isinstance(bdata, (Bone, PoseBone)): if isinstance(bdata, PoseBone): bdata = armature.data.bones[bdata.name] self._tag = 'BO' self.name = get_blenderID_name(bdata) self.bdata = bdata self._ref = armature self.parented_to_armature = False
def _object(func): """ :param func: """ def inner(arg, *args, **kwargs): """ :param arg: :param *args: :param **kwargs: """ if isinstance(arg, types.Object): obj = arg else: obj = data.objects[arg] return func(obj, *args, **kwargs) return inner
def execute(self, context): obj = context.object obj.urho_mass = 0.0 obj.urho_friction = 0.5 obj.urho_anisotropic_friction = (1.0, 1.0, 1.0) obj.urho_rolling_friction = 0.0 obj.urho_restitution = 0.0 obj.urho_linear_velocity = (0.0, 0.0, 0.0) obj.urho_angular_velocity = (0.0, 0.0, 0.0) obj.urho_linear_factor = (1.0, 1.0, 1.0) obj.urho_angular_factor = (1.0, 1.0, 1.0) obj.urho_linear_damping = 0.0 obj.urho_angular_damping = 0.0 obj.urho_linear_rest_threshold = 0.8 obj.urho_angular_rest_threshold = 1.0 obj.urho_collision_layer = [True, False, False, False, False, False, False, False] obj.urho_collision_mask = [True] * 8 obj.urho_contact_threshold = 1e+18 obj.urho_ccd_radius = 0.0 obj.urho_ccd_motion_threshold = 0.0 obj.urho_collision_event_mode = 'WHENACTIVE' obj.urho_use_gravity = True obj.urho_is_kinematic = False obj.urho_is_trigger = False obj.urho_gravity_override = (0.0, 0.0, 0.0) return {'FINISHED'} #------------------------- # Properties > Object > 'Urho3D ~ Components' panel #-------------------------
def __call__(cls, bdata, armature=None): if bdata is None: return None dup_mat = None if isinstance(bdata, Object): key = get_blenderID_key(bdata) elif isinstance(bdata, DupliObject): key = "|".join((get_blenderID_key((bdata.id_data, bdata.object)), cls._get_dup_num_id(bdata))) dup_mat = bdata.matrix.copy() else: # isinstance(bdata, (Bone, PoseBone)): if isinstance(bdata, PoseBone): bdata = armature.data.bones[bdata.name] key = get_blenderID_key((armature, bdata)) cache = getattr(cls, "_cache", None) if cache is None: cache = cls._cache = {} instance = cache.get(key) if instance is not None: # Duplis hack: since duplis are not persistent in Blender (we have to re-create them to get updated # info like matrix...), we *always* need to reset that matrix when calling ObjectWrapper() (all # other data is supposed valid during whole cache live, so we can skip resetting it). instance._dupli_matrix = dup_mat return instance instance = cls.__new__(cls, bdata, armature) instance.__init__(bdata, armature) instance.key = key instance._dupli_matrix = dup_mat cache[key] = instance return instance
def build_node_obj(self, fbx_tmpl, settings): if self.bl_obj: return self.bl_obj if self.is_bone or not self.fbx_elem: return None # create when linking since we need object data elem_name_utf8 = self.fbx_name # Object data must be created already self.bl_obj = obj = bpy.data.objects.new(name=elem_name_utf8, object_data=self.bl_data) fbx_props = (elem_find_first(self.fbx_elem, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) assert(fbx_props[0] is not None) # ---- # Misc Attributes obj.color[0:3] = elem_props_get_color_rgb(fbx_props, b'Color', (0.8, 0.8, 0.8)) obj.hide = not bool(elem_props_get_visibility(fbx_props, b'Visibility', 1.0)) obj.matrix_basis = self.get_matrix() if settings.use_custom_props: blen_read_custom_properties(self.fbx_elem, obj, settings) return obj
def update_OP_namelist_cls(self, context): # When Object namelist cls is updated: self.bf_xb = "NONE" # FIXME more rough but cleaner self.bf_xyz = "NONE" self.bf_pb = "NONE" # Check allowed geometries, different namelists may have different allowed geometries FIXME multiple not allowed geometries were left #bf_namelist = self.bf_namelist #bf_prop_XB = bf_namelist.bf_prop_XB #bf_prop_XYZ = bf_namelist.bf_prop_XYZ #bf_prop_PB = bf_namelist.bf_prop_PB #if bf_prop_XB and self.bf_xb not in bf_prop_XB.allowed_items: self.bf_xb = "NONE" #if bf_prop_XYZ and self.bf_xyz not in bf_prop_XYZ.allowed_items: self.bf_xyz = "NONE" #if bf_prop_PB and self.bf_pb not in bf_prop_PB.allowed_items: self.bf_pb = "NONE" # Set default appearance self.set_default_appearance(context)
def build_node_obj(self, fbx_tmpl, settings): if self.bl_obj: return self.bl_obj if self.is_bone or not self.fbx_elem: return None # create when linking since we need object data elem_name_utf8 = self.fbx_name # Object data must be created already self.bl_obj = obj = bpy.data.objects.new(name=elem_name_utf8, object_data=self.bl_data) fbx_props = (elem_find_first(self.fbx_elem, b'Properties70'), elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) assert(fbx_props[0] is not None) # ---- # Misc Attributes obj.color[0:3] = elem_props_get_color_rgb(fbx_props, b'Color', (0.8, 0.8, 0.8)) obj.hide = not bool(elem_props_get_visibility(fbx_props, b'Visibility', 1.0)) obj.matrix_basis = self.get_matrix() if settings.use_custom_props: blen_read_custom_properties(fbx_props[0], obj, settings) return obj
def mesh(obj, options): """ :param obj: :param options: """ logger.debug('object.mesh(%s, %s)', obj, options) if obj.type != MESH: return for mesh_, objects in _MESH_MAP.items(): if obj in objects: return mesh_ else: logger.debug('Could not map object, updating manifest') mesh_ = extract_mesh(obj, options) if len(mesh_.tessfaces) is not 0: manifest = _MESH_MAP.setdefault(mesh_.name, []) manifest.append(obj) mesh_name = mesh_.name else: # possibly just being used as a controller logger.info('Object %s has no faces', obj.name) mesh_name = None return mesh_name