Simple macro question

I have a right click macro on the New button:

_-New "C:\Users\Charles\AppData\Roaming\McNeel\Rhinoceros\8.0\Localization\de-DE\Template Files\Kleine Objekte - Millimeter.3dm"

When I have an unsaved document, Rhino asks if I want to save it.
This interrupts the macro.
Is there a simple way to avoid this interruption?

Maybe related to this?

https://mcneel.myjetbrains.com/youtrack/issue/RH-79109/Scripted-New-command-is-not-working-correctly

Exactly the same.
A solution to this would be great.

Note @whoever - this has been working correctly since as far back as we could specify a template file to use when opening - at least V3, maybe earlier, so like 20+ years?

Looks like an attempt was made to fix something that wasn’t broken. Please un-fix it.

Still not fixed in SRC 8.7…

As a workaround, here is code for a toolbar button:

! _NoEcho
_-RunScript (
Option Explicit
Call OpenTemplate()
Sub OpenTemplate()
	Dim strTemplate
	strTemplate = """Small Objects - Millimeters"""
	If IsNull(strTemplate) Then Exit Sub
	If Not Rhino.DocumentModified Or Rhino.ExeVersion < 8 Then
		Rhino.Command("_-New " & strTemplate)
		Exit Sub
	End If
	Dim strDocName
	strDocName = Rhino.DocumentName()
	If IsNull(strDocName) Then strDocName = "Untitled"
	Dim intChoice
	intChoice = Rhino.MessageBox("Save changes to " & strDocName & "?", 3, "OpenTemplate RhinoScript")
	If intChoice = 2 Then Exit Sub
	If intChoice = 6 Then
		Rhino.Command("_Save")
		Rhino.Command("_-New " & strTemplate)
		Exit Sub
	End If
	Rhino.Command("_-New _No " & strTemplate)
End Sub
)
1 Like

Very good.
Especially because there is no initialization time for Python…
Thank you!

Here is a Python version in any case… No delay if Python is already loaded.

import rhinoscriptsyntax as rs

def OpenTemplate():
    template_name="YourTemplateName.3dm"
    doc_name=rs.DocumentName()
    if not doc_name: doc_name="Untitled"
    msg="Save changes to {} ?".format(doc_name)
    choice = rs.MessageBox(msg,3)
    if choice==6:
        #Yes - save changes
        rs.Command("_Save") #save file
        rs.Command("_-New {}".format(template_name))
    elif choice==7:
        #No - do not save changes
        rs.Command("_-New _No {}".format(template_name))

OpenTemplate()
1 Like