Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: nikunj-dhamecha on February 21, 2023, 04:49:55 pm

Title: Not able to Create Part Property using C#
Post by: nikunj-dhamecha 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!


Title: Re: Not able to Create Part Property using C#
Post by: Geert Bellekens 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
Title: Re: Not able to Create Part Property using C#
Post by: qwerty 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.
Title: Re: Not able to Create Part Property using C#
Post by: nikunj-dhamecha 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.
Title: Re: Not able to Create Part Property using C#
Post by: qwerty on February 21, 2023, 09:49:35 pm
connector.SupplierEnd probably needs a .update

q.
Title: Re: Not able to Create Part Property using C#
Post by: Geert Bellekens on February 21, 2023, 10:48:34 pm
You could try if EA.Connector.CustomProperties does anything.

Geert
Title: Re: Not able to Create Part Property using C#
Post by: nikunj-dhamecha 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 !:)