Mass views exports

Thanks for this info Sophie
So, I have to raise a issue… solution in next version, the second may be?
For the moment I keep this extraction from csv then.
Thanks again
Best regards
Thierry

Hi Sophie,
New question: does exchange item elements have the same issue?
I’m trying to check whether the exchange item contains elements and if they are typed: currently with my csv process, I start from EI extraction, then I split in row on the elements (some have several) then split in column separated by colon to get elements and types… What would be the proper way to stick to this?
Thanks by advance
Regards
Thierry

Hello @Thierry_Poupon ,
Thank you for the creation of the issue.
You can get Exchange Item Elements from Exchange Item with get_owned_elements()

get_type() is also KO for Exchange Item elements :

Best regards

Sophie

Thanks Sophie
At the same time, I have found dir function, this gave me the expected spelling for attributes for EI and EIE, so I have now the elements, I’ll try for the types.
After this, I will need to get the collection type and, the class property type and the reference value. In my csv process, I expected that services need to connect to details, and then to signals. So I did not step further.

I have found it row 3474… Is it just this change, or is there any other changes below, since 3477 to … ?
I keep a copy of the orginal capella.py
Best regards
Thierry

Edit1: Trying to continue, I have managed to get attributes for enumeration, strings, but not for booleans, neither for numerical…
I just launched a try to get the list of numericals… I may need from that one (and other detail types) the literal values.
Edit 1bThe point is the class name for boolean (booleantype) and for numerical (numerictype) are not found.
Edit 2: What is the class name for Capella Classes?

Hello @Thierry_Poupon ,
Concerning the syntax, in this his extract of a demo (at 0:40) , you can see that you can have an overview of what is available in a class

It looks like some updates could be done in the specification model/simplified api:

  • To get the collection type, you can add to the class ‘Collection’ get_type():
    def get_type(self) :
    return capella_query_by_name(self, “Type”)
  • In the class DataValue, you can add get_value():
    def get_value(self):
    return self.get_java_object().getValue()

In addition of these modifications (and related issues I’ll create), I think some issue can be opened about booleanType and the reference value.

The class name of Capella Classes is Class (so it’s class Class in simplified api capella).
To get the class property type is OK

Best regards

Sophie

Many thanks Sophie
Still a question: none of the given you tubes have sound, unlike long webinars…
Is there any reason?
Best Regards
Thierry

