A3DObject / SceneObject / CustomObject

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

חבילה: aspose.threed (aspose-3d-foss 26.1.0)

שלוש המחלקות האלה מהוות את הבסיס של היררכיית המחלקות Aspose.3D. כל אובייקט ציבורי בספרייה יורש מ- A3DObject, המספקת שם ואוסף תכונות דינמי. SceneObject מרחיב A3DObject עם מעקב חברות בסצנה. CustomObject הוא תת‑מחלקה קונקרטית קלה לאחסון מטא‑נתונים של משתמשים באופן שרירותי.


A3DObject

מחלקת הבסיס השורשית לכל האובייקטים המנוהלים של Aspose.3D. כל אובייקט בעל שם בספרייה — Node, Mesh, AnimationClip, Material, וכן הלאה — יורש מ- A3DObject.

from aspose.threed import A3DObject

Example

ExampleExampleExampleExample
namestrקריאה/כתיבהשם של האובייקט קריא לבני אדם. ברירת המחדל היא מחרוזת ריקה.
propertiesPropertyCollectionקריאהאוסף התכונות הדינמי המחובר לאובייקט זה. ניתן לעבור עליו או להשתמש ב- find_property() לחיפושים לפי שם.

Example

find_property(property_name)

חפש תכונה בעלת שם באובייקט זה של PropertyCollection ולחזור את Property מופע, או None אם לא נמצא.

ExampleExampleExample
property_namestrהשם לחיפוש.

מחזיר: 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)

החזר את הערך הנוכחי של מאפיין בעל שם, או None אם המאפיין אינו קיים.

ExampleExampleExample
propertystrשם המאפיין.

מחזיר: Any

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

set_property(property, value)

מגדיר את הערך של תכונה בעלת שם. יוצר את התכונה אם היא עדיין לא קיימת.

ExampleExampleExample
propertystrשם המאפיין.
valueAnyערך חדש.

מחזיר: None

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

remove_property(property)

מסיר תכונה בעלת שם מהאוסף.

ExampleExampleExample
property`strProperty`

מחזיר: boolTrue אם המאפיין נמצא והוסר.


Example

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

Example A3DObject עם הפנייה לבעל ה- Scene. Node, Entity, והמחלקות הקשורות יורשות מ- SceneObject.

from aspose.threed import SceneObject

Example

A3DObjectSceneObject

תכונות נוספות

ExampleExampleExampleExample
scene`SceneNone`קריאה/כתיבה
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

תת‑מחלקה קלה של concrete A3DObject שנושאת רק שם ושרירותי PropertyCollection. השתמש בו כדי לצרף מטא‑נתונים חופשיים לסצנה מבלי ליצור תת‑מחלקה של אף סוג ישות.

from aspose.threed import CustomObject

Example

A3DObjectCustomObject

Example

CustomObject(name: str = None)

Example

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

ראה גם

 עברית