Report Template Structure

Предыдущая страницаВ началоСледующая страница

The report composition is similar to the XML language. The composition represents tree of elements. One or two tags specify an element. The element has embedded elements, attributes and contents.

Allowed elements names (without register):

1. group is used only for table framing.

2. container is used for variant reports (more information can be found in a report generator description).

3. list – The list of elements. It is used for table framing.

4. param – The parameter is used only in the table. Content is ignored. An element is replaced by the value from the product composition column. Should not be embedded into each other.

5. group_macro – The macro for group processing. Should be used as embedded element for element group.

6. summary – The result. Used only for table framing.

7. outcome – The resulting value. Used in summary element.

8. frag – insertion into the fragment cell.

9. sum_res - The result of the summation described on the “Sum” tab in the product composition parameters. Used only in the summary table.

10. variable – The value of the variable. The variable should exist in the file on the basis of which the report is created.

11. table_hider – The element to hide the table. Used with the filter.

Only group and list can be the top-level elements.

Allowed attributes values:

1. name is used only for param element.

2. filter is used in all elements.

3. recursive is used only for group and list elements. If there is hierarchy in the input data, it will influence the result of product composition records sampling.

4. recursive_template. The attribute shows that the element is a template for all groups.

5. str_process is used in param and outcome elements for post-processing or text value retrieving from the record. This attribute is used if insignificant processing of text value is necessary. For example, to specify the formatting and adjust the number of decimal places.

6. str_proc_macro is used in param and outcome elements for post-processing or a text value received from the record. This attribute uses the specified macro for text processing.

7. hide_table is used in table framing elements. Specifies the rule according to which the table doesn’t displayed.

8. source is used with frag element.

9. sorce_macro is used with frag element.

10. from_item is used with frag element.

11. regenerate 3d is used with frag.

12. index is used with table_hider.

The elements have two forms of recording:

1. {list}element content{/list} - 2 tags and the content.

2. {param name=”Description ”/} – 1 tag and no content.

When the report is generated the group and list elements copy the content (table) for each group/ product composition record to the report

Element group

Param elements are filled in the table of group element as follows: you take the first record from the group and its values are substituted.

All embedded list elements will operate merged data (those data that will be shown in Product composition window in ProductStructureDiff Apply product composition representation mode).

Element list

If list element is not embedded into group element, it is operating all records of the product composition (as they look like in Product composition window in ProductStructureDiff Apply product composition representation mode).

If the input data has the hierarchy:

By default, recursive attribute is disabled, i.e. only the composition records of the top level will be displayed.

If you set recursive as true, all records will be displayed.

It is allowed to create an embedded list element in the existing list element. In this case, the table from the embedded list element will be created and filled in for each product composition record with child records.

Element param

Element param is replaced with the corresponding value of the product composition record cell.

Full element record: {param name=”Description”/}. A full element record should be used if the column name contains spaces.

The element has a simplified record:

1) {param Description/} – the name is an attribute by default, thus its specifying is not necessary;

2) {Description/} – a param is an element by default, , thus its specifying is not necessary.

For example,  record {Part No./} ­ is not recognized as correct. For names of two or more words, you need to use a full record.

Names Pos, Position are allowed to display positions.

Element summary

The element frames the table. It can be used as a top-level element. The table is just copied to report in this case.

When you use the element in group and list elements, information obtained by processing group/list records can be output into the table. The information is output using outcome element.

Optional element before=”true” outputs table before group/list records.

Example of top-level summary element:

Header

 

EmptyGlobalHeader

 

 

Example with embedded group and list elements:

Header

 

EmptyGlobalHeader

 

 

 

 

{Section str_process="str = .SpecGroup(str)"/}

 

 

EachGroupHeader:

At all: {outcome name="Quantity" out_operation="numeric_sum" argument="F4"/}

 

EachGroupFooter:

At all: {outcome name="Quantity" out_operation="numeric_sum" argument="F4"/}

 

AllGroupsHeader:

At all: {outcome name=" Quantity " out_operation="numeric_sum"/}

 

AllGroupsFooter:

At all: {outcome name=" Quantity " out_operation="numeric_sum"/}

 

AllGroupsFooter:

All names: {outcome name="Description" out_operation="str_concat" argument="-;"/}

 

AllGroupsFooter:

Unique names: {outcome name="Description" out_operation="unique_strs" argument=";"/}

 

Header

 

EmptyGlobalFooter

 

 

Element outcome

The element is used to output resulting information inside framed table {summary}.

Main attributes:

1.name – a name of parameter which is used to gather resulting information.

2.out_operation – values processing type:

numeric_sum – numerical sum of all values;

str_concat – strings sum;

unique_strs – list of unique values.

3.argument – additional string parameter conveyed to out_operation.

numeric_sum – string output format;

str_concat – delimiter between summed strings for values enumeration;

