Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
135 changes: 135 additions & 0 deletions 2025R1/primemesh-25-r1/add-header-to-tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import os
import sys
import argparse


def remove_column_table(input_table):
# Split input table into rows
rows = input_table.strip().split('\n')

# Create a new array for modified table
modified_rows = []

# Add the new header row
modified_rows.append("| Name |")

# invert row[0] and row[1]
temp = rows[0]
rows[0] = rows[1]
rows[1] = temp


# Skip the second row of the original table
# We don't include it in the modified table

# Add remaining rows from the original table, starting from index 2
for i in range(0, len(rows)):
# Split the current row by the '|' character
columns = rows[i].strip().split('|')

# Extract the content of the first column
name_column = columns[1].strip()

# Add the content of the first column to the modified row
modified_rows.append("| " + name_column + " |")

# Construct the modified table string
modified_table = '\n'.join(modified_rows)

return modified_table

def process_md_table(input_table):
# Split input table into rows
rows = input_table.strip().split('\n')

# Create a new array for modified table
modified_rows = ["| Name | Description |"]

# Add the second row of the original table
modified_rows.append(rows[1])

# Add the first row of the original table
modified_rows.append(rows[0])

# Add remaining rows from the original table, starting from index 2
for i in range(2, len(rows)):
modified_rows.append(rows[i])

# Construct the modified table string
modified_table = '\n'.join(modified_rows)

return modified_table

def process_md_files(folder_path):
# Traverse the directory structure recursively
for root, dirs, files in os.walk(folder_path):
for file in files:
# Check if the file is a Markdown file
if file.endswith(".md"):
file_path = os.path.join(root, file)
print("Processing:", file_path)
# Read the input file
with open(file_path, 'r', encoding='utf-8') as file:
file_content = file.read()

# Split the file content by at least one newline character
tables = file_content.split('\n\n')

# Process each potential Markdown table found in the file
modified_tables = []

# Check if all items of column 2 are empty
for table in tables:
# Check if the potential table is actually a Markdown table
if table.strip().startswith('|'):
# Check if the table has two columns with an empty column (first row only)
rows = table.strip().split('\n')
is2ColumnTable = False
for i in range(0, len(rows)):
if i==1:
continue
if rows[i].count('|') == 3:
s = rows[i].split('|')[2]
if all(char.isspace() or char == '\t' for char in s):
print("Found 1 column table")
else:
print("Found 2 column table")
is2ColumnTable = True

if rows[0].count('|') > 3:
print("Found >2 column table")
elif is2ColumnTable == True:
# Process the MD table
modified_table = process_md_table(table)
elif is2ColumnTable == False:
# Remove the empty column from the table
modified_table = remove_column_table(table)
else:
modified_table = table

modified_tables.append(modified_table)

# Join the modified tables back into the file content
modified_content = '\n\n'.join(modified_tables)

# Write the modified content back to the input file
with open(file_path, 'w', encoding='utf-8') as file:
file.write(modified_content)

print("File '{}' has been updated with corrected tables.".format(file_path))

if __name__ == "__main__":
# Check if the folder path is provided


# Get the folder path from command line argument
#folder_path = sys.argv[1]

parser = argparse.ArgumentParser(description="Add headers to tables in Markdown files.")
parser.add_argument("--input_folder", help="Path to the folder of Markdown files")
args = parser.parse_args()

folder_path = args.input_folder

# Process all Markdown files in the folder and its subfolders
process_md_files(folder_path)
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ Results associated with the add label operation.

### Methods

