SimplifiedLogic / creoson

OpenSource Automation using JSON Transactions for PTC's CREO Parametric
http://www.creoson.com
MIT License
79 stars 23 forks source link

drwObj.create_gen_view() reports failure caused by missing view even when the view is present. #106

Open bperryrm opened 6 months ago

bperryrm commented 6 months ago

I seem to be getting an error when it's not expected. Steps to repeat:

  1. Create a drawing object and successfully add it to creo.
  2. Create a viewObject and succesfully get a list of views from the model
  3. Attempt to create_gen_view using the view name acquired in step 2 but receive the following error: "ERROR: View does not exist on model: BOTTOM"

It's an odd error considering I got the name of the view from the model itself so it seems the error message is inaccurate or there's some kind of bug causing it to fail. I'm open to the fact I'm missing something in my sample code as well.

Sample files if needed: create_gen_view test.zip Sample test code running in the playground:

function CreateDwgView (modelname) {
let drwMdlView = new creo.ViewObj();
let drwObj = new creo.DrawingObj();

let drwView = "*"
drwObj.template = "elo_sd_d.drw";
drwObj.new_window = true;
drwObj.point = {'x':10 , 'y':10};
drwObj.activate = true;
drwObj.model = "test.prt";
drwObj.drawing = "test.drw";
drwObj.template = "elo_sd_d.drw";
drwObj.scale = 1;
drwObj.display = true;
drwObj.model_view = drwView;
drwObj.new_window = true;
drwObj.sheet = 1;
drwObj.view = "Drawing_Right";

new Promise(function(resolve, reject){
    resolve(modelname)
    //Create the Drawing
    return drwObj.create()
}).then(function (result){
    //Populate the new model view
    drwMdlView.file = drwObj.model; 
    drwMdlView.name = drwView;
    //Get a list of views from this model
    return drwMdlView.list()
}).then(function(result){
    //'Use the first model view returned from the list
    return result.viewlist[0];
}).then(function(result){
    drwObj.set_cur_model(drwView, drwObj.model);
    drwObj.model_view = result;
    return drwObj.create_gen_view() //This function fails with "ERROR: View does not exist on model: BOTTOM"
}).catch((err) => {alert('ERROR: '+err)});
    return true; 
}

CreateDwgView("test.prt")