unique_strs – delimiter between summed strings for unique values enumeration.

You can also specify attribute for sorting records that will be used in calculation using source_filter attribute (works similar to filter parameter). You can use str_process for the string post-processing.

Examples:

{outcome name="Description " out_operation="unique_strs" argument=";"/}

At all: {outcome name="Quantity" out_operation="numeric_sum" argument="F4"/}

Element sum_res

The sum_res element is used for summation result output. The summation is set on the “Sum” tab in the product composition parameters.

Main attributes:

name – a summation name. The name can be found in the product composition window. To do so call Product composition > Summation results from the context menu.

The name can be omitted. Then it will be selected automatically (Representation name + Name of the first summation).

You can use filter attribute.

You can use str_process for string postprocessing.

Examples:

{sum_res/}

{sum_res name="Mass"/}

Total: {sum_res Mass/}

Element variable

The variable element is used to output document variables into report. It can be displayed in the summary header table or in group and list tables.

Main attributes:

name – a variable name.

If there is no variable in the document, an empty string will be outputted.

You can use filter attribute.

You can use str_process for a string postprocessing.

Examples:

{variable name=”nCount”/}

{variable name=”$Number”/}

Formatted output of valid values (1 decimal place):

{variable name="nCount" str_process="str = str.AsDouble().Format(1)"/}

Element group_macro

The Group_macro element is a group processing macro. This element should be used as an embedded element of group element. Can use attribute filter – the macro will be applied only for the groups, which satisfy the condition.

Name of the element must be specified. The name specifies macro that should be started before the table filling. The macro prototype: void func(MacroCallContext context, GroupItemInfo group);

The first parameter contains context for the macro call.

Example:

{group}

      {group_macro name="Gen.Gen.GroupMacro" filter="Section = Company standard parts"/}

{/group}

The macro example:

using System;

using System.Linq;

using TFlex.Model;

using System.Collections.Generic;

using TFlex.Model.Model2D;

 

using TFlex.CadReportGenerator;

 

namespace Gen

{

   public class Gen

  {

       public static bool GroupMacro(MacroCallContext context, GroupItemInfo group)

       {

             var generAttrs = context.Properties.Attributes;// The report attributes check.

               if(!generAttrs.HasAttribute(“attrName”)

                       || generAttrs[“attrName”].ValueAsBool == false)

                       return true;

               //%%TODO: fill in

               return true;

       }

   }

}

You need to add link to TFPSCadReportGenerator for the macro compilation.

Element frag

The element is used only in tables, one element per cell. Fragment is inserted instead of it.

One of the four ways can specify the path to the fragment:

1. The filename is taken from the product composition column: {frag name=”Remarks”/};

2. The filename is specified explicitly: {frag source=”<3D Assemblies>Cam.grb”/};

3. The name matches the current element name (the fragment from which the data was raised will be inserted): {frag from_item=”true”/};

4. The name is received from the macro (look through source_macro): {frag source_macro=”Gen.Gen3.SourceMacro”/}.

You can specify page name in the fragment document, its image will be inserted into the cell:

{Frag Source="<Fitting_v2>Sketch.grb" page="sketch_p"/}

or

{Frag Source=«<Fitting_v2>Sketch.grb» page_macro=«Gen.Gen.FragPageMacro»/}

The format of macros source_macro and page_macro:

 String func(MacroCallContext context, ItemInfo currentItem);

You can also use filter attribute (filter=”…”) similar to param and outcome elements.

You can specify the regenerate_3d attribute (regenerate_3d="true") to ensure that the pasted fragment always recalculates 3D when recalculating 2D (used with projections).

You can use the attribute auto_width="true/false" - automatic selection of the width of the fragment so that it fits into the cell. The default is true.

Element table hider

You can add several tables between tags that specify an element. Element table hider allows to specify logic for hiding tables.

Main attributes:

index – an index of the table, which is embedded into the parents tag (indexing from 0).

filter – a filter for hiding tables.

Attributes

In the general case the attributes are recorded like attrName=”attrValue” in the tag that opens element.

Attribute filter

Example of a filter record:

{group filter="section = 'Company standard parts'"}

First lexical unit – product composition column name

Second lexical unit – operator

Third lexical unit – value

The filter operator (in this example - ‘=’) is recorded with the space in opposite to the attributes that have no space. A string value is recorded in single quotes.

You can specify logical relation between expressions: AND / OR.

{group filter="Section = ‘Company standard parts' OR Section = ‘Unknown’"}

You can use parentheses in the filter ( ).

{group filter="(Section = ‘A' AND Quantity = 1) OR (Section = ‘B' AND Quantity = 2)"}

Special symbols in the column name processing

If the column name contains spaces or symbols, you need to change them

ampersand "&" replace with "&amp;"

less "<" replace with "&lt;"

