A3DObject / SceneObject / CustomObject

A3DObject, SceneObject, CustomObject — Aspose.3D Python API Reference

Gói: aspose.threed (aspose-3d-foss 26.1.0)

Ba lớp này tạo thành nền tảng của hệ thống lớp Aspose.3D. Mỗi đối tượng công khai trong thư viện kế thừa từ A3DObject, cung cấp một tên và một bộ sưu tập thuộc tính động. SceneObject mở rộng A3DObject với việc theo dõi thành viên trong cảnh. CustomObject là một lớp con cụ thể nhẹ để lưu trữ siêu dữ liệu người dùng tùy ý.


A3DObject

Lớp cơ sở gốc cho tất cả các đối tượng được quản lý Aspose.3D. Mỗi đối tượng có tên trong thư viện — Node, Mesh, AnimationClip, Material, và các thứ khác — kế thừa từ A3DObject.

from aspose.threed import A3DObject

Properties

PropertiesPropertiesPropertiesProperties
namestrđọc/ghiTên có thể đọc được của đối tượng. Mặc định là một chuỗi rỗng.
propertiesPropertyCollectionđọcBộ sưu tập thuộc tính động được gắn vào đối tượng này. Duyệt qua nó hoặc sử dụng find_property() để tra cứu theo tên.

Properties

find_property(property_name)

Tìm kiếm một thuộc tính có tên trong đối tượng PropertyCollection và trả về Property đối tượng, hoặc None nếu không tìm thấy.

PropertiesPropertiesProperties
property_namestrTên cần tìm.

Trả về: Property | None

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("origin")
prop = node.find_property("name")
if prop is not None:
    print(prop.value)   # "origin"

get_property(property)

Trả về giá trị hiện tại của thuộc tính có tên, hoặc None nếu thuộc tính không tồn tại.

PropertiesPropertiesProperties
propertystrTên thuộc tính.

Trả về: Any

val = node.get_property("name")
print(val)   # "origin"

set_property(property, value)

Đặt giá trị cho một thuộc tính có tên. Tạo thuộc tính nếu nó chưa tồn tại.

PropertiesPropertiesProperties
propertystrTên thuộc tính.
valueAnyGiá trị mới.

Trả về: None

node.set_property("layer", 3)
print(node.get_property("layer"))   # 3

remove_property(property)

Xóa một thuộc tính có tên khỏi bộ sưu tập.

PropertiesPropertiesProperties
property`strProperty`

Trả về: boolTrue nếu thuộc tính được tìm thấy và đã bị xóa.


Properties

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("my_node")

# Set and retrieve a custom property
node.set_property("export_lod", 2)
print(node.get_property("export_lod"))   # 2

# Enumerate all properties
for prop in node.properties:
    print(f"  {prop.name} = {prop.value!r}")

# Find and inspect a specific property
p = node.find_property("name")
if p:
    print(p.value_type)   # <class 'str'>

SceneObject

Properties A3DObject với một tham chiếu tới chủ sở hữu Scene. Node, Entity, và các lớp liên quan kế thừa từ SceneObject.

from aspose.threed import SceneObject

Properties

A3DObjectSceneObject

Các thuộc tính bổ sung

PropertiesPropertiesPropertiesProperties
scene`SceneNone`đọc/ghi
from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("child")
print(node.scene is scene)   # True (Node inherits SceneObject)

CustomObject

Một lớp con cụ thể nhẹ của A3DObject chỉ mang một tên và một giá trị tùy ý PropertyCollection. Sử dụng nó để gắn siêu dữ liệu dạng tự do vào một cảnh mà không cần tạo lớp con cho bất kỳ loại thực thể nào.

from aspose.threed import CustomObject

Properties

A3DObjectCustomObject

Properties

CustomObject(name: str = None)

Properties

from aspose.threed import CustomObject, Scene

# Attach pipeline metadata to a node as a custom object
meta = CustomObject("render_settings")
meta.set_property("max_bounces", 8)
meta.set_property("use_denoiser", True)

scene = Scene()
# Store as a user property on the root node
scene.root_node.set_property("render_meta", meta.name)
print(meta.get_property("max_bounces"))   # 8

Xem thêm

 Tiếng Việt