Using Java for UG Secondary Development: A simple example (I)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.