Overview

The step module provides the data classes and high-level API classes for working with STEP and STEP-NC data. It also provides several module-level functions as described below. Primarily these are used to bring data sets into memory or query object typing.

aim_type()

def aim_type(obj: Object) -> str:

The aim_type() function returns the AIM (EXPRESS) typename of an object. Most objects are a single leaf type, but in the case of AND/OR combinations, which are built from a set of types, the string will contain a series of leaf types concatenated with _and_. This is an alias of the type() method.

arm_type()

def arm_type(obj: Object) -> str:

The arm_type() function return the ARM typename of an object, or None if the object is not the root of an ARM concept. An ARM concept is made up of a network of AIM objects that are used to convey a higher level information, similar to a view built from many normalized tuples in a relational database.

All EXPRESS-defined object have an AIM type, but only the root object of an ARM concept has an ARM type. Objects with an ARM type will have additional ARM properties that are built from lower level AIM instances. See STEP objects for some examples.

# Object that is root of an ARM concept
print(obj)
<step.Object ARM WORKPLAN #1035 machining_workplan> 

print(step.aim_type(obj))	# or just step.type(obj)
machining_workplan

print(step.arm_type(obj))
WORKPLAN


# Other objects, not the root
print(obj)
<step.Object #20 product_definition_shape>

print(step.aim_type(obj))	# or just step.type(obj)
product_definition_shape

print(step.arm_type(obj))
None

isinstance()

def isinstance(
	obj: Object,
	typename: str
	) -> bool:

The isinstance() function returns true if the object an instance of the EXPRESS type or any subtype. This follows the pattern of the Python isinstance() function, but takes a string type name. The type name is not case sensitive. The function will throw an exception if the name is not a valid EXPRESS type.

# Given OBJ = <step.Object #200 polyline>
print (step.isinstance(obj, cartesian_point))
False

print (step.isinstance(obj, polyline))
True

# supertype of the polyline entity definition
print (step.isinstance(obj, representation_item))
True

# no such EXPRESS definition exists
print (step.isinstance(obj, flarble))
ValueError: 'flarble' is not an EXPRESS type

design()

def design() -> Design:

The design() class method returns the Design object that holds the data instances for the current project. The high-level APIs like AptAPI and FinderAPI assume a current project and only operate on one design at a time. This is the same as the return value of open_project() or new_project().

The lower-level APIs like DesignCursor or the Adaptive functions do not assume a current project and usually take a Design object as an argument.

find_design()

def find_design(
	filename: StrOrBytesPath
	) -> Design:

The find_design() function reads a STEP file into memory if not already present and returns the design object. This does no ARM recognition and does not make the design the current project for the high level APIs.

Use open_project() instead to read a file if you plan to use any of the high level APIs.

new_project()

def new_project(
	name: str
	) -> Design:

The new_project() class method creates a new STEP-NC program with an empty workpiece and an empty main workplan. Returns the Design object holding the data instances for the new project. Use the other functions of the APT class to populate the empty project from STEP CAD files, APT files and other data sources.

The empty workplan is named main workplan and its workpiece is named unnamed workpiece. The default feeds and speeds for the new project will be zero. The default tool number for the first tool will be zero.

Keyword Parameters

name: str
Name for the new project, which is also the default file name when a the project is saved.

open_project()

def open_project(
	filename: StrOrBytesPath
	) -> Design:

The open_project() class method reads a STEP or STEP-NC file and recognizes higher level ARM objects within it. Returns the Design object holding the data instances for the file.

Keyword Parameters

filename: StrOrBytesPath
String, bytes, or PathLike object giving the location of the file to be read.

save_project()

def save_project(
	filename: StrOrBytesPath,
	modules: bool = True,
	xml: bool = False
	) -> None:

The save_project() class method writes the current project out to a STEP exchange file.

Keyword Parameters

filename: StrOrBytesPath
String, bytes, or PathLike object giving the location of the file to write. The extension of the file will be changed to .stp or .stpnc depending on whether the file contains just STEP CAD data or also contains STEP-NC process data.
modules: bool = True
If true, the instances in the file are grouped by the high-level concepts that they are used by. These groups are commented showing the structure of the data in greater detail. If false, the instances are written without any extra commenting.
xml: bool = False
If false, the file is writen in STEP Part 21 Exchange Format (ISO 10303-21) which is the most widely used encoding for STEP data. If true, the file is writen using ISO 10303-28, which is an alternative XML encoding that uses XML attributes.

type()

def type(obj: Object) -> str:

The type() function returns the AIM (EXPRESS) typename of an object. This follows the pattern of the Python type() function, but returns a string type name.

Most objects are a single leaf type, but in the case of AND/OR combinations, which are built from a set of types, the string will contain a series of leaf types concatenated with _and_. This is an alias of the aim_type() function

verbose()

@overload
def verbose() -> bool: ...

@overload
def verbose(yn: bool) -> None:

The verbose() function gets or sets the verbose flag. This flag is true by default. Setting it to false disables informational printouts at startup and when files are being read.