Skip to content

Commit 8264098

Browse files
committed
Adding freecad and making the blender file be a composite file like SVG
1 parent 0360f2f commit 8264098

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

src/main/java/com/neuronrobotics/bowlerstudio/creature/CadFileExporter.java

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.apache.commons.io.FilenameUtils;
1111

1212
import com.neuronrobotics.bowlerstudio.scripting.BlenderLoader;
13+
import com.neuronrobotics.bowlerstudio.scripting.FreecadLoader;
1314

1415
import eu.mihosoft.vrl.v3d.CSG;
1516
import eu.mihosoft.vrl.v3d.FileUtil;
@@ -82,7 +83,11 @@ public ArrayList<File> generateManufacturingParts(List<CSG> totalAssembly , File
8283
}
8384
int index=0;
8485
ArrayList<CSG> svgParts = new ArrayList<>();
86+
ArrayList<CSG> blendParts = new ArrayList<>();
87+
ArrayList<CSG> freecadParts = new ArrayList<>();
8588
String svgName =null;
89+
String blendName=null;
90+
String freecadName=null;
8691
String nameBase ="";
8792
for(CSG part: totalAssembly){
8893
String name = part.getName();
@@ -109,10 +114,6 @@ public ArrayList<File> generateManufacturingParts(List<CSG> totalAssembly , File
109114
allCadStl.add(makeObj(nameBase,manufactured));//
110115
ui.setCsg(manufactured , null);
111116
}
112-
if(format.toLowerCase().contains("blend")){
113-
allCadStl.add(makeBlender(nameBase,manufactured));//
114-
ui.setCsg(manufactured , null);
115-
}
116117
if(format.toLowerCase().contains("stl")){
117118
allCadStl.add(makeStl(nameBase,manufactured));// default to stl
118119
ui.setCsg(manufactured , null);
@@ -124,17 +125,45 @@ public ArrayList<File> generateManufacturingParts(List<CSG> totalAssembly , File
124125
svgParts.add(manufactured);
125126
ui.setAllCSG(svgParts , null);
126127
}
127-
128+
if(format.toLowerCase().contains("blend")){
129+
//allCadStl.add(makeBlender(nameBase,manufactured));//
130+
ui.setCsg(manufactured , null);
131+
if(blendName==null){
132+
blendName =part.toString();
133+
}
134+
blendParts.add(manufactured);
135+
}
136+
if(format.toLowerCase().contains("freecad")){
137+
//allCadStl.add(makeBlender(nameBase,manufactured));//
138+
ui.setCsg(manufactured , null);
139+
if(freecadName==null){
140+
freecadName =part.toString();
141+
}
142+
freecadParts.add(manufactured);
143+
}
128144
}
129145

130146
}
131147
}
132148
if(svgParts.size()>0){
133149
allCadStl.add(makeSvg(nameBase,svgParts));// default to stl
134150
}
135-
151+
if(blendParts.size()>0){
152+
allCadStl.add(makeBlender(nameBase,blendParts));// default to stl
153+
}
154+
if(freecadParts.size()>0){
155+
allCadStl.add(makeFreecad(nameBase,freecadParts));// default to stl
156+
}
136157
return allCadStl;
137158
}
159+
private File makeFreecad(String nameBase,List<CSG> current ) throws IOException{
160+
File blend = new File(nameBase + ".blend");
161+
System.out.println("Writing "+blend.getAbsolutePath());
162+
for(CSG tmp:current)
163+
FreecadLoader.addCSGToFreeCAD( blend,tmp);
164+
return blend;
165+
}
166+
138167
private File makeStl(String nameBase,CSG tmp ) throws IOException{
139168
File stl = new File(nameBase + ".stl");
140169

@@ -150,10 +179,11 @@ private File makeObj(String nameBase,CSG tmp ) throws IOException{
150179
return stl;
151180
}
152181

153-
private File makeBlender(String nameBase,CSG tmp ) throws IOException{
182+
private File makeBlender(String nameBase,List<CSG> current ) throws IOException{
154183
File blend = new File(nameBase + ".blend");
155184
System.out.println("Writing "+blend.getAbsolutePath());
156-
BlenderLoader.toBlenderFile(tmp, blend);
185+
for(CSG tmp:current)
186+
BlenderLoader.toBlenderFile(tmp, blend);
157187
return blend;
158188
}
159189

0 commit comments

Comments
 (0)