Author Topic: Not able to Create Part Property using C#  (Read 1839 times)

nikunj-dhamecha

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Not able to Create Part Property using C#
« on: February 21, 2023, 04:49:55 pm »
Hello Everyone,

I am trying to create parts on the blocks using C# API, I am using EA 16! Like we create Composition to Part or Aggregation to Part in the Application, I am trying to create the same using C# API. So far, I am able to create Part with the exact traceability if we compare!
The problem I am facing is if I create Part in the application, I am finding some entries in t_xref table which gives some more information about the parts created! And same part if created from C# API, the t_xref table doesn't show anything with respect to Parts created!
Below is the code I am using for creating Part:
Code: [Select]
EA.Connector connector = source.Connectors.AddNew("Aggregation", "Aggregation");
connector.SupplierID = source.ElementID;
connector.ClientID = target.ElementID;
connector.Direction = AddinConstants.Connector.DirectionSrcDest;
connector.SupplierEnd.Aggregation = 2;//if Composition to Part otherwise 1
connector.Update();

Am I missing out some steps here which adds entry to t_xref table? Do I have to set some more properties here?
Thanks in Advance!



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Not able to Create Part Property using C#
« Reply #1 on: February 21, 2023, 06:20:44 pm »
What exactly are you missing?

t_xref is a bit of a garbage bin with all kinds of stuff that doesn't really fit anywhere else.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Not able to Create Part Property using C#
« Reply #2 on: February 21, 2023, 09:20:32 pm »
If you use the API you do not have to care what the DB tables contain!

q.

nikunj-dhamecha

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Not able to Create Part Property using C#
« Reply #3 on: February 21, 2023, 09:33:39 pm »
Actually I want the info stored inside t_xref table:

When I create part relation among 3 blocks,
one Composition bewtween two blocks and one Aggregation between two blocks, it adds 2 entries in the table, specially in the description column of t_xref table with the Property Name: _connetorRef and _isReference. I am using these property names for a specific purpose.

For the creation of part, if we create it from UI directly, we have only 2 options for creation.
1.Composition to Part
2.Aggregation to Part

These two leaves some kind of text on the block with the Aggregation relation (Connector)!
If Composition to Part is used, then it shows parts on the block with the part and if Aggregation to Part is used, then it shows references on the block with the part. But this doesn't happen when I try to create part with C#API! After searching in the different tables, I found the _isReference Property present in Description column of t_xref table has one specific value which is either 0 or -1, gives us the idea about that text.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Not able to Create Part Property using C#
« Reply #4 on: February 21, 2023, 09:49:35 pm »
connector.SupplierEnd probably needs a .update

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Not able to Create Part Property using C#
« Reply #5 on: February 21, 2023, 10:48:34 pm »
You could try if EA.Connector.CustomProperties does anything.

Geert

nikunj-dhamecha

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Not able to Create Part Property using C#
« Reply #6 on: February 22, 2023, 08:03:18 pm »
Updating CustomProerties worked!
After checking the CustomProperties on the created Parts, found "isReference".
Thanks for the help !:)