-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnComment
28 lines (20 loc) · 872 Bytes
/
UnComment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import bpy
# Specify the exact file path for your 'defines.hpp' file
#file_path = r"C:\Users\carra\Desktop\volo\FluidX3D\src\defines.hpp"
file_path = "C:/Users/carra/Desktop/BUIFluidX3D/pragmaonce.txt"
ln = bui_fluidx3d['sna_line'] # This is actually referring to the 7th line due to 0-based indexing
# Read the lines from the file
with open(file_path, 'r') as file:
lines = file.readlines()
# Note: Ensure that the file has enough lines to avoid IndexError
if lines[ln].startswith('//'):
# Uncomment the line by removing the leading comment markers
lines[ln] = lines[ln][2:]
else:
# Comment the line by adding '//' at the beginning if not already commented
lines[ln] = '//' + lines[ln]
# Write all lines back to the file
with open(file_path, 'w') as file:
file.writelines(lines)
# Print the modified line for confirmation
print(lines[ln])