Importing Python Script change Vred Filename

Importing Python Script change Vred Filename

ionmcains
Enthusiast Enthusiast
864 Views
5 Replies
Message 1 of 6

Importing Python Script change Vred Filename

ionmcains
Enthusiast
Enthusiast

Hi,

 

When I use vrFileIOService to import a python script the name of the VRED file I'm using change to the script filename

 

 

 

 

##################

import_node = vrNodeService.findNode('Root')

files = ['C:/myfile.py']

result = vrFileIOService.importFiles(files, import_node)

#############

 

 

 

Is there other way to do this or avoid this issue?

 

Is there a better workflow to share code among all the team members in a centralized mode?

 

Thanks and regards

 

0 Likes
Accepted solutions (2)
865 Views
5 Replies
Replies (5)
Message 2 of 6

Christian_Garimberti
Advisor
Advisor

Hi, if you have Vred Pro the best way is to create some ScriptPlugins. You can use a shared directory for all your team members.

https://help.autodesk.com/view/VREDPRODUCTS/2024/ENU/?guid=4Tutorial-VREDPro

 

you can use the environment variable VRED_SCRIPT_PLUGINS in every workstation

https://help.autodesk.com/view/VREDPRODUCTS/2024/ENU/?guid=VRED_Python_Documentation_EnvironmentVari...

 

If you have Vred Design you can put your code in the Script section of the preferences.

and if you want to share some preferences, including the script section, you can use this environment variable: 

VRED_PREFERENCES_OVERRIDE

(it works for bot Pro and Design)

 

best

Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

0 Likes
Message 3 of 6

ionmcains
Enthusiast
Enthusiast

Hi,

 

Do you know how I can solve the change of the file name on import?

 

Thanks a lot for the distribution info

 

 

0 Likes
Message 4 of 6

Christian_Garimberti
Advisor
Advisor
Accepted solution

Hi, the only way i found is to use the V1 API vrFileIO.load()

result = vrFileIO.load(['C:/temp/myfile.py'], vrNodeService.findNode('Root'), False, False)

maybe this can help you.

 

Best

Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

Message 5 of 6

Ihor_Skoda_Design
Participant
Participant
Accepted solution
Here is my workaround.


def vredMainWindow():
    main_window_ptr = vrVredUi.getMainWindow()
    return wrapInstance(int(main_window_ptr), QtWidgets.QMainWindow)


def set_title_after_import(*args😞
    """Window title is set, but file name and directory - not.
    So model's name is shown as '__main__.vpb' in the save dialog.
    """
    # os.chdir(os.path.dirname(fpath)) # NOTE does not work
    # os.environ['VRED_CURRENT_PROJECT_DIR'] = os.path.dirname(fpath) # NOTE does not work
    # os.environ['VRED_PROJECT_DIR'] = os.path.dirname(fpath) # NOTE does not work
    # print(vrFileIO.getFileIOBaseDir()) # NOTE no function setFileIOBaseDir
    # print(vrFileIO.getFileIOFilePath()) # NOTE no function setFileIOFilePath
    w = vredMainWindow()
    w.setWindowTitle('Previously saved title')


vrFileIOService.fileLoadingFinished.connect(set_title_after_import)
vrFileIOService.importFiles(['__main__.py'],
    vrSceneplateService.getRootNode(), loadConvertedAtfFiles=False,
    removeConvertedAtfFiles=False, loadBehavior=False)
Message 6 of 6

ionmcains
Enthusiast
Enthusiast

Thanks a lot

0 Likes