Recently, due to the need for Secondary Development of Teamcenter (fat Client Customization), all of them have to begin to study Java. So why can't I use Java for secondary development? The development of UG is dominated by C/C ++ applications. Most of them use the original UF function (that is, process-oriented 0). There are many discussions in both tutorials and related communities. Using nxopen C ++ or nxopen. NET is rare. Java should be used less.
In fact, nxopen for Java is the same as other nxopen technologies, and is a development interface built on the journal layer. It is said that Siemens has now converted 100% of the bottom layer of NX to JA, and its ja-based development interface is gradually being implemented. At least 6.0 of the NX version is very powerful. If you want to learn about the second development of NX, or your project is based on nx5.0 or later versions, we recommend that you use nxopen family development tools (nxopen C ++, nxopen. net, use C # Or VB. net)
Here I wrote a very simple example of using Java for the second development of NX: It is to generate a block. This example illustrates the basic framework of an nxopen for Java program.
import java.io.*;
import java.rmi.RemoteException;
import nxopen.*;
import nxopen.features.*;
public class HelloNX {
public static void main(String[] args)
{
try
{
Session theSession = (Session)SessionFactory.get("Session");
Part wrkPart = theSession.parts().work();
BlockFeatureBuilder builder = wrkPart.features().createBlockFeatureBuilder(null);
builder.setType(BlockFeatureBuilder.Types.ORIGIN_AND_EDGE_LENGTHS);
Point3d origin = new Point3d(0.0,0.0,0.0);
builder.setOriginAndLengths(origin,"100","100","100");
builder.commit();
}
catch(NXException ex)
{
ex.printStackTrace();
}
catch(RemoteException ex)
{
ex.printStackTrace();
}
}
public static int getUnloadOption()
{
return BaseSession.LibraryUnloadOption.IMMEDIATELY;
}
}
1. The compilation is completed first.
2. Open UG and create a new part.
3. Press Ctrl + u to bring up the execution file selection dialog box, and then select the. Class file in the file type filtering area.
4. Select the file you just generated, such as hellonx. Class. After the program is executed, a block is generated.
Okay, that's easy! I will explain the code next time.