automatic import of subfiles

Next
 From:  r2d3
6708.1 
I am working on a complex (for me) 3d printing project and because inspiration sometimes takes surprising steps i decided to split my project in one main file (with all parts) and several files with only the single parts and there "tools". so i can change one part of the project, import it to the main project to see how it correspondent.
Now my question: is it possible to write a script for the main project to automate the import of the subfiles? something like a update short key ????

Thanks for every hint
Ralf

EDITED: 17 May 2014 by R2D3

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6708.2 In reply to 6708.1 
Hi Ralf, yeah it could be possible to set up a shortcut key to import a specific file.

To do that, go to Options > Shortcut keys, and add in a new shortcut.

For the "Key" column put in whatever key you want to trigger it, and for the "Command" column put in Import followed by a space followed by the specific file name, something like this for example:

Import c:\parts\Part1.3dm

Then when you trigger that key, it will directly import that specific file instead of asking you for a file name.

Be careful not to trigger it multiple times in a row or else you'll get stacked up duplicate objects.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  r2d3
6708.3 In reply to 6708.2 
so easy..

but i thought more complex.. something like this:
script:var pf="/Users/user/Documents/CAD/";var d=".3dm";var a = ["achswerkzeug", "achshuellen", "reiter"];for ( var i = 0;i < a.length;++i ) { var pfad=pf+a[i]+d;moi.geometryDatabase.fileImport(pfad);};

Now (or before) something to delete the existing objects and than an other short key to export the objects to the part files......
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
6708.4 In reply to 6708.3 
Hi Ralf,

> but i thought more complex.. something like this:

That will work but just one thing to note is that having something alter geometry in an "instant script" like that rather than as a command will not have undo records created for them.

If you want to make it so that import will work with undo, take that same script and put it in a separate .js text file, and then put that file in the \commands sub-folder. Then in the shortcut key put the plain file name (no path and no .js file extension) as the command part of the shortcut key.

One of things that happens when stuff is run as a "command" is that the undo system is initialized and watches for changes to geometry and then creates undo records when the command ends. In the future I want to change this so that instant script would have undo records created automatically as well but currently they don't.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  r2d3
6708.5 In reply to 6708.4 
Michael, you are the best! :-)

THX a lot
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All