Entity
Methods
Methods Entity class е абстрактен базов клас за обекти, които могат да бъдат прикрепени към Node в Aspose.3D графа на сцената. Конкретни подкласове включват Mesh, Camera, Light, и Geometry. Entity предоставя достъп до йерархията на родителските възли и разкрива 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}")