Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
Mike C

GetSavedSetting usage

Recommended Posts

I'm trying to pre-select the folder path when a user selects "Save As" from the File menu, based on the template .sta that the user is working from. The .sta is opened from a different custom menu item using the "OpenURL" function, and therefore the folder path does not default to the .sta location as it does from the "Open" menu item.

The only place I can see where that information is stored is in the User settings .xml file, but I can not figure out how to use the SetSavedSetting and GetSavedSetting functions. What's the "category"? What's the "setting"? The help page is not very helpful on these topics.

Thanks in advance.

Share this post


Link to post

Mike,

???Have you tried : GetFileInfo()? I'm not sure how it will treat .sta files, though, since they are dissociated from the disk file when they are opened.

Raymond

Share this post


Link to post

Maybe you can just get that information straight from the .xml preferences file itself?

And if i'm not mistaken, this information is also saved in the windows registry (and probable the mac .plist files) but i have to look that up again.

Share this post


Link to post

I don't know what useful info you would get from GetFileInfo(), if you are opening the .sta file you already know the path to the .sta file.

If you try to get any pathing info about an unsaved file all that will be returned is the file name.

Get/SetSavedSetting category and setting are the XML tag names.

category = Dialog

setting = choice

value = A

A

If you need to access values deeper in the tree you can use the setting parameter to traverse deeper.

category = Dialog

setting = choice/field1

value = A

A

I can't guarantee changing the setting will work. The XML file is only written and read from disk when VW starts or quits and the functions access the file stored in memory, so don't try to access the settings directly using other XML calls because the information may be incorrect, may be overwritten or not used.

Share this post


Link to post

Thanks, Kevin.

So basically, my idea isn't going to work regardless. However, I still can't get the function to work either.

Here's my Vectorscript:

PROCEDURE NewFloorPlan;

var

strFileName : string;

dummy : boolean;

BEGIN

strFileName := GetFName;

dummy := GetSavedSetting('','',strFileName);

alrtdialog(strFileName);

END;

RUN(NewFloorPlan);

Funny thing is, it doesn't even display the alrtdialog, unless I comment-out the GetSavedSetting function line.

Any other ideas you can give me to pre-select the SaveAs folder path, or even to get the GetSavedSetting function to work would be greatly appreciated.

Thanks again.

Share this post


Link to post

Don't pass in the <> use just the string.

If the tag exists this is how it should read:

(I did not see the tag "DefaultFolderLocation" in my Saved Settings file.)

dummy := GetSavedSetting('DefaultFolderLocation','OpenAndSaveAs',strFileName);

If you check dummy probably returns false and strFileName is now an empty string.

AlrtDialogs don't show if the string is empty.

Share this post


Link to post

I was looking at the wrong (SavedSettings.xml) file, not the SavedSettingsUser.xml file. Which means I really can't update the setting I need to, even if it would work. . .

For anyone else who's curious, here's the syntax:

PROCEDURE NewFloorPlan;

var

strFileName : string;

dummy : boolean;

BEGIN

{NOTE: The "TOpen_Vectorworks_Drawing" setting was nested within the "default_path" setting, hence the "/" between them}

dummy := GetSavedSetting('IFileChooserDialog','default_path/TOpen_Vectorworks_Drawing', strFileName);

alrtDialog(strFileName);

END;

RUN(NewFloorPlan);

Share this post


Link to post
I was looking at the wrong (SavedSettings.xml) file, not the SavedSettingsUser.xml file. Which means I really can't update the setting I need to, even if it would work. . .

Ran into the same thing and went a bit further.

Once I noticed Getsavedsetting/Setsavedsetting only worked on the user file, I tried to rewrite the XML elements of "SavedSettings.xml" instead, hoping this would force the new data into the file. It did work, but it gets reset on closing vectorworks.

I assumed this is because vw loads the settings in the memory and saves them on quitting. I noticed there are also XML memory functions and sort of assumed this was the deal..

I managed to read the memory, and when using the right elementnames I found the saved values, so vw loads that whole file in its memory.

I rewrote them , checked them again for the new values which worked and closed vectorworks. I was hoping these new values would now get saved in the settingfile, but no they don't.

