Hi Navid,
I can share my script that creates copy of component in the active document. There is also Matrix3D.translation and it works as expected. So you can use it for your propose.
It modifies translation matrix by setCell method
trans.setCell(0, 3, 15.0);
Regards
Jan (Autodesk Fusion 360 team)
//Author-JP
//Description-tocite schody
function run(context) {
"use strict";
if (adsk.debug === true) {
/*jslint debug: true*/
debugger;
/*jslint debug: false*/
}
var ui;
try {
var app = adsk.core.Application.get();
ui = app.userInterface;
var product = app.activeProduct;
var design = adsk.fusion.Design(product);
if (!design) {
ui.messageBox('No active Fusion design', 'No Design');
return;
}
// Get the root component of the active design.
var rootComp = design.rootComponent;
var occs = rootComp.allOccurrences;
// Gather information about each unique component
var count = occs.count;
ui.messageBox(count.toString(), 'pocet');
//jmena vsech component
var i;
for (i = 0;i < count;++i) {
var comp = occs.item(i).component;
ui.messageBox(comp.name, 'jmeno');
}
//var comp = occs.item(0).component;
//var jmeno = comp.name
//ui.messageBox(jmeno,'jmeno');
// Create a new occurrence.
var trans = adsk.core.Matrix3D.create();
//var occ = rootComp.occurrences.addNewComponent(trans);
// Get the associated component.
//var newComp = occs.item(i).component;
//var newComp = occ.component;
// Create a new occurrence for the component, offset by 15 cm in the X direction.
trans.setCell(0, 3, 15.0);
var newOcc = rootComp.occurrences.addExistingComponent(occs.item(0).component, trans);
//ui.messageBox('Hello script');
}
catch (e) {
if (ui) {
ui.messageBox('Failed : ' + (e.description ? e.description : e));
}
}
adsk.terminate();
}