more ">" replace with "&gt;"

quotes """ replace with "&quot;"

apostrophe "'" replace with "&apos;"

space " " replace with a "&#032;"

left round bracket "(" replace with "&#040;"

right round bracket ")" replace with "&#041;"

For example:

{param name="Total Quantity" filter="Total&#032;Quantity != 0"/}

When the condition formed &#032 is replaced by the space.

Attribute hide_table

The attribute is similar to the attribute filter. It specifies the condition for the current element. According to the condition, the table will not be displayed. It can be used for the elements that are framing the table.

Example:

{group hide_table="Section = 'No' OR Section = '' "}

{/group}

For the groups without the section or it is “No” the heading table will not be created.

List of valid operators:

=

!=

>

>=

<

<= 

IsOneOf – included in the list

IsNotOneOf– not included in the list

IsNull  -does not contain data

IsNotNull –contains any data

ContainsSubstring -contains

NotContainSubstring –does not contain

StartsWithSubstring –starts with

EndsWithSubstring –ends on

IsEmptyString- does not contain text

IsNotEmptyString –contain text

MatchMask –merges mask

NotMatchMask – does not merge mask

Attribute str_process

The attribute is used in param and out_come elements for the post-processing of text value that is received from the element.

Example: The value of the attribute is recorded using C#. The resulting variable is “str”.

str_process="str = str.Replace('R', 'V')"

There are pre-determined methods allowed in “P” class:

P.SpecGroup – processes full BOM section name and lefts only subsection name after last ‘\’.

str_process="str = P.SpecGroup(str)".

P.AsDouble – converts string to real number:

str = (str.AsDouble() * 1.2).ToString()

P.AsInt – converts string to integer number:

str = (str.AsInt() * 2).ToString()

P.Format – converts number to string with formatting (by default there are two characters decimal places):

str = (str.AsDouble() * 1.2).Format(1) -one character decimal places.

str = (str.AsDouble() * 1.2).Format() - two characters decimal places.

Example of composite processing:

{Section str_process="str = P.SpecGroup(str).Replace('R', 'V').ToLowerInvariant()"/}

Attribute str_proc_macro

The attribute is used in param and outcome elements for the post-processing of a textual value, retrieved from product composition record. The attribute value should specify the post-processing macro name.

The attribute example:

{param name="Title_1" str_proc_macro="Gen.Str.ConstVarReplacer"/}

 

The macro example:

using System;

using TFlex.Model;

using TFlex.Model.Model2D;

using TFlex.Model.Model3D;

 

using TFlex.CadReportGenerator;

 

namespace Gen

{

public class Str

{

        public static string ConstVarReplacer(MacroCallContext context, String originalValue)

        {

                if(String.IsNullOrWhiteSpace(originalValue))

                        return originalValue;

                else if(originalValue == "ConstPart")

                        return "Variations constant data:";

                else if(originalValue == "VarPart")

                        return " Variations variable data:";

                else

                        return originalValue;

        }

}

}

 

Attribute from_item

The Boolean attribute used with frag element. It means that the path to the fragment is formed from the current element (a fragment from which the data was raised will be inserted).

Example:

{frag from_item="true"/}

Attribute source

Used with frag element. Specifies a path to the fragment file that should be inserted:

Example:

{Frag Source="<Fitting_v2>Sketch.grb"/}

Attribute source_macro

Used with frag element. Specifies a path to a fragment file that should be inserted using macro:

Example:

{frag source_macro="Gen.Gen3.FragSourceMacro"/}

 

Macro example:

using System;

using System.Linq;

using TFlex.Model;

using System.Collections.Generic;

using TFlex.Model.Model2D;

 

using TFlex.CadReportGenerator;

namespace Gen

{

public class Gen3

{

       public static string FragSourceMacro(MacroCallContext context, ItemInfo item)

       {

               string val = item["Annotation"];

               return String.IsNullOrWhiteSpace(val) ? "<Fitting_v2>Sketch.grb" : val;

       }

}

}

Attribute page

Used with frag element. Specifies name of inserted fragment page:

Example:

{Frag Source="<Fitting_v2>Sketch.grb" page=”Page_2”/}

Attribute regenerate 3d

Used with frag element. Activates flag of the inserted 2D fragment.

Example:

{Frag Source="<Fitting_v2>Sketch.grb" page=”Page_2” regenerate_3d=”true”/}

Attribute recursive_template

The attribute is used in group elements.

The attribute is important for representations, which consider hierarchy when grouping.

Example:

recursive_template=”true”

Template example

clip1052

Variant Report/BOM Generator (TFPSCadVersionReportGenerator)

The generator is a specialized version of standard (TFPSCadVersionReportGenerator) generator described above. It is used to generate reports for variant product compositions.

The main differences are:

Container element is used instead of group element;

Param element has special syntax.