Creo Object TOOLKIT Java Programming Considerations
This section contains information needed to develop an application using Creo Object TOOLKIT Java.
Creo Object TOOLKIT Java Thread Restrictions
When you run a synchronous Creo Object TOOLKIT Java program, you should configure your program so it does not interfere with the main thread of the Creo program. Because the Java API allows you to run with multiple threads, you should be cautious of using certain Java routines in your program.
The most obvious restriction involves the use of Java language user interfaces. Any Java window that you create must be a dialog box that is blocking (or modal).
Creating a nonblocking frame causes a new thread to begin, which can have unexpected results when running with Creo application. For example, you can use the javax.swing.JDialog class and set modal true. You cannot use javax.swing.JWindow, however, because it starts a thread.
Parent-Child Relationships Between Creo Object TOOLKIT Java Objects
Some Creo Object TOOLKIT Java objects inherit from either the interface com.ptc.pfc.pfcObject.Parent or com.ptc.pfc.pfcObject.Child. These interfaces are used to maintain a relationship between the two objects. This has nothing to do with Java inheritance. In Creo Object TOOLKIT Java, the Child is owned by the Parent.
Methods Introduced:
The method GetDBParent returns the owner of the child object. Because the object is returned as a com.ptc.pfc.pfcObject.Parent object, the application developer must down cast the return to the appropriate class. The following table lists parent/child relationships in Creo Object TOOLKIT Java.
Parent
Child
Session
Model
Session
Window
Model
ModelItem
Solid
Feature
Model
Parameter
Model
ExternalDataAccess
Display
DisplayList2D/3D
Part
Material
Model
View
Model2D
View2D
Solid
XSection
Session
Dll (Creo TOOLKIT)
Session
Application (Creo Object TOOLKIT Java)
Run-Time Type Identification in Creo Object TOOLKIT Java
Creo Object TOOLKIT Java and the Java language provides several methods to identify the type of an object. Each has its adavantages and disadvantages.
Many Creo Object TOOLKIT Java classes provide read access to a type enum (for example, the Feature class has a GetFeatType method, returning a FeatureType enumeration value representing the type of the feature). Based upon the type, a user can downcast the Feature object to a particular subtype, such as ComponentFeat, which is an assembly component.