Entity
Methods
Methods Entity class เป็นคลาสฐานเชิงนามธรรมสำหรับอ็อบเจกต์ที่สามารถแนบเข้ากับ a Node ใน Aspose.3D scene graph. คลาสย่อยที่เป็นคอนกรีตรวมถึง Mesh, Camera, Light, และ Geometry. Entity ให้การเข้าถึงลำดับชั้นของโหนดพาเรนต์และเปิดเผย the excluded คุณสมบัติสำหรับการควบคุมการมองเห็น.
แอตทริบิวต์ทั้งหมดที่ระบุด้านล่างคือ คุณสมบัติ; เข้าถึงได้โดยไม่ต้องใช้วงเล็บ.
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}")