No shortcut for New File

No shortcut for New File

zeljko_zelicWTQ43
Contributor Contributor
1,105 Views
10 Replies
Message 1 of 11

No shortcut for New File

zeljko_zelicWTQ43
Contributor
Contributor

Just out of interest, is there a particular reason why there is no shortcut for New File, like Ctrl+N, while all the other usual suspects do have a keyboard shortcut?

zeljko_zelicWTQ43_0-1714056006445.png

 

Thanks,

Z

 

0 Likes
Accepted solutions (1)
1,106 Views
10 Replies
Replies (10)
Message 2 of 11

seiferp
Community Manager
Community Manager

Out of curiosity, how often do you use New Scene (I mean new empty scene to start a project from scratch) requiring a shortcut? 🤔

0 Likes
Message 3 of 11

zeljko_zelicWTQ43
Contributor
Contributor

Good question 🙂 I think it's just a habit of mine. Probably several times a day. Testing, loading importing different geometry etc. Sometimes, when a scene gets too convoluted I like starting with a clean slate. But that's just me, I was wondering because all the other "standard" shortcuts are there. I think I can live with it as it is 😉

Thanks, Pascal!
Z

0 Likes
Message 4 of 11

Christian_Garimberti
Advisor
Advisor

...but if you cannot live without...

keyNSc = vrKey(Key_N, ControlButton)
keyNSc.connect("newScene()")
keyNSc.setDescription("Create New Scene")

Just add those 3 lines in the script section of the preferences.

 

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 5 of 11

zeljko_zelicWTQ43
Contributor
Contributor

Nice, cheers Christian. I feel much better already 😃

0 Likes
Message 6 of 11

zeljko_zelicWTQ43
Contributor
Contributor

Hey Chris, the script does work, but a bit too brachial for my taste. It brute forces the new scene upon you regardless of whether the scene is empty or not. All is lost. Can you make it to the user to save the scene before? That would be great!

zeljko_zelicWTQ43_0-1714074374809.png

 

0 Likes
Message 7 of 11

Christian_Garimberti
Advisor
Advisor
Accepted solution

Hi, you have to add your function to manage the ask and save process. Not just like 3 line i wrote...

Something like this

from PySide6 import QtWidgets
from PySide6.QtWidgets import QMessageBox, QFileDialog
def myCreateNewScene():
    if vrScenegraphService.isSceneEmpty():
        vrFileIOService.newFile()
    else:
        msgBox = QMessageBox(QMessageBox.Question, "Save", "Save Changet You your Scene?", QMessageBox.Yes|QMessageBox.No|QMessageBox.Cancel, None)
        retVal = msgBox.exec()
        if retVal == 16384:
            curFileName = vrFileIOService.getFileName()
            if not curFileName or len(curFileName) == 0:
                curFileNameSel = QFileDialog.getSaveFileName(None, "Create a new Vred File...", "", "Vred vpb Files (*.vpb)")
                if curFileNameSel and len(curFileNameSel):
                    curFileName = curFileNameSel[0]
            if curFileName and len(curFileName):
                vrFileIOService.saveFile(curFileName)
                vrFileIOService.newFile()
        elif retVal == 65536:
            vrFileIOService.newFile()
        else:
            print("New Scene Aborted.")

keyNSc = vrKey(Key_N, ControlButton)
keyNSc.connect("myCreateNewScene()")
keyNSc.setDescription("Create New Scene")

 

Try it before.....

 

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 8 of 11

Christian_Garimberti
Advisor
Advisor

Just a little question for Autodesk guys about the API…

is there a way to know if an opened file need to be saved or not? Jut to better manage the save question , asking only if needed.

 

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 9 of 11

Excellent question @Christian_Garimberti !

 

For the Flow Production Tracking VRED Engine we have dealt with it this way:

 

https://github.com/shotgunsoftware/tk-vred/blob/a93e270188529319def9fc67b8689e7eb6ff37dc/engine.py#L...

 

I will also double check in our backlog to add this as a +1 to the request for the API, cheers!



Rob Aitchison
Sr. Manager, Customer Excellence
Message 10 of 11

zeljko_zelicWTQ43
Contributor
Contributor

Thanks, Chris, it is just working fine.

Message 11 of 11

Thank You @rob.aitchison.autodesk!

I never though abut the * in the window title! I will use this in the future!!

 

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