How to create a circle in a Creo4 drawing using java toolkit?
Documentation for the Creo java toolkit is abysmal so I turn to the community for help.
I found example of how to create line here:
C:\Program Files\PTC\Creo 4.0\M030\Common Files\otk_java_free\otk_java_appls\jlinkexamples\pfcDrawingExamples.java
I modified it to create a circle instead like this:
public static void createCircle() throws com.ptc.cipjava.jxthrowable
{
StdColor color = StdColor.COLOR_QUILT;
Session session = pfcSession.GetCurrentSession ();
Model model = session.GetCurrentModel();
if (model.GetType() != ModelType.MDL_DRAWING)
throw new RuntimeException ("Current model is not a drawing");
Drawing drawing = (Drawing) model;
int currSheet = drawing.GetCurrentSheetNumber();
View2D view = drawing.GetSheetBackgroundView (currSheet);
Point3D circleCenter = Point3D.create();
circleCenter.set(0, 100); //x
circleCenter.set(1, 100); //y
circleCenter.set(2, 0); //z
Vector3D vd = Vector3D.create();
double diameter = 50;
printMsg("createCircle: about to pfcGeometry.CircleDescriptor_Create...");
CircleDescriptor circleDescriptor = pfcGeometry.CircleDescriptor_Create(circleCenter, diameter, vd);
printMsg("createCircle: about to pfcDetail.DetailEntityInstructions_Create...");
DetailEntityInstructions instrs = pfcDetail.DetailEntityInstructions_Create (circleDescriptor, view);
ColorRGB rgb = session.GetRGBFromStdColor (color);
instrs.SetColor(rgb);
printMsg("createCircle: about to drawing.CreateDetailItem...");
drawing.CreateDetailItem (instrs);
session.GetCurrentWindow().Repaint();
}
Program starts up and prints some debugging statements but then fails here:
createCircle: about to drawing.CreateDetailItem...
Exception caught: com.ptc.wfc.Implementation.pfcExceptions$XToolkitGeneralError
I suspect its because of the empty Vector3D in here:
pfcGeometry.CircleDescriptor_Create(circleCenter, diameter, vd);
What is vd supposed to be? Also, am I setting the circleCenter points correctly? Documentation anywhere?

