Script Dispatch - Variable Modification

Hello everyone,

I restart in the Dispatch scripts.

In my file data card, I have a PROJECT variable.
When a file is created, the value of this variable is inherited from the PROJECT variable of the data card of the parent folder.

The problem is that project managers and marketers like to change the name of the project under development...

So I'm looking to write a script that would allow me to change the value of a file data card variable.

So far, I have:

For all documents START of the block
Get the %PathToSelectedFile%%NameOfSelectedFile% file
Extract the %PathToSelectedFile%%NameOfSelectedFile% file
Editing Area NEW_PROJECT_NAME
Set map variables Variables...
(.) Selected file or folder
Destination Card Variable = (X) PROJECT
Variable Dispatch to use as variable value = PROJECT_NAME
Archive the %PathToSelectedFile%%NameOfSelectedFile% file
Message OK Rename ok
End for all documents END of the block

In defining dispatch variables:
PROJECT_NAME // Type: Static String // Value: %NEW_PROJECT_NAME%

It seems clean to me, except that it gets stuck from the first step. I can't get/extract the target file.
I get an error message: Error getting the file The process was run successfully, but returned ' false '.

Does anyone have an idea?

Thank you,
Jerome

Config: SolidWorks 2023 SP3 / PDM 2023

Well, I found the solution, I had a lot of mistakes.
I'm putting the correction here, it can be useful.

  • For obtaining/retrieval/checking-in, %PathToSelectedFile% is self-sufficient, it contains the path and file name.

  • The type of variable was not the right one, you need to have a runtime variable

  • The edit area should point directly to the runtime variable

  • As a result, there is only one variable used for the file card information.

dispatchrenommageprojet

Note, in case of multiple selection, the script displays as many " New Project Name" dialog boxes as there are selected files.
For mass renaming, maybe it's better to go through a DataRecovery.

I'm flying to new scripts...
@+

3 Likes

You should customize the Edit Area a little more then to specify which file the new project name applies to :wink:

1 Like

In fact, it was logical, all you had to do was take the " edit area" and " message ok " commands out of the block.

Thus, the dialog box is displayed only once, the script corrects the variables of all the selected files, and the message ok is displayed only once, when everything is finished.

Sans titre

Thank you,
Jerome

1 Like