Skip to content

Add iAssembly class for creating UC2 cube assemblies in 50x50x55mm grids #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 27, 2025

This PR adds comprehensive support for creating complex UC2 assemblies in grid patterns, addressing the need to place UC2 cubes based on a table with specific positions and orientations.

New Features

iAssembly Class

  • New iAssembly class for working with Inventor assembly documents (.iam files)
  • Grid-based component placement with configurable spacing (default 50x50x55mm)
  • Support for rotations around X, Y, and Z axes
  • Batch component placement from table definitions

Key Methods

# Create assembly with UC2 grid spacing
assembly = iAssembly('UC2_Assembly.iam', units='metric')
assembly.set_grid_spacing(50.0, 50.0, 55.0)

# Place components as specified in the issue
assembly.place_component_at_grid('Assembly_cube_lens.iam', 0, 0, 0, rotation=(0, 0, 0))
assembly.place_component_at_grid('Assembly_cube_mirror.iam', 1, 0, 0, rotation=(0, 90, 0))

Utility Functions

  • CSV-based component definition and import
  • Rectangular grid generation
  • Alternating/checkerboard patterns
  • Component validation helpers

Example Usage

The implementation directly addresses the issue example:

# Assembly_cube_lens.iam at 0,0,0 at orientation 0,0
# Assembly_cube_mirror.iam at 50,0,0 at angle 0,90

from PyInventor import iAssembly

assembly = iAssembly('UC2_Grid.iam', units='metric')
assembly.set_grid_spacing(50.0, 50.0, 55.0)

assembly.place_component_at_grid('Assembly_cube_lens.iam', 0, 0, 0, (0, 0, 0))
assembly.place_component_at_grid('Assembly_cube_mirror.iam', 1, 0, 0, (0, 90, 0))
assembly.save()

Files Added

  • Core Implementation: Updated PyInventor/pyinvent.py with iAssembly class
  • Examples: uc2_grid_example.py, simple_uc2_issue_example.py
  • Utilities: uc2_grid_utilities.py with helper functions
  • Sample Data: sample_uc2_components.csv for CSV workflow
  • Documentation: UC2_Grid_Documentation.md with complete API reference
  • Tests: test_uc2_grid.py for validation

Grid Coordinate System

  • Grid coordinates are integers (0, 1, 2, ...)
  • Actual positions = grid_coords × grid_spacing
  • Example: Grid (1,0,0) with 50mm spacing → Position (50,0,0)mm

CSV Workflow Support

name,file_path,grid_x,grid_y,grid_z,rot_x,rot_y,rot_z
Lens_Origin,Assembly_cube_lens.iam,0,0,0,0,0,0
Mirror_50mm,Assembly_cube_mirror.iam,1,0,0,0,90,0

Backward Compatibility

  • All existing PyInventor functionality preserved
  • New features are additive and don't affect existing iPart class
  • Updated __init__.py to export iAssembly alongside existing classes

Fixes #3.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Creating complex UC2 Assemblies in a 50x50x55 grid Add iAssembly class for creating UC2 cube assemblies in 50x50x55mm grids Jun 27, 2025
@Copilot Copilot AI requested a review from beniroquai June 27, 2025 07:52
Copilot finished work on behalf of beniroquai June 27, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating complex UC2 Assemblies in a 50x50x55 grid
2 participants