Display instructions on button click with respective to sequence steps
As per the original post.
As per the original post.
Hi
So want to provide here an simple example for parser that will e.g. read the pvi file and then write it a json file. So follwong steps
figureName = "Assemble"
and call in windows shell where a node.js is installed the following script (let say the name is myStepTool.js) :
/********** myStepTool.js *************/
let figureName = "Assemble"
let xmlFileName ="l-Creo 3D - " +figureName+".pvi"
let jsonFileName = figureName+".json"
//name is "l-Creo 3D - Assemble.pvi"
//=================================
var request = require('request');
var fs = require('fs');
let myXmlData=[]
let myArr = []
let myJsonArr = []
let TempjsonObj={stepNumber: 0 , step_name_locid: "" ,
step_name:"",step_acknowledge:false,
step_description_locid:"",step_description:""}
xml2js = require('xml2js');
var parser = new xml2js.Parser();
fs.readFile(__dirname + '/'+xmlFileName, function(err, data) {
parser.parseString(data, function (err, result) {
//console.dir(result);
let seq_s=result['galaxy_3di:figure']['galaxy_3di:sequence']
//console.log(JSON.stringify(seq_s))
//console.dir( seq_s[0]['galaxy_3di:sequence_step'] )
//console.log( seq_s )
console.log('Done');
let prop_animats=seq_s[0]['galaxy_3di:sequence_step']
prop_animats.forEach(el_function1)
});
console.info("jsonArray\n=================\n")
console.log(JSON.stringify(myJsonArr))
fs.writeFileSync(__dirname + '/'+jsonFileName, JSON.stringify(myJsonArr, null, 2) , 'utf-8');
});
function el_function1(item, index, arr) {
let jsonObj= JSON.parse(JSON.stringify(TempjsonObj))
jsonObj.stepNumber= index;
myArr[index] = item['galaxy_3di:property']
//console.log("myArr["+index+"] = "+myArr[index])
//console.dir(myArr[index])
//console.log("myArr["+index+"][1][\'$\'].value = "+myArr[index][1]['$'].value)
console.log("myArr["+index+"] ["+ myArr[index][0]['$'].name+ "] = "+myArr[index][0]['$'].value)
jsonObj.step_name_locid = myArr[index][0]['$'].value
console.log("myArr["+index+"] ["+ myArr[index][1]['$'].name+ "] = "+myArr[index][1]['$'].value)
jsonObj.step_name = myArr[index][1]['$'].value
console.log("myArr["+index+"] ["+ myArr[index][2]['$'].name+ "] = "+myArr[index][2]['_'])
jsonObj.step_acknowledge = myArr[index][2]['_']
console.log("myArr["+index+"] ["+ myArr[index][3]['$'].name+ "] = "+myArr[index][3]['$'].value)
jsonObj.step_description_locid = myArr[index][3]['$'].value
console.log("myArr["+index+"] ["+ myArr[index][4]['$'].name+ "] = "+myArr[index][4]['$'].value)
jsonObj.step_description = myArr[index][4]['$'].value
myJsonArr.push(jsonObj)
}
>> node myStepTool.js[
{
"stepNumber": 0,
"step_name_locid": "stepName_2728332481823371952_2",
"step_name": "Assemble",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 1,
"step_name_locid": "stepName_5894254086109201976_2",
"step_name": "Step 1",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 2,
"step_name_locid": "stepName_15897802472779891525_2",
"step_name": "Step 2",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 3,
"step_name_locid": "stepName_4089111003020719364_2",
"step_name": "Step 3",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 4,
"step_name_locid": "stepName_1444424151131004256_2",
"step_name": "Step 4",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 5,
"step_name_locid": "stepName_16935999301123799101_2",
"step_name": "Step 5",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 6,
"step_name_locid": "stepName_4549226109679838932_2",
"step_name": "Step 6",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 7,
"step_name_locid": "stepName_11110415484410389698_2",
"step_name": "Step 7",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 8,
"step_name_locid": "stepName_11227030841165917496_2",
"step_name": "Step 8",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 9,
"step_name_locid": "stepName_307606632875771006_2",
"step_name": "Step 9",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 10,
"step_name_locid": "stepName_5267734679139784604_2",
"step_name": "Step 10",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 11,
"step_name_locid": "stepName_18093258235493727066_2",
"step_name": "Step 11",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 12,
"step_name_locid": "stepName_8642537011799624768_2",
"step_name": "Step 12",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 13,
"step_name_locid": "stepName_9423943722212754853_2",
"step_name": "Step 13",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 14,
"step_name_locid": "stepName_6512444656035031150_2",
"step_name": "Step 14",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 15,
"step_name_locid": "stepName_14841759718657189243_2",
"step_name": "Step 15",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
},
{
"stepNumber": 16,
"step_name_locid": "stepName_7345189520540227377_2",
"step_name": "Step 16",
"step_acknowledge": "false",
"step_description_locid": "",
"step_description": ""
}
]Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.