RawPart

Declaration

class declaracad.occ.shape.RawPart(parent=None, **kwargs)[source]

Bases: Shape

A RawPart is a part that delegates creation to the declaration. This allows custom shapes to be added to the 3D model hierarchy. Users should subclass this and implement the create_shapes method.

Attributes:
activated
axis
bbox
children
color
constructed
description
destroyed
direction
display
initialized
is_destroyed
is_initialized
line_color
material
name
parent
position
proxy
proxy_is_active
rotation
texture
tolerance
topology
transparency
wireframe_line_color
x
y
z

Methods

activate_bottom_up()

Initialize the proxy on the bottom-up activation pass.

activate_proxy()

Activate the proxy object tree.

activate_top_down()

Initialize the proxy on the top-down activation pass.

child_added(child)

A reimplemented child added event handler.

child_moved(child)

A method invoked when a child is moved in the object.

child_removed(child)

A reimplemented child removed event handler.

create_shapes(parent)

Create the shape for the control.

destroy()

A reimplemented destructor.

find(name[, regex])

Find the first object in the subtree with the given name.

find_all(name[, regex])

Find all objects in the subtree with the given name.

freeze

Freeze the atom to prevent further modifications to its attributes.

get_member

Get the named member for the atom.

get_shapes()

Retrieve the shapes for display.

has_observer

Get whether the atom has the given observer for a given topic.

has_observers

Get whether the atom has observers for a given topic.

initialize()

A reimplemented initializer.

insert_children(before, insert)

Insert children into this object at the given location.

members()

Get the members dictionary for the type.

notifications_enabled

Get whether notification is enabled for the atom.

notify

Call the registered observers for a given topic with positional and keyword arguments.

observe

Register an observer callback to observe changes on the given topic(s).

parent_changed(old, new)

A method invoked when the parent of the object changes.

render()

Generates and returns the actual shape from the declaration.

root_object()

Get the root object for this hierarchy.

set_notifications_enabled

Enable or disable notifications for the atom.

set_parent(parent)

Set the parent for this object.

suppress_notifications()

Disable member notifications within in a context.

traverse([depth_first])

Yield all of the objects in the tree, from this object down.

traverse_ancestors([root])

Yield all of the objects in the tree, from this object up.

unobserve

Unregister an observer callback for the given topic(s).

Examples

from OCC.TopoDS import TopoDS_Shape from OCC.StlAPI import StlAPI_Reader

class StlShape(RawShape):

#: Loads a shape from an stl file def create_shape(self, parent):

stl_reader = StlAPI_Reader() shape = TopoDS_Shape() stl_reader.Read(shape, ‘./models/fan.stl’) return shape

create_shapes(parent)[source]

Create the shape for the control. This method should create and initialize the shape.

Parameters:
parentshape or None

The parent shape for the control.

Returns:
resultList[shape]

The shapes for the control.

get_shapes()[source]

Retrieve the shapes for display.

Returns:
shapesList[shape] or None

The toolkit shape that was previously created by the call to ‘create_shapes’ or None if the proxy is not active or the shape has been destroyed.

proxy

Reference to the implementation control

Implementation

class declaracad.occ.impl.occ_shape.OccRawPart[source]

Bases: OccPart, ProxyRawPart

Attributes:
ais_shape
builder
declaration
displayed
is_active

Test whether or not the proxy is fully activated.

location
reference
shape
shapes
tdf_label
topology
viewer

Methods

activate_bottom_up()

Activate the proxy tree for the bottom-up pass.

activate_top_down()

Activate the proxy for the top-down pass.

child_added(child)

Handle a child being added to the object.

child_removed(child)

Handle a child being removed from the object.

child_shapes()

Iterator of all child shapes

children()

Get the child objects for this object.

create_shape()

Create the toolkit shape for the proxy object.

create_shapes()

Delegate shape creation to the declaration implementation.

destroy()

Destroy the proxy and any of its resources.

freeze

Freeze the atom to prevent further modifications to its attributes.

get_first_child()

Return shape to apply the operation to.

get_member

Get the named member for the atom.

get_shapes()

Retrieve the underlying toolkit shape.

get_transform()

Compute the transform for locating the part.

has_observer

Get whether the atom has the given observer for a given topic.

has_observers

Get whether the atom has observers for a given topic.

init_layout()

Initialize the layout of the toolkit shape.

init_shape()

Initialize the state of the toolkit widget.

members()

Get the members dictionary for the type.

notifications_enabled

Get whether notification is enabled for the atom.

notify

Call the registered observers for a given topic with positional and keyword arguments.

observe

Register an observer callback to observe changes on the given topic(s).

parent()

Get the parent proxy object for this object.

set_notifications_enabled

Enable or disable notifications for the atom.

suppress_notifications()

Disable member notifications within in a context.

unobserve

Unregister an observer callback for the given topic(s).

update_location([change])

Recompute the location of this and all nested parts.

update_shape([change])

Create the toolkit shape for the proxy object.

walk_shapes([ignore_display])

Iterator of all child shapes

clear_focus

ensure_hidden

ensure_visible

focus_next_child

focus_previous_child

get_bounding_box

has_focus

on_shape_changed

parent_shape

request_relayout

restyle

set_axis

set_background

set_color

set_direction

set_display

set_enabled

set_focus

set_font

set_foreground

set_maximum_size

set_minimum_size

set_position

set_rotation

set_status_tip

set_texture

set_tool_tip

set_transform

set_transparency

set_visible

create_shapes()[source]

Delegate shape creation to the declaration implementation.

get_shapes()[source]

Retrieve the underlying toolkit shape.

reference

Update the class reference