How does vectorworks work ? :(

Share this post


Link to post

Saved settings get read from disk on application open and written to disk on application close. Changes you make to the xml in memory should write on exit.

What exactly are you trying to change in SavedSettings.xml? Many of the application settings have their own SetPref or SetVariable calls. It's also possible that you are writing to a setting that gets read by the quit process. For example, palette positions are read on quit, so any custom change would get overwritten by the actual GUI.

Does that help?

-Josh

Share this post


Link to post

These are the ones I REALLY would like to change..


\\xxxxxx\
C:\Users\xxxx
\\LACIExxxxx

I couldn't find anything in the setvariable calls, and I did manage to overwrite these in the memory, but they get reset somewhow which is weird, no ? Why would they be read on opening, and overwritten by reading again on quitting ?

I'm just not happy with the way that VW saves these paths, its never correct. I have a projectmanagement tool in vectorworks that has the right path for each project we work on, on using it I want it to change all the default paths so it's right when opening/saving/exporting etc in a new drawing..

Edited by hippothamus

Share this post


Link to post

After Overwriting the memory, when exporting or saving the path (before quitting vw) isn't changed either, as if it uses another variable or it reloads them before. I guess this won't work out..

Share this post


Link to post
I couldn't find anything in the setvariable calls

Did you search in the appendix for it or did you ran trough all variables. I'm asking because some of those are just not documented.

I run trough the variables if I can't find it in the appendix. I make a for-loop and write all the values to a text file. Then I search for the specific value and knows what the selector is.

Script is something like this:

Append(fileName);
FOR i:=-3000 TO 3000 DO
BEGIN
Write(i);
Tab(1);
Write(GetPref(i));
Tab(1);
Write(GetPrefInt(i));
Tab(1);
...
Write(GetPrefString(i));
END;
Close(fileName);

Share this post


Link to post

These look like OS level settings. LIkely these values are stored in memory via the OS routines that handle the open / save / export dialogs, and VW reads, then writes these values on quit.

Why are you trying to set these particular values via VS? If it is for user interaction in a script, just use GetFileN, which lets you designate a default path.

-Josh

Share this post


Link to post

Because:

lets say I work on drawing A. I Export something from drawing A once.

When I start Project B, vectorworks still uses the old path. When trying to save B I start at the posision of the previous project.

Of course I need to save the new path once, but we use a project manager in vw that has that path allready, it would be nice if it could be used.

So ok, I save project B in the correct folder, next time saving will be in the right spot !.

Until I try to export something, its still in the position of project A which makes no sense to me. It's a lot of projectsearching while everything could be simplified.

And not to mention, that if I now open project A, the stored valus are from value B.

I took some time to create a projectmanager, storing all our project data into one shared file, including the path of each project and now find out I can't change it .. :(

We save and export a lot between different projects and I have to spend a lot of time changing directories.. The idea was, when switching a drawing I just had to open my manager, and the default saving paths of that particular project are used.

Edited by hippothamus

Share this post


Link to post
I couldn't find anything in the setvariable calls

Did you search in the appendix for it or did you ran trough all variables. I'm asking because some of those are just not documented.

I'll give that a shot.

Share this post


Link to post
I couldn't find anything in the setvariable calls

Did you search in the appendix for it or did you ran trough all variables. I'm asking because some of those are just not documented.

I'll give that a shot.

Went to 20 000, none of them had any path saved.

Share this post


Link to post

I'm glad someone else sees this as a shortcoming within Vectorscript.

As the VW "admin", I need a simple way for my users to open and save drawings in the proper locations without needing to navigate through the file directories themselves. Which is the nice way of saying they're not the sharpest tacks in the drawer.

The OpenURL command shared the Open... menu command functionality in VW 12, but lost it somewhere along the way. I don't know about hippothamus, but at least restoring that functionality would solve my problem.

But preferably, there should be a command within Vectorscript that allows the Save As... path to be initially set per document.

Share this post


Link to post

Tried this myself. Since I new the file path and the new file name I ended up using:

Response := StrDialog ('Filename:', FName));

the user copied this highlighted string and then

DoMenuTextByName ('Save As...',0);

pasting in the copied string (file name and path)

I was told the path was an operating system function and not controllable in VW.

You will note that if the Save As... is used once then the following Save As's will be to the same location.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×