Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: thomaskilian on May 11, 2007, 02:33:19 pm
-
Help! It's probably simply too late, but since hours I try to add a default value for a new attribute. This is what I'm doing:
$class = $pk->Elements->AddNew ("newClass", "Class");
$class->Update();
$attr = $class->Attributes->AddNew ("newAttr", "int");
$attr->Default = "Default";
and that throws an exception saying that I'm not allowed to assign a value to $attr. Is is that something is wrong with the Perl interface or did I miss something?
-
A couple of Long shots here Thomas...
First, try calling $Attr.Update(); before trying to assign the default value.
Then...
My experience has been - regardless of what the documentation says - that whatever you provide in the Type field of AddNew becomes the data type of the Attribute (this behavior is different from most other EA collections). You've done this correctly.
However, since EA is aware of the Attribute data type, and since it is aware of the base type of the data, it might be evaluating what you provide. I wonder if you could assign a string to a different (i.e. not int) data type.
Please let me know what works.
David
-
Hi David,
putting Update in front did not help (I guess I alread tried that a 1000 times last night).
The Addnew uses the 2nd parm as type. At last I put the default in the type and shoveled it manually >:(
It seems I have to send a bug report. It's not possible to set anything once the attribute is created.
Thanks anyway :)
-
Mom always said there'd be those days...
Please let me know when this gets repaired. It could be a show stopper for me down the line a ways.
David
-
I reported it to the support. I'll post the result here...
-
Help! It's probably simply too late, but since hours I try to add a default value for a new attribute. This is what I'm doing:
$class = $pk->Elements->AddNew ("newClass", "Class");
$class->Update();
$attr = $class->Attributes->AddNew ("newAttr", "int");
$attr->Default = "Default";
and that throws an exception saying that I'm not allowed to assign a value to $attr. Is is that something is wrong with the Perl interface or did I miss something?
Sparx helped me out. Stupid me. Of course you have to write
$attr->{Default} = "Default";
I forgot the curly brackets when assigning a value to the attribute.
-
Yep, jest one a them days...