Book a Demo

Author Topic: AddNew returns Error  (Read 4192 times)

DmitriyKnyazhin

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • Sorry for that
    • View Profile
AddNew returns Error
« on: October 22, 2007, 11:59:50 pm »
I'v tried to add new constraint into the attribute of the class.
new_constr := attr.Constraints.AddNew('test','test') as IDualConstraint;

I could't add. According official information after built 814 this error was exaust. I have built 817 but error still here.
Can anybody help me?
« Last Edit: October 23, 2007, 03:56:28 pm by DmitriyKnyazhin »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: AddNew return Error
« Reply #1 on: October 23, 2007, 01:43:01 am »
Try this with different parameter values. Also, try using a constraint object instead of the interface type.

Does this make any difference?
No, you can't have it!

DmitriyKnyazhin

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • Sorry for that
    • View Profile
Re: AddNew return Error
« Reply #2 on: October 23, 2007, 03:52:26 pm »
Thanks for your help.

As I can understand You suggest something like this
cn: Constraint;
cn := a.constraints.addnew('<123','Precision') as Constraint;
or
idst: IDispatch;
idsp := a.constraints.addnew('<123','Precision');
cn := (idsp as Attribute).constraints.addnew('<123','Precision') as Constraint;
I'v try replace Attribute object interface with Element interface
cn := (idsp as Element).constraints.addnew('<123','Precision') as Constraint;
But I'v got the same result. All attemts led to error EIntfCastError 'Interface not supported'.

I get parameters from UserGuide manual Code Sample Chapter.

As I can see method AddNew returns IDispatch object, and I have to use correct type of the variable (IDualConstraint, Constraint, IDispatch). Is it correct.

What should I do to use object type instead interface?
And thanks for your help again.



lhyabcd

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: AddNew return Error
« Reply #3 on: March 10, 2008, 05:14:11 pm »
Please try the following code:

EA.ConnectorConstraint connectorConstraint = (EA.ConnectorConstraint)con.Constraints.AddNew("constraint2", "type");
if (!connectorConstraint.Update())
 {
     MessageBox.Show(connectorConstraint.GetLastError());
  }


By the way ,the connector tagged value work in sam way:
EA.ConnectorTag connectorTag = (EA.ConnectorTag)con.TaggedValues.AddNew("Tag", "Value");
if (!connectorTag.Update())
{
      MessageBox.Show(connectorTag.GetLastError());
 }
« Last Edit: March 10, 2008, 05:40:09 pm by lhyabcd »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: AddNew returns Error
« Reply #4 on: March 10, 2008, 09:37:01 pm »
That's it all right. Connectors have their own collections for a few things. If you don't use the correct collection your method calls will not return a value. [Or sometimes will throw an error, but not always.]

There are a few such cases, and they are not clearly documented. The information is all in the documentation, and in a fairly consistent form, but it is not gathered together where it is obvious. You pretty much have to read through all the sections to find them all. [Sort of like an encyclopedia that requires you to read the entire contents to find each single item.]

Spotters hint: Look for some of these in the Element Features section of the SDK.

Still, I have high hopes for improvement. Roy and crew are making great progress in cleaning up the docs. To date most of the effort has been directed towards correcting outright mistakes, or making global improvements. But they will get to these things.

David
No, you can't have it!