pycatia
repository·master·Indexed 43 days ago
https://github.com/evereux/pycatiaA Python library designed to interface with the CATIA V5 COM interface on Windows for automating CATIA tasks. It provides programmatic access to the CATIA Automation Object model, including modules for Mechanical Modeler (mec_mod_interfaces), Part Design (part_interfaces), Manufacturing (manufacturing_interfaces), Knowledge-based engineering (knowledge_interfaces), and Abaqus automation (abq_automation_interfaces).
What's inside pycatia
- pycatia is a Python module designed to interface with the CATIA V5 Automation COM object. It allows developers to automate CATIA V5 tasks using Python scripts.
Explore pycatia.part_interfaces API
masterThe
pycatia.part_interfacesmodule provides access to various Part Design interfaces in CATIA. This module is organized into sub-modules, each corresponding to a specific geometric or part-design operation.Common categories of operations available through these interfaces include:
- Feature Creation:
pad,pocket,shaft,rib,shell,hole,loft,sweep,revolution. - Patterns & Repartitions:
circ_pattern,rect_pattern,linear_repartition,angular_repartition,user_pattern. - Fillets & Chamfers:
edge_fillet,face_fillet,chamfer,auto_fillet,tritangent_fillet. - Boolean & Transformations:
boolean_shape,solid_combine,mirror,translate,rotate,scaling. - Surface & Shape Operations:
sew_surface,thick_surface,trim,split,dress_up_shape. - Defeaturing: Various filters such as
defeaturing_filter,defeaturing_hole_filter, anddefeaturing_fillet_filterto simplify geometry.
To use a specific interface, you will typically navigate through the
part_interfaceshierarchy to find the relevant operation module.- Feature Creation:
Explore pycatia.manufacturing_interfaces API
masterThe
pycatia.manufacturing_interfacesmodule provides access to CATIA's manufacturing automation interfaces. It contains a wide range of sub-modules for controlling various aspects of the manufacturing process, including machining, tool management, manufacturing activities, and resource factories.Key functional areas include:
- Machining & Processes:
machining_process,manufacturing_process,manufacturing_operation. - Tooling:
manufacturing_tool,manufacturing_tool_assembly,manufacturing_tool_corrector,manufacturing_tool_motion. - Manufacturing Setup & Activities:
manufacturing_setup,manufacturing_activities,manufacturing_activity. - Geometry & Features:
manufacturing_feature,manufacturing_hole,manufacturing_insert,manufacturing_machinable_area. - Generators & Outputs:
manufacturing_apt_generator,manufacturing_output_generator,manufacturing_program.
- Machining & Processes:
Explore Abaqus Automation Interfaces
masterThe
pycatia.abq_automation_interfacesmodule provides programmatic access to Abaqus automation objects. This module is organized into specific interfaces for managing Abaqus jobs, analysis models, steps, loads, boundary conditions, and output requests.Key functional areas include:
- Job Management: Controlling
abq_jobandabq_jobs. - Analysis Setup: Configuring
abq_analysis_model,abq_analysis_case, andabq_analysis_cases. - Step Configuration: Defining various step types such as
abq_general_static_step,abq_explicit_dynamics_step,abq_frequency_step, andabq_heat_transfer_step. - Physics & Constraints: Applying
abq_load,abq_boundary_condition,abq_interaction, and various connection properties (e.g.,abq_spring_connection_property,abq_gasket_property). - Data & Output: Managing
abq_output_request,abq_field_output_request, andabq_history_output_requestto extract simulation results.
- Job Management: Controlling
Explore pycatia knowledge interfaces
masterThepycatia.knowledge_interfacesmodule provides access to CATIA's knowledge-based engineering features. This includes interfaces for managing parameters (Boolean, Integer, Real, String, Enum, etc.), constraints, formulas, rules, optimizations, and design tables. Use these interfaces to automate the manipulation of design intent and mathematical relationships within CATIA models.Explore pycatia.mec_mod_interfaces API
masterThe
pycatia.mec_mod_interfacesmodule provides Python interfaces for interacting with CATIA Mechanical Modeler (Mec Mod) objects. This module is organized into specific sub-modules corresponding to different geometric and mechanical entities.Key categories of interfaces available include:
- Part & Document Management:
part,part_document,factory. - Geometric Elements:
axis_system,axis_systems,body,bodies,hybrid_body,hybrid_bodies,shape,shapes,vertex,edge,face. - Constraints & Relations:
constraint,constraints,fix_together,fix_togethers. - Complex Geometries:
hybrid_shape,hybrid_shapes,ordered_geometrical_set,ordered_geometrical_sets. - Feature-Specific Edges/Vertices: Various interfaces for dimension-specific features like
bi_dim_feat_edge,mono_dim_feat_edge,tri_dim_feat_edge, andrectilinearvariations.
- Part & Document Management:
Understand the pycatia Automation Object hierarchy
masterThe
pycatialibrary follows the CATIA Automation Object model. Understanding the hierarchical relationship between these objects is essential for navigating the API. The hierarchy starts from theApplicationobject and branches into documents, windows, and system services.Core Hierarchy Path:
ApplicationDocumentsDocumentPartProductDrawingRoot
SelectionSelectedElement
WindowsWindowSpecsAndGeomWindowSpecsViewer
ViewersViewerViewer2D/Viewer3D
FileSystemFolder/Files
SystemServiceSettingControllers
Extract Hole information from CATParts
masterFor anyHoleobject within aCATPart, you can programmatically retrieve its origin and direction.Automate Specs and Geometry window captures
masterAutomate the generation of technical views. You can loop through all
CATPartsin a directory and save specific views (PLAN VIEW, SIDE VIEW, END VIEW, and ISO) as PNG files.Typical workflow involves:
- Turning off the specification tree.
- Setting the background to white for clean screen captures.
- Capturing the views.
- Restoring the tree and background settings.
Install pycatia via pip
masterThe quickest way to install
pycatiais usingpipfrom PyPI. This is recommended if you already have Python 3.9 or later installed.To install the package:
pip install pycatiaTo upgrade an existing installation:
pip install pycatia --upgradeRun a script from the command line
masterOnce your script is written and your virtual environment is active, run the script by calling the
pythonexecutable followed by the filename.Example workflow:
# Navigate to the directory cd c:\Users\<username>\python\pycatia-scripts # Activate the virtual environment env\Scripts\activate # Run the script python catia_details.pycd c:\Users\<username>\python\pycatia-scripts env\Scripts\activate python catia_details.pyManage CATIA documents using context managers
masterUse Python context managers to safely open and close CATIA documents. This ensures that resources are properly released even if errors occur during processing.
Common document tasks include:
- Opening and closing documents via context managers.
- Batch processing: Opening all
CATPartfiles in a source directory and exporting them toIGSin a target directory. - File conversion: Opening a CATIA file, exporting it to
STP, and then closing it.
# Example: Using context manager for documents # Example: Batch export CATPart to IGS # Example: Open, Export to STP, and Close