834x
004688
1.9.2020

Dotaz

Jak mohu změnit nastavení sítě konečných prvků pomocí rozhraní COM?


Odpověď:

Obecné nastavení sítě konečných prvků je možné změnit pomocí rozhraní IFeMeshSettings. Toto rozhraní se nachází pod IModel > IModelData > ICalculation. Na Obrázku 01 je vidět, které prvky lze měnit/zobrazovat.

Zde je příklad kódu, kde je požadovaná délka konečných prvků nastavena na 100 mm. Dále se aktivuje dělení prutů se stejnou velikostí prvku a minimální dělení se nastaví na 3 prvky:

Sub mesh_params()

Dim iApp As RFEM5.Application

'   get interface for model data
Dim iModel As RFEM5.model
Set iModel = GetObject(, "RFEM5.Model")

On Error GoTo e

If Not iModel Is Nothing Then
    
    '   get interface for application and lock licence
    Set iApp = iModel.GetApplication()
    iApp.LockLicense
    
    '   get interface for model dat
    Dim iModdata As RFEM5.IModelData2
    Set iModdata = iModel.GetModelData
    
    '   get interface for calculation
    Dim iCalc As RFEM5.ICalculation2
    Set iCalc = iModel.GetCalculation()
    
    '   get interface for mesh settings
    Dim iMeshSet As RFEM5.IFeMeshSettings
    Set iMeshSet = iCalc.GetFeMeshSettings
    
    '   get general mesh settings
    Dim meshGen As RFEM5.FeMeshGeneralSettings
    meshGen = iMeshSet.GetGeneral
    
    meshGen.ElementLength = 0.1
    
    '   set new general mesh settings
    iModdata.PrepareModification
    iMeshSet.SetGeneral meshGen
    iModdata.FinishModification
    
    '   get mesh member settings
    Dim meshMem As RFEM5.FeMeshMembersSettings
    meshMem = iMeshSet.GetMembers
    
    meshMem.DivideStraightMembers = True
    meshMem.ElementLength = 0.1
    meshMem.MinStraightMemberDivisions = 3
    
    '   set new mesh member settings
    iModdata.PrepareModification
    iMeshSet.SetMembers meshMem
    iModdata.FinishModification
    
    
    iApp.UnlockLicense
End If

e:  If Err.Number <> 0 Then
    MsgBox Err.description, , Err.Source
    End If
    iApp.UnlockLicense
    Set iApp = Nothing
    Set iModel = Nothing

End Sub


Podprogram je také doplněný podprogramem pro záchyt chyby (On Error GoTo e) a stejně jako v případě úpravy jiných prvků je zde zapotřebí blok Prepare-/FinishModification. Blok se zde vytvoří pomocí rozhraní IFeMeshSettings.


Autor

Ing. Günthel zajišťuje technickou podporu zákazníkům.