+package org.simantics.g3d.csg.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.g3d.csg.model.ModelUtil;
+import org.simantics.layer0.Layer0;
+
+public class NewCSGModelHandler extends AbstractHandler {
+
+ private final String defaultName = "CSG Model";
+
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final Resource library = Simantics.getProject().get();
+
+ Simantics.getSession().asyncRequest(new WriteRequest() {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ Layer0 l0 = Layer0.getInstance(graph);
+
+ String name = NameUtils.findFreshName(graph, defaultName, library, l0.ConsistsOf, "%s%d");
+
+ Resource model = ModelUtil.createCSGModel(graph, name);
+ graph.claim(library, l0.ConsistsOf, model);
+
+ }
+ });
+ return null;
+ }
+
+}
\ No newline at end of file