@@ -295,6 +295,7 @@ public void initialize() {
295295 opperations = opperations .stream ().filter (Objects ::nonNull ).collect (Collectors .toCollection (ArrayList ::new ));
296296 if (indexStarting > opperations .size ())
297297 indexStarting = opperations .size ();
298+ ArrayList <CaDoodleOperation > toRem = new ArrayList <CaDoodleOperation >();
298299 for (int i = 0 ; i < getOpperations ().size (); i ++) {
299300 CaDoodleOperation op = getOpperations ().get (i );
300301 if (op == null )
@@ -306,11 +307,15 @@ public void initialize() {
306307 process (op );
307308 } catch (Throwable t ) {
308309 com .neuronrobotics .sdk .common .Log .error (t );
309- indexStarting = i + 1 ;
310- break ;
311- // opperations.remove (op);
310+ // indexStarting = i ;
311+ // break;
312+ //toRem.add (op);
312313 }
313314 }
315+ //opperations.removeAll(toRem);
316+ // if(indexStarting>opperations.size()) {
317+ // indexStarting = opperations.size();
318+ // }
314319 setCurrentIndex (indexStarting );
315320 updateCurrentFromCache ();
316321 loadImageFromFile ();
@@ -499,18 +504,31 @@ public void run() {
499504
500505 }
501506
502- private void process (CaDoodleOperation op ) {
507+ private void process (CaDoodleOperation op ) throws Exception {
503508 op .setCaDoodleFile (this );
504- List <CSG > process = op .process (getCurrentState ());
505- if (MakeRobot .class .isInstance (op )) {
506- MakeRobot mr = (MakeRobot ) op ;
507- getRobots ().put (mr .getName (), mr .getBuilder ());
509+ List <CSG > process =null ;
510+ Exception ex =null ;
511+ try {
512+ process = op .process (getCurrentState ());
513+ if (MakeRobot .class .isInstance (op )) {
514+ MakeRobot mr = (MakeRobot ) op ;
515+ getRobots ().put (mr .getName (), mr .getBuilder ());
516+ }
517+ }catch (Exception ex1 ) {
518+ ex =ex1 ;
519+ }
520+ if (process ==null ) {
521+ process =getCurrentState ();
522+ }
523+ if (process .size ()==0 ) {
524+ Log .error ("Nothing returned int he process step?" );
508525 }
509526 int currentIndex2 = getCurrentIndex ();
510527 storeResultInCache (op , process );
511528 setCurrentIndex (currentIndex2 + 1 );
512529 setCurrentState (op , process );
513-
530+ if (ex !=null )
531+ throw ex ;
514532 }
515533
516534 public boolean isOperationRunning () {
@@ -569,7 +587,12 @@ public void run() {
569587 }
570588 if (getResult () == OperationResult .INSERT ) {
571589 getOpperations ().add (getCurrentIndex (), op );
572- process (op );
590+ try {
591+ process (op );
592+ } catch (Exception e ) {
593+ // TODO Auto-generated catch block
594+ e .printStackTrace ();
595+ }
573596 try {
574597 regenerateFrom (op ).join ();
575598 } catch (InterruptedException e ) {
@@ -632,12 +655,12 @@ public void run() {
632655 return t ;
633656 }
634657
635- public static CSG getByName (List <CSG > back , String name ) {
658+ public static CSG getByName (List <CSG > back , String name ) throws NameMissingException {
636659 for (CSG c : back ) {
637660 if (c .getName ().contentEquals (name ))
638661 return c ;
639662 }
640- throw new RuntimeException ("Fail! there was no object named " + name );
663+ throw new NameMissingException ("Fail! there was no object named " + name );
641664 }
642665
643666 public static int applyToAllConstituantElements (boolean addRet , List <String > targetNames , ArrayList <CSG > back ,
@@ -649,10 +672,10 @@ public static int applyToAllConstituantElements(boolean addRet, List<String> tar
649672 CSG c = getByName (back , s );
650673 if (c .isInGroup ())
651674 continue ;
652- } catch (Exception ex ) {
653- com .neuronrobotics .sdk .common .Log .error (ex );
654- //continue;
675+ }catch (NameMissingException e ) {
676+ continue ;
655677 }
678+
656679 applyToAllConstituantElements (addRet , s , back , p , depth , appliedMemory );
657680 }
658681 return back .size ();
@@ -755,8 +778,7 @@ private void storeResultInCache(CaDoodleOperation op, List<CSG> process) {
755778 HashSet <String > names = new HashSet <>();
756779 for (CSG c : process ) {
757780 if (names .contains (c .getName ()))
758- throw new RuntimeException ("There can not be 2 objects with the same name after an " + op .getType ()
759- + " opperation! " + c .getName ());
781+ continue ;
760782 names .add (c .getName ());
761783 CSG cachedVer = cloneCSG (c ).setStorage (new PropertyStorage ()).syncProperties (getCsgDBinstance (), c )
762784 .setName (c .getName ()).setRegenerate (c .getRegenerate ()).setID (c );
0 commit comments