Table of Contents
Using a Token to Launch 3DX CATIA from Console or Script
In this post, we’re going to look at how to generate and use a 3DX Login Ticket token to automatically launch a new CATIA session in the native/thick client, bypassing both the user-login and collaborative-space-selection screens.
Creating A Login Ticket in the 3DX Web Client
First, we’re going to navigate to the URL for the 3DX Web Client, and login using our user credentials. In the left pane, within the Experience Configuration section, click on Manage Login Tickets.
Choose Your Login Role and Collaborative Space
In the next screen, we’re going to select the login role and collaborative space we want associated with the login ticket we’re about to generate. This list is automatically populated with all roles and collaborative spaces granted to your user account. In most instances, we’re going to want to use the Infinite Ticket Type, allowing us to use this token more than once. After making these selections, click on Create.
Copying the Generated Token for the Login Ticket
On the following screen, the unique token string for the Login Ticket we’ve just created is displayed. Highlight everything except for the two trailing equals signs (==) in the token string with your cursor. Let’s copy this string to the clipboard – we’ll use it in the next step.
Creating A New Windows User Environment Variable To Store The Login Ticket Token
Next, we’re going to open up System Properties, navigate to the Advanced tab, and click the Environment Variables button at the bottom. This will open up the Windows Environment Variables Editor. Click New underneath the User Variables section (theoretically, we could make it a System environment variable instead, but making it a User environment variable restricts its usage to your Windows account and is more secure).
Naming Our New Environment Variable and Assigning A Value
Now we’re going to choose a name for our new environment variable. In this case, I used 3DXLOGIN, but the name itself does not matter. Let’s type our chosen name into the Variable name field, and then paste the login ticket token we copied to the clipboard in the previous step into the Variable value field. Important – there should not be any trailing equals signs (==) at the end of this string.
Using A Batch Script to Launch and Login to CATIA
Here, we’re going to create a bat file to execute a command to launch and login to CATIA using our new login token. Copy the following code block into a new .bat file using the editor of your choice.
@echo off START C:/"Program Files"/"Dassault Systemes"/B422/win_b64/code/bin/3DEXPERIENCE.exe -Url=https://3dxp.xxxxxxxxxx.xxxx:443/3dspace/ -Tk=%3DXLOGIN%
Modify the path to the 3DEXPERIENCE.exe executable to reflect its actual location on your computer.
Modify the -Url argument to reflect the URL of your organization’s 3DExperience 3DSpace, also changing the port number if necessary.
Optionally, if you’d like to use a non-default environment name and environment directory, you may also include -env and -direnv arguments, respectively, to specify these values. I’ve omitted these arguments from this example.
Modify the -Tk argument to reflect the name you’ve chosen for your environment variable. This always goes in between two percent (%) signs.
Calling the Shell Command From Python
Alternatively, we can simply call the above shell command from whatever language we’re using for CATIA automation interfacing. Let’s look at how to do this in Python:
In this Python example, the launchCatiaAndLogin() function is passing the shell string to Python’s os.system function, which will behave just as if we were executing it from a batch script. I’ve included code to wait for 60 seconds after executing CATIA, and then start checking once every 10 seconds to see if the process 3DEXPERIENCE.exe is running, prior to attempting to define our CATIA application object using the get3dxClient() method (which is part of Dassault’s com3dx Python library and is used to establish communication between CATIA and Python).
def launchCatiaAndLogin(): os.system("START C:/\"Program Files\"/\"Dassault Systemes\"/B422/win_b64/code/bin/3DEXPERIENCE.exe -Url=https://3dxp.xxxxxxxxxxx.xxxx:443/3dspace/ -Tk=%3DXLOGIN%") def isCatiaRunning(): return isProcessRunning("3DEXPERIENCE.exe") # define the CATIA application object if CATIA is None: if isCatiaRunning(): CATIA = get3dxClient() else: launchCatiaAndLogin() # start 3DEXPERIENCE CATIA thick client and login wait_time = 60 for i in range(wait_time): # wait for wait_time seconds while catia launches os.system('cls') # clear screen print("") print(f"Launching 3DEXPERIENCE CATIA; please wait {wait_time - i} seconds...") print("") time.sleep(1) # sleep for 1 sec while CATIA is None: # loop until CATIA is defined CATIA = get3dxClient() if CATIA is None and isCatiaRunning(): # if catia launch process has already started, wait 10 secs and try again for i in range(10): os.system('cls') # clear screen print("CATIA hasn't finished launching yet." f" Attempting to retrieve application object again in {10 - i} seconds.") print("") time.sleep(1) # sleep 10 secs