55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
|
|
"""
|
||
|
|
NXOpen script — Extract plate geometry from selected face.
|
||
|
|
|
||
|
|
ONE-TIME: Run inside NX. User selects plate face, assigns hole weights.
|
||
|
|
Exports geometry.json for the Python brain.
|
||
|
|
|
||
|
|
NOTE: This is pseudocode / skeleton. Actual NXOpen API calls need
|
||
|
|
NX environment to develop and test.
|
||
|
|
"""
|
||
|
|
|
||
|
|
# This script runs inside NX — NXOpen is available at runtime
|
||
|
|
# import NXOpen
|
||
|
|
# import json
|
||
|
|
# import math
|
||
|
|
|
||
|
|
|
||
|
|
def extract_plate_geometry(face, hole_weights):
|
||
|
|
"""
|
||
|
|
Extract plate geometry from an NX face.
|
||
|
|
|
||
|
|
Parameters
|
||
|
|
----------
|
||
|
|
face : NXOpen.Face
|
||
|
|
The selected plate face.
|
||
|
|
hole_weights : dict
|
||
|
|
{loop_index: weight} from user input.
|
||
|
|
|
||
|
|
Returns
|
||
|
|
-------
|
||
|
|
dict : geometry definition for export.
|
||
|
|
"""
|
||
|
|
raise NotImplementedError(
|
||
|
|
"This script must be developed and tested inside NX Simcenter. "
|
||
|
|
"See docs/technical-spec.md Section 2 for full pseudocode."
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def sample_edge(edge, tolerance=0.1):
|
||
|
|
"""Sample edge curve as polyline with given chord tolerance."""
|
||
|
|
# NXOpen: edge.GetCurve(), evaluate at intervals
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
|
||
|
|
def fit_circle(points):
|
||
|
|
"""Fit a circle to boundary points. Returns (center, diameter)."""
|
||
|
|
# Least-squares circle fit
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
|
||
|
|
def export_geometry(geometry, filepath='geometry.json'):
|
||
|
|
"""Export geometry dict to JSON."""
|
||
|
|
import json
|
||
|
|
with open(filepath, 'w') as f:
|
||
|
|
json.dump(geometry, f, indent=2)
|