Entity
Methods
Methods Entity class היא המחלקה הבסיסית המופשטת עבור אובייקטים שיכולים להיות מצורפים ל‑ Node ב‑Aspose.3D scene graph. תתי‑מחלקות קונקרטיות כוללות Mesh, Camera, Light, ו Geometry. Entity מספק גישה להיררכיית צמתים הורה ומחשוף את excluded property לבקרת נראות.
All attributes המופיעים למטה הם properties; גישה אליהם ללא סוגריים.
from aspose.threed import Scene
from aspose.threed.entities import Mesh
scene = Scene.from_file("model.obj")
for node in scene.root_node.child_nodes:
entity = node.entity
if entity is not None:
# excluded is a property, not a method call
if not entity.excluded:
# parent_node is a property, not a method call
parent = entity.parent_node
print(f"Active entity '{entity.name}', parent: {parent.name if parent else 'None'}")Methods
A3DObject → SceneObject → Entity
תתי‑מחלקות: Geometry → Mesh, Camera, Light, ו‑אחרים.
Methods
Entity הוא מחלקה בסיס מופשטת ואינה נוצרה ישירות. השתמש במחלקה נגזרת קונקרטית כגון Mesh.
Methods
| Methods | Methods | Methods |
|---|---|---|
parent_nodes | list[Node] (קריאה בלבד) | כל צמתים הורים שאליהם ישות זו מחוברת. תומך ביצירת מופעים (אותה ישות מוזכרת ממספר צמתים). |
parent_node | Optional[Node] (קריאה/כתיבה) | צומת ההורה הראשי, או None אם הישות אינה מחוברת. |
excluded | bool (קריאה/כתיבה) | Methods True, ישות זו מוחרגת מהצגה. גישה והגדרה כמאפיין: entity.excluded = True. |
name | str (קריאה/כתיבה) | שם קריא לבן אדם עבור ישות זו. |
properties | PropertyCollection (קריאה בלבד) | אוסף של תכונות מותאמות. |
Methods
| Methods | סוג החזרה | Methods |
|---|---|---|
get_property(name) | Any | מקבל ערך תכונה לפי שם. |
find_property(name) | Optional[Property] | מחפש תכונה לפי שם. |
חשוב: parent_node, parent_nodes, ו excluded הם תכונות, לא שיטות. אל תקראו להם עם סוגריים. התבניות הנכונות הן:
# CORRECT
is_excluded = entity.excluded
parent = entity.parent_node
parents = entity.parent_nodes
# WRONG: do not do this
is_excluded = entity.excluded() # TypeError
parent = entity.parent_node() # TypeErrorלהגדיר parent_node, הקצה למאפיין:
entity.parent_node = some_node # CORRECTMethods
בדקו את מצב ה‑entity לאחר טעינת סצנה:
from aspose.threed import Scene
from aspose.threed.entities import Mesh
scene = Scene.from_file("model.stl")
for node in scene.root_node.child_nodes:
entity = node.entity
if entity is None:
continue
# Properties accessed without parentheses
print(f"Entity: {entity.name or '(unnamed)'}")
print(f" Type: {type(entity).__name__}")
print(f" Excluded: {entity.excluded}")
print(f" Parent node: {entity.parent_node.name if entity.parent_node else 'None'}")
if isinstance(entity, Mesh):
print(f" Vertices: {len(entity.control_points)}")
print(f" Polygons: {entity.polygon_count}")