|
| 1 | +""" |
| 2 | + Examples for the Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler |
| 3 | +
|
| 4 | + ACIS and SAT are registered trademarks of Spatial Corporation. |
| 5 | +
|
| 6 | + The Python module is developed by Onur R. Bingol and released under MIT license. |
| 7 | + Please see the LICENSE file for details. |
| 8 | +""" |
| 9 | + |
| 10 | +from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Sweeping, Query |
| 11 | + |
| 12 | +# Start ACIS Modeler |
| 13 | +Modeler.api_start_modeller(0) |
| 14 | + |
| 15 | +# Unlock ACIS Modeler components |
| 16 | +unlock_key = "Your ACIS Unlock Key here" |
| 17 | +Licensing.spa_unlock_products(unlock_key) |
| 18 | + |
| 19 | +# Make a cuboid |
| 20 | +block = Entity.BODY() |
| 21 | +Modeler.api_make_cuboid(150, 75, 25, block) |
| 22 | + |
| 23 | +# Get faces of the cuboid |
| 24 | +face_list = Lists.ENTITY_LIST() |
| 25 | +Query.api_get_faces(block, face_list) |
| 26 | + |
| 27 | +# Choose any face from the cuboid's face list |
| 28 | +block_face = face_list.first() |
| 29 | + |
| 30 | +# Convert the chosen face into a sheet body |
| 31 | +sheet_body = Entity.BODY() |
| 32 | +Modeler.api_sheet_from_ff([block_face], sheet_body) |
| 33 | + |
| 34 | +# Make a sweep path |
| 35 | +pt1 = GeometricAtoms.SPAposition(0.0, 0.0, 0.0) |
| 36 | +pt2 = GeometricAtoms.SPAposition(10.0, 55.0, 23.0) |
| 37 | +sweep_path = Entity.EDGE() |
| 38 | +Sweeping.api_make_sweep_path([pt1, pt2], sweep_path) |
| 39 | + |
| 40 | +# Sweep the chosen face using the sweep path |
| 41 | +opts = Sweeping.sweep_options() |
| 42 | +swept_body = Entity.BODY() |
| 43 | +Sweeping.api_sweep_with_options(sheet_body, sweep_path, opts, swept_body) |
| 44 | + |
| 45 | +# Assign attributes after generation |
| 46 | +sheet_body.name = "Swept FACE" |
| 47 | +sheet_body.id = 1 |
| 48 | + |
| 49 | +# Prepare for saving |
| 50 | +save_list = Lists.ENTITY_LIST() |
| 51 | +# api_sweep_with_options will modify sheet_body object as defined in its documentation |
| 52 | +save_list.add(sheet_body) |
| 53 | + |
| 54 | +# Set file name |
| 55 | +filename = "ACIS_Ex03.SAT" |
| 56 | + |
| 57 | +# ACIS requires FileInfo object to be set before saving SAT files |
| 58 | +file_info = SaveRestore.FileInfo() |
| 59 | +file_info.set_product_id(filename) |
| 60 | +file_info.set_units(1.0) # milimeters |
| 61 | + |
| 62 | +SaveRestore.api_set_file_info(file_info, product_id=True, units=True) |
| 63 | + |
| 64 | +# Save the model as a SAT file |
| 65 | +SaveRestore.api_save_entity_list(filename, True, save_list) |
| 66 | + |
| 67 | +# Stop ACIS Modeler |
| 68 | +Modeler.api_stop_modeller() |
0 commit comments