Neural Acceleration (MLP Surrogate): - Add run_nn_optimization.py with hybrid FEA/NN workflow - MLP architecture: 4-layer (64->128->128->64) with BatchNorm/Dropout - Three workflow modes: - --all: Sequential export->train->optimize->validate - --hybrid-loop: Iterative Train->NN->Validate->Retrain cycle - --turbo: Aggressive single-best validation (RECOMMENDED) - Turbo mode: 5000 NN trials + 50 FEA validations in ~12 minutes - Separate nn_study.db to avoid overloading dashboard Performance Results (bracket_pareto_3obj study): - NN prediction errors: mass 1-5%, stress 1-4%, stiffness 5-15% - Found minimum mass designs at boundary (angle~30deg, thick~30mm) - 100x speedup vs pure FEA exploration Protocol Operating System: - Add .claude/skills/ with Bootstrap, Cheatsheet, Context Loader - Add docs/protocols/ with operations (OP_01-06) and system (SYS_10-14) - Update SYS_14_NEURAL_ACCELERATION.md with MLP Turbo Mode docs NX Automation: - Add optimization_engine/hooks/ for NX CAD/CAE automation - Add study_wizard.py for guided study creation - Fix FEM mesh update: load idealized part before UpdateFemodel() New Study: - bracket_pareto_3obj: 3-objective Pareto (mass, stress, stiffness) - 167 FEA trials + 5000 NN trials completed - Demonstrates full hybrid workflow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
84 lines
2.6 KiB
Python
84 lines
2.6 KiB
Python
"""
|
|
NX CAD Hooks
|
|
============
|
|
|
|
Direct manipulation of NX CAD parts via NX Open Python API.
|
|
|
|
This submodule contains hooks for CAD-level operations on NX parts:
|
|
geometry, expressions, features, and part management.
|
|
|
|
Modules
|
|
-------
|
|
part_manager
|
|
Open, close, save, and query NX part files.
|
|
|
|
Functions:
|
|
- open_part(path) -> Open an NX part file
|
|
- close_part(path) -> Close an open part
|
|
- save_part(path) -> Save a part
|
|
- save_part_as(path, new_path) -> Save with new name
|
|
- get_part_info(path) -> Get part metadata
|
|
|
|
expression_manager
|
|
Get and set NX expressions (design parameters).
|
|
|
|
Functions:
|
|
- get_expressions(path) -> Get all expressions
|
|
- get_expression(path, name) -> Get single expression
|
|
- set_expression(path, name, value) -> Set single expression
|
|
- set_expressions(path, dict) -> Set multiple expressions
|
|
|
|
geometry_query
|
|
Query geometric properties (mass, volume, area, bodies).
|
|
|
|
Functions:
|
|
- get_mass_properties(path) -> Get mass, volume, area, centroid
|
|
- get_bodies(path) -> Get body count and types
|
|
- get_volume(path) -> Get total volume
|
|
- get_surface_area(path) -> Get total surface area
|
|
- get_material(path) -> Get material name
|
|
|
|
feature_manager
|
|
Suppress and unsuppress features for design exploration.
|
|
|
|
Functions:
|
|
- get_features(path) -> List all features
|
|
- get_feature_status(path, name) -> Check if suppressed
|
|
- suppress_feature(path, name) -> Suppress a feature
|
|
- unsuppress_feature(path, name) -> Unsuppress a feature
|
|
- suppress_features(path, names) -> Suppress multiple
|
|
- unsuppress_features(path, names) -> Unsuppress multiple
|
|
|
|
Example
|
|
-------
|
|
>>> from optimization_engine.hooks.nx_cad import geometry_query
|
|
>>> result = geometry_query.get_mass_properties("C:/model.prt")
|
|
>>> if result["success"]:
|
|
... print(f"Mass: {result['data']['mass']:.4f} kg")
|
|
... print(f"Material: {result['data']['material']}")
|
|
|
|
NX Open APIs Used
|
|
-----------------
|
|
- Session.Parts.OpenActiveDisplay() - Open parts
|
|
- Part.Close(), Part.Save(), Part.SaveAs() - Part operations
|
|
- Part.Expressions, ExpressionCollection.Edit() - Expressions
|
|
- MeasureManager.NewMassProperties() - Mass properties
|
|
- Part.Bodies - Body collection
|
|
- Feature.Suppress(), Feature.Unsuppress() - Feature control
|
|
- Session.UpdateManager.DoUpdate() - Model update
|
|
"""
|
|
|
|
from . import part_manager
|
|
from . import expression_manager
|
|
from . import geometry_query
|
|
from . import feature_manager
|
|
from . import model_introspection
|
|
|
|
__all__ = [
|
|
'part_manager',
|
|
'expression_manager',
|
|
'geometry_query',
|
|
'feature_manager',
|
|
'model_introspection',
|
|
]
|