Forum Discussion

lucas's avatar
lucas
Creator II
5 years ago

how to add classified part

hello, i need to load parts that are a kind of part from my classification and i'm struggling with how to write it. I've found different ways to do it but i haven't been able to make them work.

i need the part to be resistor class . i've tried this:  

var part = innovator.newItem("Part","add");
var part_xclass = part.createRelationship("Part_xClass","add");           
var partItem = part_xclass.createRelatedItem("xClass","get");
partItem.setProperty("name","/composants/passif/resistor"); and partItem.setProperty("name","resistor");

and this:


partItem = innovator.newItem("Part","add");
partItem.setProperty("classification","resistance");

and the following code to fill the xproperties of my class:


var val_resist =parts_to_add[0];                                                               parts_to_add is an array with the data i want to fill and it worked well for simple part import and bom import
partItem.setProperty("xp-valeur_resistance", val_resist);
partItem.setPropertyAttribute("xp-valeur_resistance","set","value");
var tol = parts_to_add[1];
partItem.setProperty("xp-tolerance", tol);
partItem.setPropertyAttribute("xp-tolerance","set","value");
var puiss = parts_to_add[2];
partItem.setProperty("xp-puissance", puiss);
partItem.setPropertyAttribute("xp-puissance","set","value");
var serie = parts_to_add[3];
partItem.setProperty("xp-serie", serie);
partItem.setPropertyAttribute("xp-serie","set","value");
var cms = parts_to_add[4];
partItem.setProperty("xp-cms", cms );
partItem.setPropertyAttribute("xp-cms","set","value");
var boitier = parts_to_add[5];
partItem.setProperty("xp-boitier", boitier);
partItem.setPropertyAttribute("xp-boitier","set","value");
var resultItem = partItem.apply();

when i run my code i have no error message and the code doesn't stop runnig at some point but no parts are created .

if you have any hints or solution i would be more than happy to know them.

Thanks lucas.

No RepliesBe the first to reply