Keywords to pick variable into Simlab script for variable mesh size etc

AjayBorah
AjayBorah Altair Community Member
edited December 2021 in Community Q&A

#************************Variables set from SimLab CustomUI***************************************
Avg_element_Size='2'
Element_Type_2D='Tri3'
Element_Type_3D='Tet4'
Hexnut_Dia/2='13'
Internal_grading='1'
Tetra_Size='2'
#***************************************************************************************************

//***************************************************************/
//********This script is generated by SimLab script engine******/
//SimLab Version 2018
//Created at Mon Oct 25 10:01:34 2021
//***************************************************************/
from hwx import simlab

SurfaceMesh=''' <SurfaceMesh UUID="08df0ff6-f369-4003-956c-82781326c876">
<tag Value="-1"/>
<SurfaceMeshType Value="Tri"/>
<SupportEntities>
<Entities>
<Model>Tierod.stp</Model>
<Body></Body>
</Entities>
</SupportEntities>
<Tri>
<ElementType Value="+Element_Type_2D+"/>
<AverageElementSize Value="+Avg_element_Size+" Checked="1"/>
<MaximumElementSize Value="2.8" Checked="1"/>
<MinimumElementSize Value="0.5"/>
<GradeFactor Value="1"/>
<MaximumAnglePerElement Value="45"/>
<CurvatureMinimumElementSize Value="

Tagged:

Answers

  • AlessioLibrandi
    AlessioLibrandi
    Altair Employee
    edited December 2021

    Hi, you are missing the TRIPLE QUOTES which are required to interrupt the multi-line string and concatenate the variable-string.

    Try with:

         <ElementType Value="'''+Element_Type_2D+'''"/>

     

     

    image

  • AjayBorah
    AjayBorah Altair Community Member
    edited December 2021

    HI, Thank you Very much,

    Its still not working ,Variables are not calling into command.

    Kindly check the attached file .

    Thank you

    #************************Variables set from SimLab CustomUI***************************************
    Avg_element_Size='2'
    Element_Type_2D='Tri3'
    Element_Type_3D='Tet4'
    Hexnut_Dia/2='13.026'
    Internal_grading='1'
    Tetra_Size='2'
    #***************************************************************************************************

    //***************************************************************/
    //********This script is generated by SimLab script engine******/
    //SimLab Version 2018
    //Created at Mon Oct 25 10:01:34 2021
    //***************************************************************/
    from hwx import simlab

    SurfaceMesh=''' <SurfaceMesh UUID="08df0ff6-f369-4003-956c-82781326c876">
    <tag Value="-1"/>
    <SurfaceMeshType Value="Tri"/>
    <SupportEntities>
    <Entities>
    <Model>Tierod.stp</Model>
    <Body></Body>
    </Entities>
    </SupportEntities>
    <Tri>
    <ElementType Value='''+Element_Type_2D+'''/>

  • AlessioLibrandi
    AlessioLibrandi
    Altair Employee
    edited December 2021
    AjayBorah said:

    HI, Thank you Very much,

    Its still not working ,Variables are not calling into command.

    Kindly check the attached file .

    Thank you

    #************************Variables set from SimLab CustomUI***************************************
    Avg_element_Size='2'
    Element_Type_2D='Tri3'
    Element_Type_3D='Tet4'
    Hexnut_Dia/2='13.026'
    Internal_grading='1'
    Tetra_Size='2'
    #***************************************************************************************************

    //***************************************************************/
    //********This script is generated by SimLab script engine******/
    //SimLab Version 2018
    //Created at Mon Oct 25 10:01:34 2021
    //***************************************************************/
    from hwx import simlab

    SurfaceMesh=''' <SurfaceMesh UUID="08df0ff6-f369-4003-956c-82781326c876">
    <tag Value="-1"/>
    <SurfaceMeshType Value="Tri"/>
    <SupportEntities>
    <Entities>
    <Model>Tierod.stp</Model>
    <Body></Body>
    </Entities>
    </SupportEntities>
    <Tri>
    <ElementType Value='''+Element_Type_2D+'''/>

    You should add the triple quotes... but without deleting the existing double quotes (")

    I know that it looks weird to have "''' , like 5-ple quotes,  but once you understand why you will remember it!

    Original recorded text:
    SurfaceMesh='''....  <ElementType Value="Tri6"/> ...'''

    Triple quotes ''' define a MULTIPLE LINE STRING.

    You have to

    - Delete the recorded field (Tri6)

    - Instead of the recorded field, you close the string ('''), concatenate the variable string (+VARname+) and open the string again (''')

    It becomes: 

    SurfaceMesh='''....  <ElementType Value="'''+VARname+'''"/> ...'''

    ******************************

    So, you have to write:

     

    SurfaceMesh=''' <SurfaceMesh UUID="08df0ff6-f369-4003-956c-82781326c876">
    <tag Value="-1"/>
    <SurfaceMeshType Value="Tri"/>
    <SupportEntities>
    <Entities>
    <Model>$Geometry</Model>
    <Body></Body>
    </Entities>
    </SupportEntities>
    <Tri>
    <ElementType Value="'''+Element_Type_2D+'''"/>
    <AverageElementSize Value="8" Checked="1"/>
    <MaximumElementSize Value="11.312" Checked="0"/>
    <MinimumElementSize Value="0.8"/>
    <GradeFactor Value="1.5"/>
    <MaximumAnglePerElement Value="30"/>
    <CurvatureMinimumElementSize Value="4"/>
    <AspectRatio Value="10"/>
    <IdentifyFeaturesAndMesh Checked="1"/>
    <CreateMatchingMesh Checked="0"/>
    <AdvancedOptions>
    <ImprintMeshing Checked="0"/>
    <BetterGeometryApproximation Checked="0"/>
    <CoarseMesh Checked="0"/>
    <CoarseMesh_UseExistingNodes Checked="0"/>
    <CreateNewMeshModel Checked="0"/>
    <UserDefinedModelName Value=""/>
    <Tri6WithStraightEdges Checked="0"/>
    <ImproveSkewAngle Value="0"/>
    <MappedMesh Value="0"/>
    <MeshPattern Value="0"/>
    </AdvancedOptions>
    </Tri>
    </SurfaceMesh>''';
    simlab.execute(SurfaceMesh);

  • AjayBorah
    AjayBorah Altair Community Member
    edited December 2021

    Hi Alessio,

    Thanks a lot

    Its working now.

  • AjayBorah
    AjayBorah Altair Community Member
    edited December 2021

    Hi,

    I am trying to get model names for FEM into Simlab script so as to generalized for running the script for any model.

    I have some numbering rule for my model and the Script is as below

    FEMModelName = simlab.getModelName("FEM");

    Renumber=''' <Renumber UUID="28706164-a6f5-4544-b4a9-c052c4b6c60f">
    <Option Value="Nodes"/>
    <Selection Value="Model"/>
    <AdvancedOption>
    <SurfaceAndInterior Value="false"/>
    <CornerAndMid Value="false"/>
    </AdvancedOption>
    <RenumberData>
    <Model Name="'''+FEMModelName+'''"</Model>
    <NodeStartID>101</NodeStartID>
    </Model>
    </RenumberData>
    <FileName Value=""/>
    </Renumber>''';
    simlab.execute(Renumber);

    when i run this FE Model is not renumbered.

    Any suggestions.

    Thank you in advance...

  • AlessioLibrandi
    AlessioLibrandi
    Altair Employee
    edited December 2021

    Hello, 

     

    in this case, the created variable is already a string, so you don't need to introduce it through " when concatenating.

    Please in order to use the right syntax, just see the help related to the automation utility, you will always find the right script sample and syntax explanation

    image