Code folding for Abaqus input files

Code folding for Abaqus input files

2

    Feb 04, 2020#1

    Hi!

    I am having some trouble setting up the code folding I want to use for Abaqus input files. The blocks I want to fold always starts with an * followed by a keyword, example: *NODE. After this, there will be a block of indented text which is the text I want to have folded. The indented block is usually followed by ** or * followed by an arbitrary character. I therefore would like to set up a code folding that either consider the indentation of strings or will fold text between strings that starts with an * followed by an arbitrary character and ** or * followed by an arbitrary character.

    Is this possible?

    Any help would be much appreciated. Please, also find the attached figure as clarification of the block I want to fold where the highlighted sections are the blocks that I would like to have folded.

    Thanks in advance for your reply!

    Best regards,
    Jonatan
    abaqus_example_text.png (28.17KiB)

    6,686585
    Grand MasterGrand Master
    6,686585

      Feb 04, 2020#2

      It would be helpful for us if the text of an Abaqus input file would be posted as text and not as image. Then we could try out the code folding definitions by ourselves and post the working solution or let you know that it is not possible at all. Please post the text as text formatted as code block (last but one item on toolbar above the edit field).

      There is the keyword EnableCFByIndent which can be added to first line of a wordfile to enable code folding based on indentation levels. But right aligned data in first data column means different indentations within a block.

      Code folding based on *NODE and *ELEMENT as fold strings and ** as unfold string would be also possible, but your text shows multiple lines containing ** which means for folding engine of UltraEdit that there are multiple unfold strings in file while there is just one fold string. Fold/unfold strings are not defined as matching pairs like the open/close brace strings.
      Best regards from an UC/UE/UES for Windows user from Austria

      2

        Feb 05, 2020#3

        Please find the text formatted as code below.

        Code: Select all

        *NODE
               1,       307.65000000000003,       132.14443822709597,        6.443840684457536
               2,        309.1499999999999,       128.31001106435033,       0.5520133041122024
               3,       364.65000000000254,       124.60153458169401,        9.277548342465533
               4,        364.6500000000023,       120.38262920740083,        3.735676156953737
               5,       357.64999999999753,       123.10701999654462,          6.9042877960595
               6,       364.65000000000254,       122.69769808728955,          6.3500839194031
               7,       361.15000000000003,       121.81584903008108,        5.258729008316886
               8,       361.15000000000003,       123.89019245111548,        8.068198895548534
               9,       364.65000000000254,       114.45663730339109,     -0.45909095925276633
              10,       357.64999999999736,        118.3515581587259,       1.9754476436818116
              11,       364.65000000000254,       117.58274766854157,       1.4079280372813239
        **
        ** SOLID ELEMENTS
        **
        *ELEMENT, TYPE=C3D10, ELSET=EM1_Plate
          136293,   168769,   168333,   168372,   169218,   168773,   168774,   168772,   169158,   169224,   170914
          136295,   168275,   168748,   168274,   165428,   168749,   168751,   168750,   153820,   163201,   171708
          136296,   168215,   168274,   168748,   165428,   168217,   168751,   168752,   171152,   171708,   163201
          136297,   168372,   168313,   168769,   168356,   168373,   168771,   168772,   168375,   168358,   170995
        *ELEMENT, TYPE=C3D10, ELSET=EM1_Box
          138593,   173227,   173236,   173215,   172838,   173237,   173238,   173228,   173781,   173809,   173904
          138594,   172470,   173215,   173236,   172838,   173241,   173238,   173243,   173903,   173904,   173809
          138595,   172460,   172838,   172470,   173236,   172860,   173903,   172488,   174107,   173809,   173243
          138596,   172838,   172834,   173227,   172855,   172845,   173178,   173781,   172856,   172857,   173739
          138597,   173236,   172855,   172460,   172838,   173761,   172861,   174107,   173809,   172856,   172860
          138601,   173227,   172838,   172855,   173236,   173781,   172856,   173739,   173237,   173809,   173761
        **
        Unfortunately "NODE" and "ELEMENT" are just text strings used as an example of how a file could look like. There could be numerous other text strings that I would like to use as a fold string and instead of detecting all possible strings it would be useful to only specify * followed by an arbitrary character as the fold string. Regarding the multiple lines containing "**", this is an usual formatting of Abaqus input-files which have been automatically generated by another software. It would therefore be neat if it would be possible to detect the first occurring string of "**" after the fold string and identify this as the unfold string. This might not be possible, however? The keyword "EnableCFByIndent" in the beginning of the word file, however, seems to produce a code folding that would suffice for my current needs. 

        Thank you for this solution!

        Best regards,
        Jonatan

        6,686585
        Grand MasterGrand Master
        6,686585

          Feb 05, 2020#4

          Thank you for the example block.

          Code folding worked fine (with UltraEdit for Windows v22.20 on Windows XP) for the example if the wordfile used to syntax highlight the file contains in first line the keyword EnableCFByIndent and no lines starting with /Open Fold Strings = and /Close Fold Strings =.

          UltraEdit suggests with this configuration to fold
          • from line 1 with *NODE to line 12 with 11,,
          • from line 16 with *ELEMENT, TYPE=C3D10, ELSET=EM1_Plate to line 20 with 136297,
          • from line 21 with *ELEMENT, TYPE=C3D10, ELSET=EM1_Box to line 27 with 138601,.
          There is at Advanced - Settings or Configuration - Editor display - Code folding the setting Show last line of fold in syntax highlighted files which should be better unchecked for this code folding.

          I used the first time EnableCFByIndent which was introduced for Python script files, but works also good on other file types. I was surprised that the different indentations on first block caused by right aligning the incremented numbers result nevertheless in a code folding as wanted.

          So my advice is using this simple indent based code folding as already used by you and see how it works for you and your Abaqus input files.

          I tested also a code folding definition in wordfile without EnableCFByIndent and with

          Code: Select all

          /Open Fold Strings = "*NODE" "*ELEMENT"
          /Close Fold Strings = "*ELEMENT" "**"
          That worked also fine for the example whereby the configuration setting Show last line of fold in syntax highlighted files should be better enabled for this type of code folding. But this method requires that all possible strings after a single asterisk must be written into the wordfile as open fold strings and where necessary also as close fold strings.

          It is not possible to use an open fold string definition like asterisk and wildcard or regular expression representing any other character with exception of space or asterisk. Regular expressions are not supported for syntax highlighting and other features based on syntax highlighting like code folding. Regular expressions are supported only for searching for strings to list in the Function List. That's it.
          Best regards from an UC/UE/UES for Windows user from Austria