Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: naxx on August 26, 2016, 11:34:11 pm
-
Hello,
How I can set my own GUID to element? Is it possible?
Thank
-
No (unless you go through the backdoor and issue an SQL update statement).
Why would you want that?
Geert
-
Thanks. I want set GUID to element, because I have XML file with GUIDs (that was parsed and imported to EA) and I want same element´s GUID.
-
Hi,
I would also like to set a GUID manually.
When I Import a CSV-File with (valid) GUID inside, the GUIDs where set to the new Elements.
So I consider there musst be a Method to give Input with GUIDs.
I tried to Import it by an script because i like to add a new Connector to existing Elements.
I also tried the "SQL Backdoor" Geert implied, but I got a warning about duplicate Elements.
I also tried the "normal" way to import with the buildin Sparx CSV importer, no Porblems with the GUIDs.
Here is the import function:
function OnRowImported()
{
rowCount++;
// get all values for this row
var reqName = CSVIGetColumnValueByName("Name");
var reqType = CSVIGetColumnValueByName("Type");
var reqGUID = CSVIGetColumnValueByName("GUID");
var reqNotes = CSVIGetColumnValueByName("Notes");
var reqAlias = CSVIGetColumnValueByName("Alias");
var reqStereotype = CSVIGetColumnValueByName("Stereotype");
var reqTagValue = CSVIGetColumnValueByName("TagValue");
var systemGUID = CSVIGetColumnValueByName("SystemGUID");
Session.Output(" Importing: " + reqName + "." + reqGUID);
targetPackage = Repository.GetTreeSelectedPackage();
requirement = targetPackage.Elements.AddNew (reqName, reqType);
// requirement.ElementGUID = "{"+reqGUID+"}";
requirement.Notes = reqNotes;
requirement.Stereotype = reqStereotype;
requirement.Alias = reqAlias;
tag = requirement.TaggedValues.AddNew ("Funktional/NichtFunktional",reqTagValue);
tag.Update;
requirement.Update();
SQL = "UPDATE `t_object`"+
"SET `ea_guid`='{"+reqGUID+"}'"+
"WHERE `Object_ID`="+requirement.ElementID+";"
Repository.Execute(SQL);
}
May someone got a hint for me
regards Benny
[edit] HAHA never Mind I really got double GUID in the CSV-file (because of a N-N dependency for the System Elements... :o
So it work fine with the SQL Update :D