1
Automation Interface, Add-Ins and Tools / first script to place a component on a diagram
« on: January 10, 2025, 03:15:35 am »
Need some help with this JavaScript:
It should place a component in a component diagram, what it does. But something is wrong. The component cannot be selected and not be moved. Also the name is placed outside.
Any idea what I did wrong? My AI questions did not result in a solution.
If you like to see a stripped-down project for EA17 you may download the qeax file - testet with Firefox.
In package browser right-click on My Component package in the project/Detailed Design package and run the script add component to diagramm.
Thank you very mucn.
Code: [Select]
function addElToDiag( element, diagram ) {
var diagObj as EA.DiagramObject;
var r = false;
let posL = 100;
let posT = 100;
diagObj = diagram.DiagramObjects.AddNew("l=100;t=100;", "");
diagObj.Update();
if (diagObj) {
diagObj.ElementID = element.ElementID;
diagObj.right = diagObj.left +100;
diagObj.bottom = diagObj.top +60;
diagObj.Sequence = 1;
diagObj.SetStyleEx("Selectable","1");
diagObj.SetStyleEx("Moveable","1");
diagObj.Update();
diagram.DiagramObjects.Refresh();
diagram.Update();
Repository.SaveDiagram(diagram.DiagramID);
Repository.ReloadDiagram(diagram.DiagramID);
r = true;
}
return r;
It should place a component in a component diagram, what it does. But something is wrong. The component cannot be selected and not be moved. Also the name is placed outside.
Any idea what I did wrong? My AI questions did not result in a solution.
If you like to see a stripped-down project for EA17 you may download the qeax file - testet with Firefox.
In package browser right-click on My Component package in the project/Detailed Design package and run the script add component to diagramm.
Thank you very mucn.