console.log("Version cv_dalno 14-02-2022.js ver-5");
window.constructorConverters = [
{
name: "export to ORD",
mimeType: "application/txt",
extension: ".ord",
convert: function (data)
{
//copy_to .js file-------------------
let result_string = "";
const SOFFIT = 222;
const THICK = 100;
const VAULT_HEIGHT = 1219.200;
const CATALOG_NAME = "CREATOR.cvc";
let roomX = data.plan?.room?.dimensions?.x;
let roomY = data.plan?.room?.dimensions?.z;
let roomZ = data.plan?.room?.dimensions?.y;
let additional_height = 0;
let door_types = new Map();
door_types.set("LAMINAT LASER", "LASER");
door_types.set("LAV ERERMATT","TEXTURA");
door_types.set("AKRYLAT", "LASER");
door_types.set("LAMINAT", "TEXTURA");
door_types.set("LAK LESK", "TEXTURA");
door_types.set("DYHA", "TEXTURA");
door_types.set("FOLIA", "TEXTURA");
door_types.set("NANOTEQ MATT", "LASER");
let textures = new Map();
textures.set("Vertical", "ZVISLA");
textures.set("Horizontal", "VODOROVNA");
function WriteSection(name)
{
result_string += `[${name}]\r\n`;
}
function NewLine()
{
return result_string += "\r\n";
}
function WritePropsNamed(name, values)
{
result_string += `${name}=` + ValuesToString(values);
NewLine();
}
function WriteProps(values)
{
result_string += ValuesToString(values);
NewLine();
}
function FormatPropetyValue(x)
{
if(x == null)
return "";
switch(typeof(x))
{
case 'string':
return "\"" + x + "\"";
case 'number':
return x;
case 'boolean':
return x ? "1" : "0";
}
return "";
}
function ValuesToString(values)
{
var str = "";
if(values instanceof Array)
{
values.forEach(function(val){
str += FormatPropetyValue(val) + ",";
});
str = str.slice(0, -1);
}
else
{
str += FormatPropetyValue(values);
}
return str;
}
function IfDef(obj, str)
{
return (obj != undefined ? obj : str);
}
function getTimestamp()
{
var dt = new Date();
function pad(n)
{
return n < 10 ? '0' + n : n;
}
return pad(dt.getDate()) + "." + pad(dt.getMonth()+1) + "." + dt.getFullYear() +
" " + pad(dt.getHours()) + ":" + pad(dt.getMinutes()) + ":" + pad(dt.getSeconds());
}
function WriteHeader(data)
{
WriteSection("Link");
WritePropsNamed("PocketPCPath", "");
WritePropsNamed("PCPath", "");
WritePropsNamed("PCDate", "");
WritePropsNamed("CreateBy", "PRODBOARD");
NewLine();
WriteSection("Header");
WritePropsNamed("Version", 4);
WritePropsNamed("Unit", 1);
WritePropsNamed("Name", data?.number); // project number
WritePropsNamed("Description", data?.url);
WritePropsNamed("PurchaseOrder", data?.number);
WritePropsNamed("Comment", "");
WritePropsNamed("Customer", data?.customer?.name);
WritePropsNamed("Contact", "");
WritePropsNamed("Address1", "");
WritePropsNamed("Address2", "");
WritePropsNamed("City", "");
WritePropsNamed("State", "");
WritePropsNamed("Zip", "");
WritePropsNamed("Phone", data?.customer?.phone);
WritePropsNamed("Fax", "");
WritePropsNamed("Mobile", "");
WritePropsNamed("EMail", data?.customer?.email);
WritePropsNamed("ShipToComment", "");
WritePropsNamed("ShipToCustomer", "");
WritePropsNamed("ShipToContact", "");
WritePropsNamed("ShipToAddress1", "");
WritePropsNamed("ShipToAddress2", "");
WritePropsNamed("ShipToCity", "");
WritePropsNamed("ShipToState", "");
WritePropsNamed("ShipToZip", "");
WritePropsNamed("ShipToPhone", "");
WritePropsNamed("ShipToFax", "");
WritePropsNamed("ShipToMobile", "");
WritePropsNamed("ShipToEMail", "");
WritePropsNamed("BaseDoors", ["TEXTURA VODOROVNA","Biela ST","","","","","Door",""]);
WritePropsNamed("WallDoors", ["TEXTURA VODOROVNA","Biela ST","","","","","Door",""]);
WritePropsNamed("DrawerFront", ["TEXTURA VODOROVNA","Biela ST","","","","","Door",""]);
WritePropsNamed("BaseEndPanels", ["TEXTURA VODOROVNA","Biela ST","","","","","Door",""]);
WritePropsNamed("WallEndPanels", ["TEXTURA VODOROVNA","Biela ST","","","","","Door",""]);
WritePropsNamed("TallEndPanels", ["TEXTURA VODOROVNA","Biela ST","","","","","Door",""]);
WritePropsNamed("CabinetConstruction", "DZada vlozene-PVDVFALOS10");
WritePropsNamed("DrawerBoxConstruction", "Hettich InnoTech Drawer");
WritePropsNamed("RollOutConstruction", "Hettich InnoTech Int Adv");
WritePropsNamed("BaseCabinetMaterials", "Biela ST");
WritePropsNamed("WallCabinetMaterials", "Biela ST");
WritePropsNamed("BaseExposedCabinetMaterials", "Biela ST");
WritePropsNamed("WallExposedCabinetMaterials", "Biela ST");
WritePropsNamed("DrawerBoxMaterials", "HETTICH BIELA");
WritePropsNamed("RollOutMaterials", "HETTICH BIELA");
WritePropsNamed("PullMaterials", "Knobka");
WritePropsNamed("HingeMaterials", "Blum ClipTop W5 Screwon");
WritePropsNamed("GuideMaterials", "Hett Inno White Qdro V6 30kg");
WritePropsNamed("ClosetBaseDoors", "");
WritePropsNamed("ClosetWallDoors", "");
WritePropsNamed("ClosetDrawerFront", "");
WritePropsNamed("ClosetBaseEndPanels", "");
WritePropsNamed("ClosetWallEndPanels", "");
WritePropsNamed("ClosetTallEndPanels", "");
WritePropsNamed("ClosetCabinetConstruction", "");
WritePropsNamed("ClosetDrawerBoxConstruction", "");
WritePropsNamed("ClosetRollOutConstruction", "");
WritePropsNamed("ClosetMaterials", "");
WritePropsNamed("ClosetDrawerBoxMaterials", "");
WritePropsNamed("ClosetRollOutMaterials", "");
WritePropsNamed("ClosetPullMaterials", "");
WritePropsNamed("ClosetGuideMaterials", "");
WritePropsNamed("ClosetWireBasketMaterials", "");
WritePropsNamed("ClosetRodMaterials", "");
WritePropsNamed("ClosetHingeMaterials", "");
WritePropsNamed("InteriorFinish", "");
WritePropsNamed("ExteriorFinish", "");
NewLine();
}
function WriteWalls(data)
{
WriteSection("Walls");
//WriteWall(startX, startY, angle, length, height, index)
WriteWall(0, roomY, 90, roomY, roomZ, 1);
WriteWall(0, 0, 0, roomX, roomZ, 2);
WriteWall(roomX, 0, -90, roomY, roomZ, 3);
WriteWall(roomX, roomY, -180, roomX, roomZ, 4);
NewLine();
}
function WriteWall(x, z, direction, length, height, index)
{
WriteProps(
//1 Float Wall X Position
[x,
//2 Float Wall Z Position
z,
//3 Float Wall Direction
direction,
//4 Float Wall Length
length,
//5 Float Wall Height
height,
//6 Float Wall Thickness
THICK,
//7 Integer Wall Number (1 based) Empty = Line Count
null,
/*
8 Integer Wall Type
* 1 = Exterior Wall
2 = Interior Wall ('T' Wall or extra Wall)
3 = Peninsula or Island Wall
4 = Radius Wall*/
2,
//9 String Left Wall Number (0 or Empty => No Wall Attached)
/*The format for the "Left Wall Number" field is #-x where x:
can be empty, or E to indicate the Wall is continued from Wall #, e,g., 3 or 3-E
F to indicate the Wall is attached to the front of the Wall #, e.g., 3-F
B to indicate the Wall is attached to the back of the Wall #, e.g., 3-B*/
null,
//10 Float Wall Radius
null,
//11 Integer Rotation of the Radius Wall (0 = CW, 1 = CCW)
null,
//12 Float Arc Angle for the Radius Wall
null,
//13 Integer Wall ID
index,
//14 String Modify Code
"S"]
);
}
function WriteCatalog(item)
{
WriteSection("Catalog");
WritePropsNamed("Name", CATALOG_NAME);
let construction = item.item.items.find(el => el.code === "CabinetConstruction");
WritePropsNamed("CabinetConstruction", construction?.value ? construction.value : "DZada vlozene-PVDVFALOS10");
//Doors for each cabinet
if(item.item.cv_type = "module")
{
let primary_material = item.item.options.find(el => el.code === "main_materials")?.value?.material?.primary?.code;
if(primary_material)
{
WritePropsNamed("Materials", primary_material);
}
let door_props;
let door = item.item.options.find(el => el.code === "doors_module");
let inline_door = item.item.inline?.find(el => el.item.code === "door");
let cv_vitrine = inline_door?.item.inline?.find(el => el.item.code === "door_vitrine")?.item?.items?.find(el => el.code === "cv_vitrine");
if(door)
{
let door_decor_code = door.value?.doors?.decor?.code;
let orientation = door.value?.doors?.texture_orientation.name;
let door_type = door.value?.name;
let prof_ind = door_type.indexOf(' PROFIL')
if(prof_ind > -1)
{
door_type = door_type.substring(0, prof_ind);
}
door_props = [door_types.get(door_type) + " " + textures.get(orientation), door_decor_code, "","","","","Door",""];
let pull = door.value?.options?.pullmaterials;
if(pull != undefined)
{
WritePropsNamed("PullMaterials", pull);
}
}
if(cv_vitrine && cv_vitrine.value.length > 1)
{
door_props = [cv_vitrine.value[0], cv_vitrine.value[1], "","","","","Door",""];
}
if(door_props)
{
WritePropsNamed("BaseDoors", door_props);
WritePropsNamed("WallDoors", door_props);
WritePropsNamed("DrawerFront", door_props);
WritePropsNamed("BaseEndPanels", door_props);
WritePropsNamed("WallEndPanels", door_props);
WritePropsNamed("TallEndPanels", door_props);
}
let drawers = item.item.items.find(el => el.code === "cv_drawers");
if(drawers)
{
WritePropsNamed("DrawerBoxMaterials", drawers.value?.DrawerBoxMaterials);
WritePropsNamed("GuideMaterials", drawers.value?.GuideMaterials);
WritePropsNamed("DrawerBoxConstruction", drawers.value?.DrawerBoxConstruction);
}
let inner_drawers = item.item.items.find(el => el.code === "cv_drawer_inners");
if(inner_drawers)
{
WritePropsNamed("RollOutMaterials", inner_drawers.value?.RollOutMaterials);
WritePropsNamed("RollOutConstruction", inner_drawers.value?.RollOutConstruction);
}
let hinges = item.item.options.find(el => el.code === "hinges");
if(hinges)
{
WritePropsNamed("HingeMaterials", "HETTICH 110В° NALOZENY");
}
}
NewLine();
}
function WriteParameters(item)
{
WriteSection("Parameters");
WritePropsNamed("Attribute", ["1) Spoje skrinka","APPLY_HW_CAB","int",1,"0\) Ano=1|1) Ne=0|2) Reset=2"]);
WritePropsNamed("Attribute",["AUTO poloha zasuviek","Poloha_zasuviek","bool",1]);
WritePropsNamed("Attribute",["Pred znaГЁenie?","Predznacenie","bool",1]);
WritePropsNamed("Attribute",["B-ZГЃDA TYP","MAKEDADO","int",0,"1-DRГЃЕЅKA=0|2-VSAZENГЃ=1|3-NIC=2"]);
WritePropsNamed("Attribute",["C-DRÁŽKU ZAD FRÉZOVAT?","Cab_FRD","bool",0]);
WritePropsNamed("Attribute",["Pouzit bublinky:","DALNO_BUBLINKY","bool",1]);
WritePropsNamed("Attribute",["Zvacsit dvierka?","Zvacsit_dvierka","bool",0]);
WritePropsNamed("Attribute",["Plytsie dno o 22mm?","Hlbka_dna","bool",0]);
WritePropsNamed("Note",["Material dvierok 1:","Material_dvierok1","meas","Cab.Face.DOR_OPEN@1.DOR.S_DSLAB._M:MatID"]);
WritePropsNamed("Note",["Material olepenia dvierok 1:","Mat_dv_olep1","int","Cab.Face.DOR_OPEN@1.DOR.S_DSLAB.DBAND._M:MatID"]);
WritePropsNamed("Attribute",["Olepenie refres?","AUTOMATIKA_SKR","int",1,"1)AUTO=1|2)Refresh=2|3)NIE! Refresh=3"]);
// WritePropsNamed("Attribute",["VZPERA 1 SAT SKRINA?","Pridat_VZPERA_OLEP","bool",0]);
// WritePropsNamed("Attribute",["VZPERA 2 SAT SKRINA?","Pridat_VZPERA2_OLEP","bool",0]);
WritePropsNamed("Attribute",["ATYP_OPERACIA_SKRINKA","ATYP_OPER_SKRINKA","text",""]);
WritePropsNamed("Attribute",["PolicovГ© kovanie:","Policove_kovanie","int",0,"0, NIC=0|1, IF-K-Line=1|2, Maori=2|3, Unico=3|4, Flipper=4|5, Tab 15=5|6, ME05=6"]);
WritePropsNamed("Attribute",["A-SPOJE TYP","UCS_3DHWcabinet","int",1,"2-KOLIKY=1|1-K_Excenter=2|3-K_Excenter VB36=5|4-K_Excenter VB35=3|5-IBA KOLIKY=6|6-IBA KOLIKY_priebezne=9|7-K_Excenter_priebezny=10|0-NIC=0"]);
let left_side_depth = 0;
let right_side_depth = 0;
let lsd = item.item.options.find(el => el.code === "left_side");
let rsd = item.item.options.find(el => el.code === "right_side");
if(lsd && lsd.value?.options?.left_end_depth)
{
left_side_depth = lsd.value.options.left_end_depth;
}
if(rsd && rsd.value?.options?.right_end_depth)
{
right_side_depth = rsd.value.options.right_end_depth;
}
////write items attribute
let attr = item.item.items.find(el => el.code === "cv_attributes");
if(attr)
{
attr.items.forEach(function (itm)
{
if(itm.value.length > 0)
{
WritePropsNamed("Attribute", itm.value)
}
});
}
///////
////// write inline items attribute
item.item.inline.forEach(function (itm)
{
if(itm.item.items)
{
let attr = itm.item.items.find(el => el.code === "cv_attributes");
if(attr)
{
attr.items.forEach(function (itm)
{
WritePropsNamed("Attribute", itm.value)
});
}
}
});
//////////
WritePropsNamed("Attribute",["UPR1.01 PREDLZ PRAVY BOK?","Pridat_predlz_bok_P","meas",right_side_depth + "mm"]);
WritePropsNamed("Attribute",["UPR1.02 PREDLZ LAVY BOK?","Pridat_predlz_bok_L","meas", left_side_depth + "mm"]);
WritePropsNamed("Attribute",["UPR1.03 POLOHA CHRBTA?","Pridat_POLOHA_CHRBTA","meas","0mm"]);
WritePropsNamed("Note",["Cislo_skrinky","Cislo_skrinky","int", item.item.index]);
NewLine();
}
function WriteCabinets(data)
{
data?.plan?.items.forEach(function addKitchenItem(item)
{
switch(item.item.cv_type)
{
case "worktop":
case "plinth":
break;
case "module":
switch(item.item.m_class)
{
case "Base":
case "Tall":
additional_height = 100;
//schedules = "BaseMaterialSchedules";
break;
case "Wall":
additional_height = 0;
//schedules = "UpperMaterialSchedules";
break;
}
break;
}
WriteCatalog(item);
WriteParameters(item);
WriteCabinet(item);
NewLine();
});
}
function WriteCabinet(item)
{
WriteSection("Cabinets");
let offsetX = 0;
let offsetY = 0;
let wallNum = 1;
let width = item.item.dimensions.x;
let height = item.item.dimensions.y;
let depth = item.item.dimensions.z;
let centerX = item.position.center.x;
let centerY = item.position.center.y;
let centerZ = item.position.center.z;
let pos_x = 0;
let pos_y = centerY - height/2 - additional_height; //doesn't depend on wall number
let pos_z = 0;
let cab_type_index = item.item.cabinet_cv_type;
function setPlace(x, y, n)
{
offsetX = x;
offsetY = y;
wallNum = n;
}
if(item?.position?.direction)
{
var directions = [item.position.direction.x, item.position.direction.y, item.position.direction.z];
var str = directions.join(",");
switch(str)
{
case "1,0,0": //x=0 y=0 z=1 //wall 1
setPlace(0, roomY, 1);
pos_x = offsetY - centerZ - width/2;
pos_z = centerX - depth/2;
break;
case "0,0,1": //wall 2
setPlace(0, 0, 2);
pos_x = centerX - width/2;
pos_z = centerZ - depth/2;
break;
case "-1,0,0": //wall 3
setPlace(roomX, 0, 3);
pos_x = centerZ - width/2;
pos_z = offsetX - centerX - depth/2;
break;
case "0,0,-1": //wall4
setPlace(roomX, roomY, 4);
pos_x = offsetX - centerX - width/2;
pos_z = offsetY - centerZ - depth/2;
break;
}
}
let orientation = "";
let orient = item.item.options.find(el => el.code === "orientation");
if(orient)
{
orientation = orient.value.orientation.code.toUpperCase();
}
else if(item.item.cv_orientation != undefined)
{
orientation = item.item.cv_orientation.toUpperCase();
}
else
{
orientation = "*";
}
let ENDINGS =
{
NONE: "N",
LEFT: "L",
RIGHT: "R",
BOTH: "B"
};
let cab_endings = ENDINGS.NONE;
let ps = item.item.options.find(el => el.code === "plinth_sides");
if(ps)
{
let isLeft = ps.value?.options?.plinth?.left != undefined;
let isRight = ps.value?.options?.plinth?.right != undefined;
cab_endings = isLeft ? (isRight ? ENDINGS.BOTH : ENDINGS.LEFT) : isRight ? ENDINGS.RIGHT : ENDINGS.NONE;
}
WriteProps(
[
// Float Order Entry Number (1 based)
item.item.index,
//2 String Cabinet's Catalog Nomenclature
item.item.code,
//3 Float Cabinet Width
width,
//4 Float Cabinet Height
height + additional_height,
//5 Float Cabinet Depth
depth,
//6 String Cabinet Hinging
orientation,
//7 Cabinet Endings
cab_endings,
//8 Integer Cabinet Quantity
//isWide ? 2 : 1,
1,
// 9 String Cabinet Comment
"", //specification.Comments,
//10 String Wall Number
/*The "Wall Number" field specifies the Wall
A plain number or #-F indicates the front face eg: 3 or 3-F
3-B indicates the back face eg:3-B
*/
wallNum + "-F",
//11 Float Offset from Wall start
pos_x,
//12 Float Distance from Floor
pos_y,
//13 Float Outset from Wall
pos_z,
//14 Integer Cabinet Type
cab_type_index,
//15 Integer Fill Mode
/*
0 = Placed
1 = Fill Top
2 = Fill Bottom
4 = Filled to left
8 = Filled to right*/
0,
//16 String Section Code (e.g., "3V-D=L-O-D=R")
"",
//17 String Cabinet ID - ID for CW or CV to identify
"",
//18 String Modify Code
/*The "Modify Code" field is:
S = Same (No change)
N = New
M = Modify
D = Delete
L = Allow to move or to delete only
X = Lock*/
"S"]);
}
WriteHeader(data);
WriteWalls(data);
WriteCabinets(data);
return result_string;
}
}
]