Author Topic: Python COM AddNew Class and Image  (Read 9974 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Python COM AddNew Class and Image
« Reply #15 on: March 16, 2022, 01:54:55 am »
You have to pass a single string to Repository.Execute, so more like:

Code: [Select]
repo.Execute("INSERT INTO T_DOCUMENT (BINCONTENT) VALUES (image_bytes)")
Geert

Okay I managed to create an entry in the t_document with my image.
But I struggle to link the document entry to a diagram. Any ideas? I tried to add an entry to diagram.DiagramObjects collection but it doesn't work.

FSXManu
What isn't working? That is exactly what you need to do.

Geert

FSXManu

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Python COM AddNew Class and Image
« Reply #16 on: March 22, 2022, 07:25:10 pm »

What isn't working? That is exactly what you need to do.

Geert

So now most things are fine. I got the Image Artifact in EA. The problem is when I open the Image in EA with double click it says it cannot open it because it's corrupted. But when I look at it in the db it's fine. I think the problem is that the Image is in the t_image table and needs a correct ImageID. I just couldn't figure out how to get the correct ImageID and that this needs to be created by EA or sth. Do you know anything about the ImageID in the t_image table?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Python COM AddNew Class and Image
« Reply #17 on: March 22, 2022, 11:22:13 pm »
I don't think there's anything special about the imageID, it's an Identity column in SQL server, so it gets a new ID automatically, you only need to insert name, type and image.
Have you tried copying the values from another t_image record?
I'm guessing there's still something wrong with the value in t_image.image

Geert

FSXManu

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Python COM AddNew Class and Image
« Reply #18 on: March 24, 2022, 12:14:46 am »
I don't think there's anything special about the imageID, it's an Identity column in SQL server, so it gets a new ID automatically, you only need to insert name, type and image.
Have you tried copying the values from another t_image record?
I'm guessing there's still something wrong with the value in t_image.image

Geert

Could be something wrong with the t_imga.image yes. I'm still investigating that. Since I have to create the record with SQL I also have to pass an ImageID since it doesn't get generated. This is primarily that the Image Manager recognises it afaik.


FSXManu

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Python COM AddNew Class and Image
« Reply #19 on: April 01, 2022, 05:56:55 pm »
I don't think there's anything special about the imageID, it's an Identity column in SQL server, so it gets a new ID automatically, you only need to insert name, type and image.
Have you tried copying the values from another t_image record?
I'm guessing there's still something wrong with the value in t_image.image

Geert

Okay so I think the t_image entry is fine since that is the entry for the image manager and it shows up just fine there. On the other hand in the t_document table where it's needed to be an artifact and diagram object it's not showing correctly. Even though I took the t_image.image value and put it into t_document.bincontent withoug modifying it. What should go into the BINCONTENT column?

FSXManu

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Python COM AddNew Class and Image
« Reply #20 on: April 01, 2022, 07:53:46 pm »
Okay so I think the t_image entry is fine since that is the entry for the image manager and it shows up just fine there. On the other hand in the t_document table where it's needed to be an artifact and diagram object it's not showing correctly. Even though I took the t_image.image value and put it into t_document.bincontent withoug modifying it. What should go into the BINCONTENT column?

FSXManu
You shouldn't assume the format of t_image.image is going to be the same as the format of t_document.bincontent

The easiest way to figure out what needs to be done is doing it manually though the GUI first.
Then replicate the results using the API untill you have exactly the same info in the bincontent field.

Geert

FSXManu

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Python COM AddNew Class and Image
« Reply #21 on: April 11, 2022, 06:04:59 pm »
You shouldn't assume the format of t_image.image is going to be the same as the format of t_document.bincontent

The easiest way to figure out what needs to be done is doing it manually though the GUI first.
Then replicate the results using the API untill you have exactly the same info in the bincontent field.

Geert

Yes I managed to make it work. I can import into the T_Image table via the importreferencedata command from the API. I just need to create an xml with the image first. This all worked pretty good. But since last Friday when I import the xml via this importreferencedata command in the code, it only creates one image and overwrites it with the next one so if I import an xml with 10 images in it there will be only one image in the table with the content of the last image. Even when I try it with the code that was working a week before I have the problem. Did you ever came accross this issue?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Python COM AddNew Class and Image
« Reply #22 on: April 11, 2022, 06:51:29 pm »
I'm guessing your xml contains an error. Maybe they all have the same identifier?

Geert