|
[Sponsors] |
November 4, 2015, 11:32 |
Run Java macros in Star Ccm+
|
#1 |
New Member
Join Date: Nov 2015
Posts: 2
Rep Power: 0 |
Hi!
I recently began programming in Java in order to do some pre-process into Star Ccm+. The problem I have is when a play in Star Ccm+ a java macro wich calls another macro, Star throws a Instantiation Exception, like if the class was abstract or empty or something. This is a silly example of what I'm trying with two simple macros (the classpath is correct). The second macro "crearprueba.java" calls the first macro "prueba.java" and set its data member "a" as value for BaseSize. First class: public class prueba { int a; public prueba (int b) { a=b; } } Second class: import java.util.*; import star.resurfacer.*; import star.common.*; import star.base.neo.*; import star.meshing.*; public class crearprueba extends StarMacro { public prueba Pr; public crearprueba (prueba p) { Pr=p; } int metodo() { return Pr.a; } public void execute() { prueba paul = new prueba (3); crearprueba hewson = new crearprueba (paul); Simulation simulation_0 = getActiveSimulation(); MeshContinuum meshContinuum_0 = simulation_0.getContinuumManager().createContinuum (MeshContinuum.class); meshContinuum_0.enable(ResurfacerMeshingModel.clas s); meshContinuum_0.getReferenceValues().get(BaseSize. class).setValue(hewson.metodo()); } } Either if I play "prueba.java" or "crearprueba.java" Star Ccm+ throws "java.lan.InstantiationException: prueba/crearprueba" Any ideas? Thanks for all the solutions you can provide. |
|
November 5, 2015, 08:57 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
You have to consider that your crearpreuba class is derived from StarMacro, so you can't use your constructer, since this doesn't have any means of creating its super class (StarMacro).
Instead, just do it directly: Code:
public class crearprueba extends StarMacro { private Simulation sim_; private prueba Pr; public void execute() { sim_ = getActiveSimulationMethod(); Pr = new prueba (3); } } Code:
public class MyMeshVals { private int val_; public void MyMeshVals(int val) { val_ = val; } public void setSomething(Simulation sim) { MeshContinuum meshCont = sim.getContinuumManager().createContinuum (MeshContinuum.class); meshCont.enable(ResurfacerMeshingModel.clas s); meshCont.getReferenceValues().get(BaseSize. class).setValue(val_); } } Code:
public class crearprueba extends StarMacro { public void execute() { Simulation sim = getActiveSimulationMethod(); MyMeshVals paul = new MyMeshVals(3); paul.setSomething(sim); } } |
|
November 6, 2015, 03:48 |
|
#3 |
New Member
Join Date: Nov 2015
Posts: 2
Rep Power: 0 |
Hey olesen!
Thanks for your reply and your advices. I tried your code in Star Ccm+ but Star still does not rcognize "MyMeshVals". Throws a "cannot find symbol (class MyMeshVals)" message and I don't know why. Is it maybe due to not having a .jar file made of the classes in the classpath of Star Ccm+? The thing is I can't make a .jar file because I can't compile those classes since NetBeans doesn't recognize the lines such as "import star.common.*;" "import star.base.neo.*;" neither the own methods of Star like " Simulation sim = getActiveSimulation"... |
|
Tags |
java macro, star ccm+ |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I load Star CCM to Vista? | student_58 | STAR-CCM+ | 0 | December 21, 2012 18:29 |
a java error with installation of Star ccm+ | greenfire | STAR-CCM+ | 1 | November 26, 2012 18:15 |
how to open star ccm 6.04 version file in older versions | pritam.edke | Siemens | 2 | June 25, 2012 04:14 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 21:02 |
How to run star design on unix | AB | Siemens | 1 | October 1, 2004 14:29 |