_-ImportAnnotationStyles Script help

Im currently using the following to import various settings from my template file into existing DWG files that I’m editing.

Using the following script moves me to the Rhino Template folder.

_-ImportAnnotationStyles “C:\Users\YourUserName\AppData\Roaming\McNeel\Rhinoceros\8.0\Localization\en-US\Template Files\Rhino Template.3DM”

When I eventually go to save the file I need to move back to the original folder of the DWG file i was editing, before the above line of script was processed.

Im hoping to avoid having to climb back through the tree to the original folder.

Any help on how to accomplish this would be greatly appreciated.

Hi @wm_c,

Perhaps a Python script that’s something like this will help?

import Rhino
import System

def ImportDimStyles():
    # Get the %APPDATA% folder
    folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)
    # The template file to import
    template = r"McNeel\Rhinoceros\8.0\Localization\en-US\Template Files\Rhino Template.3DM"
    # Combine the two
    file = System.IO.Path.Combine(folder, template)
    # Verify the file exists
    if System.IO.File.Exists(file):
        # Get the current working folder
        working_folder = Rhino.ApplicationSettings.FileSettings.WorkingFolder
        # Script the ImportAnnotationStyles command
        script = "_-ImportAnnotationStyles \"{0}\"".format(file)
        Rhino.RhinoApp.RunScript(script, False)
        # Reset the current working folder
        Rhino.ApplicationSettings.FileSettings.WorkingFolder = working_folder

if __name__ == "__main__":
    ImportDimStyles()

Thank you Dale, let me give it a spin.

Thank you Dale, but no luck. The script ends asking me for a file selection in the system folder.

Does not appear to know what folder i was working in before the script was called.

Version 1.0001:

import Rhino
import System
import scriptcontext as sc

def ImportDimStyles():
    # Get the %APPDATA% folder
    folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)
    # The template file to import
    template = r"McNeel\Rhinoceros\8.0\Localization\en-US\Template Files\Rhino Template.3DM"
    # Combine the two
    file = System.IO.Path.Combine(folder, template)
    # Verify the file exists
    if System.IO.File.Exists(file):
        # Get path to open file
        working_folder = sc.doc.Path
        if not working_folder:
            # Get the current working folder
            working_folder = Rhino.ApplicationSettings.FileSettings.WorkingFolder
        # Script the ImportAnnotationStyles command
        script = "_-ImportAnnotationStyles \"{0}\"".format(file)
        Rhino.RhinoApp.RunScript(script, False)
        # Reset the current working folder
        Rhino.ApplicationSettings.FileSettings.WorkingFolder = working_folder

if __name__ == "__main__":
    ImportDimStyles()

ImportDimStyles.py (1.0 KB)

– Dale

Thank you Dale, this version finds the template file, opens a window to select the file and then stops.