What's new

Find Path to Script

NateLiquidGravity

Alibre Super User
I'm trying to find the path to the script instead of having the path coded - so I can load information from an xml file sitting in the same folder. So far all the paths that I can find point to 'C:\Program Files\Alibre Design\Program' or a subfolder of that folder. Any ideas?

Code:
from System.IO import Directory
directory = Directory.GetCurrentDirectory()
 

simonb65

Alibre Super User
Not tried it, but does this work in Alibre Script, it works in python ...

Code:
import os
scriptDirectory = os.path.dirname(os.path.realpath(__file__))
 

NateLiquidGravity

Alibre Super User
Good point.
My intentions were to make this tool save settings per user/pc instead of per assembly/part. I hadn't thought about what I'd do if the script was saved in / run from in the assembly/part. I'll have to add a step to my load/save settings function that uses the GetUserData and SetUserData to check for existing settings in the assembly/part.
 

NateLiquidGravity

Alibre Super User
Code:
print ScriptFileName
print ScriptFolder

Andy
Awesome! This will allow me to determine if the script is run from "in memory" or from a saved location too.

Please add information like this to the Help Reference. Otherwise the only people who know are you and those of us reading everything on the forum.
 
Top