| [`AddLabelResults.print_default`](ansys.meshing.prime.AddLabelResults.print_default.md#ansys.meshing.prime.AddLabelResults.print_default)() | Print the default values of `AddLabelResults` object. |
| Name | Description |
|---------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| [`AddLabelResults.print_default`](ansys.meshing.prime.AddLabelResults.print_default.md#ansys.meshing.prime.AddLabelResults.print_default)() | Print the default values of `AddLabelResults` object. |
| [`AddLabelResults.set_default`](ansys.meshing.prime.AddLabelResults.set_default.md#ansys.meshing.prime.AddLabelResults.set_default)([error_code]) | Set the default values of the `AddLabelResults` object. |

### Attributes

| [`AddLabelResults.error_code`](ansys.meshing.prime.AddLabelResults.error_code.md#ansys.meshing.prime.AddLabelResults.error_code) | Error code associated with the add label operation. |
| Name | Description |
|------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
<!-- vale on -->
| [`AddLabelResults.error_code`](ansys.meshing.prime.AddLabelResults.error_code.md#ansys.meshing.prime.AddLabelResults.error_code) | Error code associated with the add label operation. |
<!-- vale on -->
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ Parameters to add thickness for a given plane.

### Methods

| [`AddThicknessParams.print_default`](ansys.meshing.prime.AddThicknessParams.print_default.md#ansys.meshing.prime.AddThicknessParams.print_default)() | Print the default values of `AddThicknessParams` object. |
| Name | Description |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`AddThicknessParams.print_default`](ansys.meshing.prime.AddThicknessParams.print_default.md#ansys.meshing.prime.AddThicknessParams.print_default)() | Print the default values of `AddThicknessParams` object. |
| [`AddThicknessParams.set_default`](ansys.meshing.prime.AddThicknessParams.set_default.md#ansys.meshing.prime.AddThicknessParams.set_default)([thickness, ...]) | Set the default values of the `AddThicknessParams` object. |

### Attributes

| [`AddThicknessParams.fix_intersections`](ansys.meshing.prime.AddThicknessParams.fix_intersections.md#ansys.meshing.prime.AddThicknessParams.fix_intersections) | Fix intersections in concave regions. |
| Name | Description |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------|
| [`AddThicknessParams.fix_intersections`](ansys.meshing.prime.AddThicknessParams.fix_intersections.md#ansys.meshing.prime.AddThicknessParams.fix_intersections) | Fix intersections in concave regions. |
| [`AddThicknessParams.reverse_face_normal`](ansys.meshing.prime.AddThicknessParams.reverse_face_normal.md#ansys.meshing.prime.AddThicknessParams.reverse_face_normal) | To assign the direction of inflation. |
| [`AddThicknessParams.suggested_part_name`](ansys.meshing.prime.AddThicknessParams.suggested_part_name.md#ansys.meshing.prime.AddThicknessParams.suggested_part_name) | Suggested part name for created patching surfaces. |
| [`AddThicknessParams.thickness`](ansys.meshing.prime.AddThicknessParams.thickness.md#ansys.meshing.prime.AddThicknessParams.thickness) | To assign the offset distance of inflation. |
<!-- vale on -->
<!-- vale on -->
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ Result structure associated with add thickness zonelets.

### Methods

| [`AddThicknessResults.print_default`](ansys.meshing.prime.AddThicknessResults.print_default.md#ansys.meshing.prime.AddThicknessResults.print_default)() | Print the default values of `AddThicknessResults` object. |
| Name | Description |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [`AddThicknessResults.print_default`](ansys.meshing.prime.AddThicknessResults.print_default.md#ansys.meshing.prime.AddThicknessResults.print_default)() | Print the default values of `AddThicknessResults` object. |
| [`AddThicknessResults.set_default`](ansys.meshing.prime.AddThicknessResults.set_default.md#ansys.meshing.prime.AddThicknessResults.set_default)([...]) | Set the default values of the `AddThicknessResults` object. |

### Attributes

| [`AddThicknessResults.error_code`](ansys.meshing.prime.AddThicknessResults.error_code.md#ansys.meshing.prime.AddThicknessResults.error_code) | Error code associated with failure of operation. |
| Name | Description |
|------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------|
| [`AddThicknessResults.error_code`](ansys.meshing.prime.AddThicknessResults.error_code.md#ansys.meshing.prime.AddThicknessResults.error_code) | Error code associated with failure of operation. |
| [`AddThicknessResults.part_id`](ansys.meshing.prime.AddThicknessResults.part_id.md#ansys.meshing.prime.AddThicknessResults.part_id) | The created thickness part id. |
<!-- vale on -->
<!-- vale on -->
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ Results associated with the add to zone operation.

### Methods

| [`AddToZoneResults.print_default`](ansys.meshing.prime.AddToZoneResults.print_default.md#ansys.meshing.prime.AddToZoneResults.print_default)() | Print the default values of `AddToZoneResults` object. |
| Name | Description |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| [`AddToZoneResults.print_default`](ansys.meshing.prime.AddToZoneResults.print_default.md#ansys.meshing.prime.AddToZoneResults.print_default)() | Print the default values of `AddToZoneResults` object. |
| [`AddToZoneResults.set_default`](ansys.meshing.prime.AddToZoneResults.set_default.md#ansys.meshing.prime.AddToZoneResults.set_default)([error_code, ...]) | Set the default values of the `AddToZoneResults` object. |

### Attributes

| [`AddToZoneResults.error_code`](ansys.meshing.prime.AddToZoneResults.error_code.md#ansys.meshing.prime.AddToZoneResults.error_code) | Error code associated with the failure of operation. |
| Name | Description |
|----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| [`AddToZoneResults.error_code`](ansys.meshing.prime.AddToZoneResults.error_code.md#ansys.meshing.prime.AddToZoneResults.error_code) | Error code associated with the failure of operation. |
| [`AddToZoneResults.warning_codes`](ansys.meshing.prime.AddToZoneResults.warning_codes.md#ansys.meshing.prime.AddToZoneResults.warning_codes) | Warning codes associated with the add to zone operation. |
<!-- vale on -->
<!-- vale on -->
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Define advanced settings for remeshing operation.

### Methods

| [`AdvancedSurferSetup.conjugate`](ansys.meshing.prime.AdvancedSurferSetup.conjugate.md#ansys.meshing.prime.AdvancedSurferSetup.conjugate) | Returns self, the complex conjugate of any int. |
| Name | Description |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [`AdvancedSurferSetup.conjugate`](ansys.meshing.prime.AdvancedSurferSetup.conjugate.md#ansys.meshing.prime.AdvancedSurferSetup.conjugate) | Returns self, the complex conjugate of any int. |
| [`AdvancedSurferSetup.bit_length`](ansys.meshing.prime.AdvancedSurferSetup.bit_length.md#ansys.meshing.prime.AdvancedSurferSetup.bit_length)(/) | Number of bits necessary to represent self in binary. |
| [`AdvancedSurferSetup.bit_count`](ansys.meshing.prime.AdvancedSurferSetup.bit_count.md#ansys.meshing.prime.AdvancedSurferSetup.bit_count)(/) | Number of ones in the binary representation of the absolute value of self. |
| [`AdvancedSurferSetup.to_bytes`](ansys.meshing.prime.AdvancedSurferSetup.to_bytes.md#ansys.meshing.prime.AdvancedSurferSetup.to_bytes)(/[, length, ...]) | Return an array of bytes representing an integer. |
Expand All @@ -21,11 +22,12 @@ Define advanced settings for remeshing operation.

### Attributes

| [`AdvancedSurferSetup.real`](ansys.meshing.prime.AdvancedSurferSetup.real.md#ansys.meshing.prime.AdvancedSurferSetup.real) | the real part of a complex number |
| Name | Description |
|-------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| [`AdvancedSurferSetup.real`](ansys.meshing.prime.AdvancedSurferSetup.real.md#ansys.meshing.prime.AdvancedSurferSetup.real) | the real part of a complex number |
| [`AdvancedSurferSetup.imag`](ansys.meshing.prime.AdvancedSurferSetup.imag.md#ansys.meshing.prime.AdvancedSurferSetup.imag) | the imaginary part of a complex number |
| [`AdvancedSurferSetup.numerator`](ansys.meshing.prime.AdvancedSurferSetup.numerator.md#ansys.meshing.prime.AdvancedSurferSetup.numerator) | the numerator of a rational number in lowest terms |
| [`AdvancedSurferSetup.denominator`](ansys.meshing.prime.AdvancedSurferSetup.denominator.md#ansys.meshing.prime.AdvancedSurferSetup.denominator) | the denominator of a rational number in lowest terms |
| [`AdvancedSurferSetup.NONE`](ansys.meshing.prime.AdvancedSurferSetup.NONE.md#ansys.meshing.prime.AdvancedSurferSetup.NONE) | Option to define no advanced settings. |
| [`AdvancedSurferSetup.WRAPPER`](ansys.meshing.prime.AdvancedSurferSetup.WRAPPER.md#ansys.meshing.prime.AdvancedSurferSetup.WRAPPER) | Option to define advanced settings for wrapper surfaces. |
<!-- vale on -->
<!-- vale on -->
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,9 @@ For example, with prisms.

### Methods

| [`AutoMesh.mesh`](ansys.meshing.prime.AutoMesh.mesh.md#ansys.meshing.prime.AutoMesh.mesh)(part_id, automesh_params) | Performs volume meshing on the part with the given meshing parameters. |
| Name | Description |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [`AutoMesh.mesh`](ansys.meshing.prime.AutoMesh.mesh.md#ansys.meshing.prime.AutoMesh.mesh)(part_id, automesh_params) | Performs volume meshing on the part with the given meshing parameters. |

<a id="examples-using-automesh"></a>

## Examples using AutoMesh

<div class="sphx-glr-thumbnails">
<!-- thumbnail-parent-div-open --><div class="sphx-glr-thumbcontainer" tooltip="Summary: This example demonstrates how to mesh a thin solid with hexahedral and prism cells."> <div class="sphx-glr-thumbnail-title">Mesh a saddle bracket for a structural analysis</div>
</div>
* [Mesh a saddle bracket for a structural analysis](../../examples/gallery_examples/gallery/07_saddle_bracket.md#sphx-glr-examples-gallery-examples-gallery-07-saddle-bracket-py)

<div class="sphx-glr-thumbcontainer" tooltip="Summary: This example demonstrates how to generate a mesh for a generic F1 rear wing STL file model."> <div class="sphx-glr-thumbnail-title">Mesh a generic F1 car rear wing for external aero simulation</div>
</div>
* [Mesh a generic F1 car rear wing for external aero simulation](../../examples/gallery_examples/gallery/08_lucid_generic_f1_rear_wing.md#sphx-glr-examples-gallery-examples-gallery-08-lucid-generic-f1-rear-wing-py)

<!-- thumbnail-parent-div-close --></div>
<!-- vale on -->
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ Performs volume meshing on the part with the given meshing parameters.

**automesh_params**
: Parameters for auto mesh.

* **Returns:**
:

[`AutoMeshResults`](ansys.meshing.prime.AutoMeshResults.md#ansys.meshing.prime.AutoMeshResults)
: Returns the AutomeshResults.

* **Return type:**

[`AutoMeshResults`](ansys.meshing.prime.AutoMeshResults.md#ansys.meshing.prime.AutoMeshResults)

### Examples
Expand All @@ -31,17 +33,3 @@ Performs volume meshing on the part with the given meshing parameters.

<!-- !! processed by numpydoc !! -->

<a id="examples-using-automesh-mesh"></a>

## Examples using AutoMesh.mesh

<div class="sphx-glr-thumbnails">
<!-- thumbnail-parent-div-open --><div class="sphx-glr-thumbcontainer" tooltip="Summary: This example demonstrates how to mesh a thin solid with hexahedral and prism cells."> <div class="sphx-glr-thumbnail-title">Mesh a saddle bracket for a structural analysis</div>
</div>
* [Mesh a saddle bracket for a structural analysis](../../examples/gallery_examples/gallery/07_saddle_bracket.md#sphx-glr-examples-gallery-examples-gallery-07-saddle-bracket-py)

<div class="sphx-glr-thumbcontainer" tooltip="Summary: This example demonstrates how to generate a mesh for a generic F1 rear wing STL file model."> <div class="sphx-glr-thumbnail-title">Mesh a generic F1 car rear wing for external aero simulation</div>
</div>
* [Mesh a generic F1 car rear wing for external aero simulation](../../examples/gallery_examples/gallery/08_lucid_generic_f1_rear_wing.md#sphx-glr-examples-gallery-examples-gallery-08-lucid-generic-f1-rear-wing-py)

<!-- thumbnail-parent-div-close --></div>
Loading