*createstringarray

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hello,

 

I have written a TCL script that selects certain elements in my mesh. I want to have these elements put into a string array, so I can use this array to update a certain NASTRAN card, in comments, so I can use them later on in a different routine. The problem now, however, is whenever I try to use *createstringarray it gives back a 0 in the left corner.

 

The string is in a variable that needs to be substituted into *createstring array:

 

set elements {213 5342 53 213 642};

set $str [subst {\$BSURF 1 $elements}];

(Note that the BSURF is commented via $, hence the backslash)

 

*createstringarray 3 '\$beginbsurfs' $str '\$endbsurfs'

 

This following procedure returns a zero. What am I doing wrong?

 

Thank you for your help and time!

 

Jeffrey

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2013

    Hi Jeffrey,

     

    please try the the following in line 2

     

    set str [subst {\$BSURF 1 $elements}];

     

    Only access to a variable needs a '$', not at creation time...

    You can insert a check after this line:

     

    tk_messageBox -message 'String : $str'
     

    Here you need the '$'

     

     

    Regards,

    Mario

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2013

    Hello Mario,

     

    The '$' was a typo from my side. It appears that the $elements variable that is created in HyperMesh causes an error, while using a user created variable with set numbers seem to work perfectly:


    set elements {213 5342 53 213 642};
    set str [subst {\$BSURF 1 $elements}];
    *createstringarray 3 '\$beginbsurfs' $str '\$endbsurfs'

    Works. The following does not:

    $elems is a list created in HyperMesh by means of a TCL script. This is just an ordinary but lengthy list.


    set str [subst {\$BSURF 1 $elems}];
    *createstringarray 3 '\$beginbsurfs' $str '\$endbsurfs'

    Maybe the error window output gives more insight of what the problem is?


    0
    while executing
    '*createstringarray 3 '\$beginbsurfs' $str '\$endbsurfs''
    ('uplevel' body line 1)
    invoked from within
    'uplevel #0 {*createstringarray 3 '\$beginbsurfs' $str '\$endbsurfs'}'
    invoked from within
    'interp eval $::tkcon::OPT(exec) $args'
    (procedure '::tkcon::EvalSlave' line 2)
    invoked from within
    'EvalAttached $cmd'

    Thanks for your help and time.

     

    Jeffrey

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2013

    Hi,

     

    sry, can't detect any error. For me it works for elements or elems.

     

    Please check whats inside of $elems

     

    set elems {213 5342 53 213 642};
    tk_messageBox -message 'Elementlist : $elems'

    set str [subst {\$BSURF 1 $elems}];
    tk_messageBox -message 'String : $str'

    *createstringarray 3 '\$beginbsurfs' $str '\$endbsurfs'
     

     

    Normaly TCL strings are not limited, but maybe *createstringarray has a limit in string lenght. Please check it too.

     

    Regards,

    Mario

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2013

    Hello Mario,

     

    I think the string length is limited. I've created a workaround, grouping ranges of values together. The string created is far smaller than the original string and it does create the string via this method.

     

    Nonetheless, I've checked the items inside $elems and the information is just numbers, element ID numbers.

     

    How and where could I check the maximum length of *createstringarray?

     

    Thank you,

     

    Jeffrey

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited July 2013

    Hi Jeffrey,

     

    i don't know a answer, so it is better to contact the Altair hotline.

     

    Regards,

    Mario

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.