I am trying to access the actual part and the linked GPF to it from script as first steps as follows. I get the error
Error: No Global Parameter File (GPF) is linked to the current part.
Can you help about about finding the root? Is it better to specifically define hard coded the route to the files and files names?
Thanks.
import math # Import math module for mathematical operations
from AlibreScript import * # Import Alibre Script API
from datetime import datetime # Import for timestamps
import os # Import for file and folder operations
# Debug: Confirm the script starts execution
print("Script has started...") # Notify the user in the console
# Step 1: Access the current part in Alibre
try:
part = CurrentPart() # Attempt to get the currently active part
print("Part loaded: {}".format(part.Name)) # Debug: Part successfully accessed
except Exception as e:
# Handle the error if no part is loaded
print("Error: No part is currently loaded in Alibre.\n{}".format(str(e)))
raise SystemExit # Exit the script if no part is available
# Step 2: Access the Global Parameter File (GPF)
try:
GPF = CurrentGlobalParameters() # Access the GPF linked to the part
print("GPF loaded: {}".format(GPF.Name)) # Debug: GPF successfully accessed
except NameError:
# Handle the error if no GPF is linked
print("Error: No Global Parameter File (GPF) is linked to the current part.")
raise SystemExit # Exit the script if no GPF is available
# Step 3: Create the output folder
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") # Generate a timestamp for unique folder naming
output_folder = os.path.join("C:\\Users\\usuario\\Desktop\\DESIGNBATHS", "{}_{}_{}".format(part.Name, GPF.Name, timestamp))
os.makedirs(output_folder) # Create the output folder
print("Output folder created: {}".format(output_folder)) # Debug: Folder creation successful
# Step 4: Read favorite parameters from the GPF
parameter_names = [param.Name for param in GPF.Parameters if param.IsFavorite] # Retrieve favorite parameters
print("Debug: Favorite parameters found in GPF: {}".format(parameter_names)) # Debug: List of favorite parameters
Error: No Global Parameter File (GPF) is linked to the current part.
Can you help about about finding the root? Is it better to specifically define hard coded the route to the files and files names?
Thanks.
import math # Import math module for mathematical operations
from AlibreScript import * # Import Alibre Script API
from datetime import datetime # Import for timestamps
import os # Import for file and folder operations
# Debug: Confirm the script starts execution
print("Script has started...") # Notify the user in the console
# Step 1: Access the current part in Alibre
try:
part = CurrentPart() # Attempt to get the currently active part
print("Part loaded: {}".format(part.Name)) # Debug: Part successfully accessed
except Exception as e:
# Handle the error if no part is loaded
print("Error: No part is currently loaded in Alibre.\n{}".format(str(e)))
raise SystemExit # Exit the script if no part is available
# Step 2: Access the Global Parameter File (GPF)
try:
GPF = CurrentGlobalParameters() # Access the GPF linked to the part
print("GPF loaded: {}".format(GPF.Name)) # Debug: GPF successfully accessed
except NameError:
# Handle the error if no GPF is linked
print("Error: No Global Parameter File (GPF) is linked to the current part.")
raise SystemExit # Exit the script if no GPF is available
# Step 3: Create the output folder
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") # Generate a timestamp for unique folder naming
output_folder = os.path.join("C:\\Users\\usuario\\Desktop\\DESIGNBATHS", "{}_{}_{}".format(part.Name, GPF.Name, timestamp))
os.makedirs(output_folder) # Create the output folder
print("Output folder created: {}".format(output_folder)) # Debug: Folder creation successful
# Step 4: Read favorite parameters from the GPF
parameter_names = [param.Name for param in GPF.Parameters if param.IsFavorite] # Retrieve favorite parameters
print("Debug: Favorite parameters found in GPF: {}".format(parameter_names)) # Debug: List of favorite parameters