Book a Demo

Author Topic: Add an Attribute using Delphi  (Read 3859 times)

cvg

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Add an Attribute using Delphi
« on: June 27, 2010, 09:59:11 am »
Hi there,  Can you help?  I'm not progressing far in my attempts to add a new attribute to a class using Automation with Delphi.  I'm able to access my model and peruse it.  I can obtain the class I want to use but I can't figure out how to add an attribute.  Here is a snipet of my code - what am I doing wrong?

procedure TForm1.GetClassClick(Sender: TObject);
var
  IDC: IDualCollection;
  IDE: IDualElement;
begin
   IDC:= Repository1.Models;  //use an IDualCollection
   IDE:=  Repository1.GetElementByID(107);
   //create an attribute
   IDE.Attributes.AddNew('newAttribute','string');
   // save it
   if NOT IDE.Update() then Memo1.Lines.Add('error');
   IDE.Attributes.Refresh;
end;

Many thanks.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Add an Attribute using Delphi
« Reply #1 on: June 28, 2010, 04:39:17 pm »
Try
Code: [Select]
IDE.Attributes.AddNew('newAttribute','Attribute')
Geert

cvg

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Add an Attribute using Delphi
« Reply #2 on: June 28, 2010, 11:19:32 pm »
Thanks Geert.
At long last I think I'm getting the hang of using Delphi and the Automation Interface.
 ;D ;D