Hi Sophie,
I added both items to simplified api (collection under class collection(datatype) r3679 and data value under class datavalue(javaobject) r3333:
my script runs with just the collection name but does not with type… it says:
“Cannot convert [<main.Class object at 0x000001F4143B2A08>] to Excel”
Does it need a second loop? Type is supposed to be unique I suppose…
Thanks for any support
Regards
Thierry
PS the previous line in the error text is:
“File “C:\Anaconda3\lib\site-packages\openpyxl\cell\cell.py”, line 222, in _bind_value
raise ValueError(“Cannot convert {0!r} to Excel”.format(value))”

Hello @Thierry_Poupon ,
It’s because the videos were commented during the webinar Python4Capella

Best regards,

Sophie

Hello,
It’s because it’s in list :

  • you can do a second loop as suggested
  • or use collection_type[0].get_name() with collection_type being the list above

Best regards

Sophie

Hi,
For collections, I did not put type in a loop as I thought it should be one item… and because then I need an object name… and this type can be another collection, a class or any kind of detail data: I did not solve this point yet.
For classes, I have a second loop for properties but I have the same message.

Script extract:

all_CLS=[]
all_CLS=se.get_all_contents_by_type(Class)
all_Pties=se.get_all_contents_by_type(property)

now retrieving capabilities and owned scenarios from model

i = 1
print(‘flag1’)
for elem_CLS in all_CLS:

i = i + 1

ClassProperties=elem_CLS.get_contained_properties()
for elem_Pties in ClassProperties:  
 
    i = i + 1  
    worksheet.cell(row = i, column = 1).value = elem_CLS.get_name()  
    worksheet.cell(row = i, column = 2).value = elem_CLS.get_contained_properties()

Console extract:
File “C:\Anaconda3\lib\site-packages\openpyxl\cell\cell.py”, line 222, in _bind_value
raise ValueError(“Cannot convert {0!r} to Excel”.format(value))
ValueError: Cannot convert <main.JavaList object at 0x0000022E51049288> to Excel

Many thanks for your time and your patience (very appreciated)
Best regards
Thierry

Edit1: PS: Is it possible to append together collection names; class names; detail data name (append PhQ; Num; Enum: Bool: Strg)?

@Sophie_Plazanet
Yess! My script for collections runs with the types…
Now I have to solve classes: "… ‘Property’ object has no attribute get.name()
I will need the names and the types (looks type will be easier for types if I read correctly the simplified api)…
Best regards
Thierry

Well done :+1:
To get name, you can use as an temporary alternative ’ get_java_object().getName() ’

For your other need, it’s possible

Best regards,

Sophie Plazanet

Hi
I tried guess this in the simplified api, under class property:

def get_name(self):
‘’’
‘’’
return capella_query_by_name(self, “Name”)
My script did not run
Then I added a third column to get property types
Even having a loop, I have a listed result…
I guess that (it’s written like this in the mass view) that the list is “name:type”.
So I need a new loop to catch name, then type…
I’m afraid I need again your help there…
Regards
Thierry

Hello Thierry,
Concerning your property object,

  • to get name, you can use ’property object.get_java_object().getName() ’ for exemple
  • to get type, you can use ‘property object.get_type()’ and a new loop to use ‘property type.get_name()’

Concerning this previous point, is it OK for you ?

Best regards,

Sophie

Hi Sophie,
I currently trying your solution for the properties… I explored another one : use split
proptytype=elem_Pties.split(":")
then in the loop:
worksheet.cell(row = i, column = 2).value = proptytype[0])
worksheet.cell(row = i, column = 3).value = proptyType[1]).
The point is I had the following response: there is no split attribute…
Thanks once more
Regards
Thierry
PS: Capabilities is solved: I have SFS and SIS names, that’s enough for the moment.
I will need after the available in state…

Hello,
Concerning split, I think it is ‘’:".split(elem_pties) but I think elem_pties has not the good type.

Best regards

Sophie

Hi Sophie,

Trying this:

i = 1
print(‘flag1’)
for elem_CLS in all_CLS:

ClassProperties=elem_CLS.get_contained_properties()
for elem_Pties in ClassProperties:
    proptytype=replace(":",",").elem_Pties
    #elem_Pties.get_java_object().getName()
    #pptyName=elem_Pties.get_name()
    #pptyType=elem_Pties.get_type()
 
    i = i + 1  
    worksheet.cell(row = i, column = 1).value = elem_CLS.get_name()
     
    j=0
    while j <2:
        worksheet.cell(row = i, column = 2+j).value = proptytype[j]
        j=j+1

I got : NameError: name ‘replace’ is not defined
Before I tried elem_Pties.replace(":",",") -syntax found in w3 python- and had: “property has no replace attribute”…
I understand that the string “name:type” is not a list, but it seems not to be a value either…
Without the replace, I had proptytype is not subscriptable…
I’m getting lost about p4c syntax compared to python (or some python internet course are wrong, or I don’t read them properly)
I tried as well get_java_object… but never succeed. I probably did not set up the correct syntax.
Or may be we don’t have “name:type”…
Thanks for your help
Regards
Thierry

Hello Thierry,
I would suggest to modify the loop like this:

For elem_Pties in ClassProperties:
pptyName = elem_Pties.get_java_object().getName()
pptyType = elem.get_type()
for pptyType_elem in pptyType:
proptytype = pptyType_elem.get_name()
[…]

  worksheet.cell(row = i, column = 2+j).value = proptytype

Best regards,

Sophie

Thanks Sophie, I run this
Have a good WE
Regards
Thierry

Hi Sophie
I have made small change to planned script and it runs…
I made a variant to get services (operations) but without parameters for the moment
Now I need the reference values: If I understood, I need to prepare a table for booleans, another for enumerations, numerics and strings… Then append the found files with Excel.
For all these the target is to find the detail typing each, ensuring by it there is a signal set typing the EI even when it is a value.
About EIE types is there any news to get about solving the issue? next release? beyond? corrective script until?
Thanks for all
Regards
Thierry