Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Is there any way to add parameters to multiple files at the same time or some way to automate it?
Currently I am working on Creo 3.0 & Intralink.
You can use ModelCheck or DBatch - but those are a bit painful to setup and debug (in my opinion).
IF you want a quick solution - use CREOSON
Here is a code example (slightly modified) from the PlayGround in CREOSON that creates/sets the same parameter across all prt files in session using a wildcard (e.g. *.prt) . -- you can do the same for assemblies and drawings just change the wildcard extension.
let paramObj = new creo.ParameterObj();
paramObj.file = '*.prt'; // <<-- ENTER CREO FILE and EXTENSION (can be wildcard)
paramObj.name = 'NEW_PARAM' // Parameter 'name'
paramObj.value = 'HELLO!' // Parameter 'value'
paramObj.set();
If you want to do the same for ALL Parts in a Working Directory by loading each model into memory one at a time.... you can do something like this (modified from the sample code in the CREOSON PlayGround):
function setParam(itemName) {
let paramObj = new creo.ParameterObj();
paramObj.file = itemName;
paramObj.name = 'NEW_PARAM';
paramObj.value = "WOW!";
return paramObj.set();
}
function processItem(itemName) {
let fileObj = new creo.FileObj();
fileObj.display = true;
fileObj.activate = true;
fileObj.file = itemName;
return fileObj.open()
.then((itemName) => {
return setParam(itemName)
});
}
function batchFiles () {
let creoObj = new creo.CreoObj();
let creosonUtilObj = new creo.CreosonUtils();
creoObj.filename = "*.prt"; // <<-- ENTER CREO FILE (*) and EXTENSION
creoObj.list_files()
.then(function (respObj) {
return creosonUtilObj.loopItems(respObj.filelist, processItem)
})
.then(function () {
alert("Finished Batching!");
})
.catch((err) => {
alert('ERROR: '+err);
});
}
// START THE BATCH PROCESS!
batchFiles();
Note the above code leave everything in session within Creo - so you would have to add a save operation after each update to be more complete.
Hope that helps!
Dave