Accessing certain slot properties via Report Wizard

Uploaded report templates and discussions about reports.

Moderators: sarawut_w, Moderators

Accessing certain slot properties via Report Wizard

Postby ohs18 » Wed Feb 03, 2021 12:52 pm

Hi,

I am currently trying to create a report from an instance specification. I have run into a couple problems while doing this, and have some questions specifically regarding slots of the instance specfications.

Question 1:
I am iterating through a foreach loop to retrieve slot values of the current instance. However, when they print out onto the report, they are not in the order that they are listed in the containment tree. I was wondering if there is a default way the report wizard decides to print slot values, because it seems to be very random, and not in the order I would expect or any listed order in my model. Is there a way to know how the report wizard is sorting the slot values, and if so, is there a way to change or manipulate that?

Question 2:
In my model, the instance specification I am creating the report for has a particular block as its classifier. The classifier block has both value properties and part properties, thus in the instance specification I created, it has slots for both the value properties and the part properties. Is there a way in the report wizard language to have only the slots that represent the value properties reported out when iterating through the slots? I don't want the slots that represent the part properties to be reported out, because the values of those slots are instance specifications themselves. I thought there might be a way to sort the slots, or simply have the foreach loop stop iterating when it hits the slots I don't want, but due to the way the report wizard seems to randomly output the slots in my report, this doesn't seem likely. So I was wondering if there was another way to do this.

Thanks in advance.
ohs18
Forum Newbie
Forum Newbie
 
Posts: 11
Posts Rating:1
Joined: Wed Jan 20, 2021 7:08 pm

Re: Accessing certain slot properties via Report Wizard

Postby sarawut_w » Wed Feb 03, 2021 7:16 pm

Hello,

For question1, there is a function for sorting elements in the same order that you see on Containment Tree, but this function is released in MagicDraw 19.0SP4 and 20.0 versions.
Moreover, you could use another sorter tool for sorting the slot in the way you want.
See $sorter.containmentTreeSort(collection) in our online document.
https://docs.nomagic.com/display/MD190SP4/Sorter+tool
If you are using 19.0 version, please update the patch.

For question2, you need to print value from slot values that have <<ValueProperty>> applied to Defining Feature element.
Code: Select all
#foreach($instance in $InstanceSpecification)
$instance.name
#foreach($slot in $instance.slot)
#set($df = $slot.definingFeature)
#if($report.containsStereotype($df, “ValueProperty”))
-   $df.name : $slot.value.get(0).text
#end
#end
#end


Best regards,
Sarawut W.
Support Engineer
sarawut_w
No Magic
No Magic
 
Posts: 466
Posts Rating:42
Joined: Thu Jun 23, 2011 12:47 am

Re: Accessing certain slot properties via Report Wizard

Postby ohs18 » Mon Feb 08, 2021 10:50 am

Thank you for the response.

I was able to get what I needed sorted properly as of right now, so that was very helpful. As a follow-up to the sorting question, is there a way to sort arrays that you create in your template? I have tried passing arrays into the "collection" field of the sorting tool before and that has not worked. Or is the functionality only for lists obtained directly from the model data you are trying to report out.

Thanks again.
ohs18
Forum Newbie
Forum Newbie
 
Posts: 11
Posts Rating:1
Joined: Wed Jan 20, 2021 7:08 pm

Re: Accessing certain slot properties via Report Wizard

Postby sarawut_w » Mon Feb 08, 2021 8:05 pm

Hello,

Yes, you could use the Sorter Tool with your Array. See this sample code:
Code: Select all
#set($myArray = [“c”,”a”,”b”])
Without sorter:
#foreach($val in $myArray)
$val
#end

With sorter:
#foreach($val in $sorter.sort($myArray))
$val
#end


This is a result of this code:
Code: Select all
Without sorter:
c
a
b

With sorter:
a
b
c


If you have a problem, please share us a sample project and template.

Best regards,
Sarawut
sarawut_w
No Magic
No Magic
 
Posts: 466
Posts Rating:42
Joined: Thu Jun 23, 2011 12:47 am

Re: Accessing certain slot properties via Report Wizard

Postby ohs18 » Tue Feb 09, 2021 12:05 pm

Thanks Sarawut.

I do have another question regarding what I am working on right now, so if you would like me to post it as another topic, please let me know and I can do so.

However, what I am having trouble doing currently is printing the names and values of the value properties of a group of instances that all have the same slots, just different values. I attached the template and the project file below. What I am trying to do is have all the "SV" instance value property names on the left side of the template, with the actual values of the slots in the corresponding columns. I also attached a file of what I would like the desired sheet output to look like.

I want to be able to access and print the value property slots as efficiently as possible and with as little hard-coding as possible, but I have not been successful in doing so. I have tried a number of different things, including making macros and trying to print the names and data that way, and also using the code I currently have in the template. I really think my lack of understanding how to properly use #forrow and #forcol directives is limiting me from doing this successfully on top of other things. Also, I am not sure if I am even thinking of this situation properly, and if there is a completely better way to accomplish my goal. Currently, I am operating on the parent instance of the model, which has child instances underneath of it (due to having part properties), and under these child instances are more child instances, and so forth. I have been struggling quite a bit with this task so far so any additional help is greatly appreciated.

Thanks

Working_Template.xlsx

Desired_Output.xlsx

Report_Wizard_Outputs.mdzip
You do not have the required permissions to view the files attached to this post.
ohs18
Forum Newbie
Forum Newbie
 
Posts: 11
Posts Rating:1
Joined: Wed Jan 20, 2021 7:08 pm

Re: Accessing certain slot properties via Report Wizard

Postby ohs18 » Tue Feb 16, 2021 5:49 pm

Hi. I just wanted to follow up on this post as I haven't gotten a response yet and am still having trouble with this issue and have not figured out a solution to this problem yet and could still use some support.

Thanks in advance.
ohs18
Forum Newbie
Forum Newbie
 
Posts: 11
Posts Rating:1
Joined: Wed Jan 20, 2021 7:08 pm

Re: Accessing certain slot properties via Report Wizard

Postby sarawut_w » Tue Feb 16, 2021 9:01 pm

Hello,

We are sorry for lately reply.
Please create a new ticket for this question in our support system.
It seems we have to provide you a sample template, and this may take our effort.
So, this question need to be answered by our template creation expert.

Best regards,
Sarawut
sarawut_w
No Magic
No Magic
 
Posts: 466
Posts Rating:42
Joined: Thu Jun 23, 2011 12:47 am


Return to Report Engine

Who is online

Users browsing this forum: No registered users and 0 guests