1717import com .google .gson .annotations .Expose ;
1818import com .neuronrobotics .bowlerstudio .physics .TransformFactory ;
1919import static com .neuronrobotics .bowlerstudio .scripting .DownloadManager .*;
20+
21+ import com .neuronrobotics .bowlerstudio .scripting .BlenderLoader ;
22+ import com .neuronrobotics .bowlerstudio .scripting .DownloadManager ;
2023import com .neuronrobotics .bowlerstudio .scripting .ScriptingEngine ;
2124import com .neuronrobotics .bowlerstudio .vitamins .VitaminBomManager ;
2225import com .neuronrobotics .sdk .addons .kinematics .VitaminLocation ;
@@ -121,7 +124,7 @@ public List<CSG> process(List<CSG> incoming) {
121124 return back ;
122125 }
123126
124- public static File copyFileToNewDirectory (File sourceFile , File targetDirectory , String newBaseName )
127+ public static File copyFileToNewDirectory (CaDoodleFile cf , File sourceFile , File targetDirectory , String newBaseName )
125128 throws IOException {
126129 if (!sourceFile .exists ()) {
127130 throw new IOException ("Source file does not exist: " + sourceFile .getAbsolutePath ());
@@ -139,6 +142,15 @@ public static File copyFileToNewDirectory(File sourceFile, File targetDirectory,
139142 if (dotIndex > 0 && dotIndex < fileName .length () - 1 ) {
140143 fileExtension = fileName .substring (dotIndex );
141144 }
145+ // if(fileExtension.toLowerCase().contains("stl")) {
146+ // if(DownloadManager.isDownloadedAlready("blender")) {
147+ // Log.debug("Convert STL to Blender for use in model");
148+ // String newFileName = newBaseName + ".blend";
149+ // File blenderfile = new File(targetDirectory, newFileName);
150+ // BlenderLoader.toBlenderFile(cf.getCsgDBinstance(),sourceFile, blenderfile);
151+ // return blenderfile;
152+ // }
153+ // }
142154
143155 String newFileName = newBaseName + fileExtension ;
144156 File targetFile = new File (targetDirectory , newFileName );
@@ -168,7 +180,7 @@ public static File toLocal(File file, String name,CaDoodleFile cf ) {
168180 if (!isDoodle ) {
169181 File copied ;
170182 try {
171- copied = copyFileToNewDirectory (file , parentFile , name );
183+ copied = copyFileToNewDirectory (cf , file , parentFile , name );
172184 file = copied ;
173185 } catch (IOException e ) {
174186 // Auto-generated catch block
@@ -292,8 +304,10 @@ private static boolean copyDirectory(File sourceDir, File targetDir) throws IOEx
292304 public static File getFile (String name ,CaDoodleFile cf ) {
293305 String strValue = cf .getSelf ().getAbsolutePath ();
294306 File parentFile = new File (strValue ).getParentFile ();
307+ File stl =null ;
295308 for (File f : parentFile .listFiles ()) {
296309 if (f .getName ().contains (name )) {
310+
297311 if (f .isDirectory ()) {
298312 // is a doodle file
299313 for (File d : f .listFiles ()) {
@@ -304,13 +318,18 @@ public static File getFile(String name,CaDoodleFile cf) {
304318 } else {
305319 for (String s : ScriptingEngine .getAllExtentions ()) {
306320 if (f .getName ().toLowerCase ().endsWith (s .toLowerCase ())) {
307- return f ;
321+ if (s .toLowerCase ().contains ("stl" )){
322+ stl =f ;// return the stl if no blender file exists
323+ }else
324+ return f ;
308325 }
309326 }
310327 }
311328 }
312329
313330 }
331+ if (stl !=null )
332+ return stl ;
314333 throw new RuntimeException ("File not found! " + name );
315334 }
316335//
0 commit comments