Finding the right object
I will like to then I have a drawing open then I start my script, be able to open the part on the drawing orient part in default view and then export a TIFF file of the part.
I can open the part and export the TIFF file, but I can't orient the part.
If I run "window.GetModel().RetrieveView("Front");" there I start my script from a part it works,
but then I call this then I have a drawing open:
private static void OrientPart(Session MySession, Model model) throws jxthrowable {
// MySession is the current session
// model is the drawing there the Jlink is started
Drawing drawing = (Drawing) model;
String FileType = "";
Models solids = drawing.ListModels ();
Solid solid = (Solid)solids.get (0); // first model on the drawing
// finding the type of the model on the drawing
if (solid.GetType() == ModelType.MDL_DRAWING) FileType = ".drw";
else if (solid.GetType() == ModelType.MDL_PART) FileType = ".prt";
else if (solid.GetType() == ModelType.MDL_ASSEMBLY) FileType = ".asm";
// opening the model
Window window = MySession.OpenFile(pfcModel.ModelDescriptor_CreateFromFileName(model.GetFullName() + FileType));
/* tring to turn the model to the "Default Orientation"
it works if the function is started from a part without opening it
but then runned like here I can compile the code, and Creo run it, but nothing happens.
*/
window.GetModel().RetrieveView("Front");
// solid.RetrieveView("Front");
}
notting happens, no errors.
I think I don't have the part object.
Can anybody help?
Allan Kok

