864x
004409
2020-04-27

Question

How can I create a section via the COM interface?


Answer:
In principle, a section is an element, such as a member, and is created in the same way. First, an interface to the objects is required. For a member, this would be IModelData, and for sections, it would be ISections. This interface can be found in IModel3:

Sub test_section()
'   get interface from the opened model and lock the licence/program
    Dim iModel As RFEM5.IModel3
    Set iModel = GetObject(, "RFEM5.Model")
    iModel.GetApplication.LockLicense
    
On Error GoTo E
    
    Dim iSecs As RFEM5.ISections
    Set iSecs = iModel.GetSections()

All sections created previously are deleted first, then two new sections are created.
The first section should be a solid section with a visible sectional area (see Image 01). The data are entered in a similar way as in RFEM. As the type, "SectionOnSectionalArea" is selected, the corner points of the section are set using "EdgePoint", and a "Vector" defines the direction of the section:

   '   first delete all sections
    iSecs.PrepareModification
    iSecs.DeleteObjects ("All")
    iSecs.FinishModification
    
    '   set section on solid
    Dim sec As RFEM5.Section
    sec.EdgePointA.X = 2
    sec.EdgePointA.Y = 5
    sec.EdgePointA.Z = 0
    sec.EdgePointB.X = 2
    sec.EdgePointB.Y = 8
    sec.EdgePointB.Z = 0
    
    sec.no = 1
    sec.Name = "solid section"
    sec.Plane = GlobalPlaneInPositiveX
    sec.ShowValuesInIsolines = False
    sec.Type = SectionOnSolidSectionLine
    sec.ObjectList = "1"
    
    iSecs.PrepareModification
    iSecs.SetSection sec
    iSecs.FinishModification

As already known from other elements, the new section is finally transferred in a Prepare-/FinishModification block. A surface section is to be created as the second section (see Image 02). For this, it is necessary to use the "SectionViaSurfacePlane" type. In addition to the vector of the section direction, you have to select the display plane of the results for the surface section. In the following example, the xy plane is selected by setting "GlobalPlaneInPositiveX".

'   set section on surface
    sec.EdgePointA.X = 2
    sec.EdgePointA.Y = 0
    sec.EdgePointA.Z = 0
    sec.EdgePointB.X = 2
    sec.EdgePointB.Y = 3
    sec.EdgePointB.Z = 0
    
    sec.no = 2
    sec.Name = "surface section"
    sec.Plane = GlobalPlaneInPositiveX
    
    sec.ShowValuesInIsolines = True
    sec.Type = SectionViaSurfacePlane
    sec.ObjectList = "1"
    
    sec.Vector.X = 0
    sec.Vector.Y = 0
    sec.Vector.Z = 1
    
    iSecs.PrepareModification
    iSecs.SetSection sec
    iSecs.FinishModification

It is also possible to get the results of a section using the separate method "GetResultsInSection" of the "IResults2" interface. In the following, the shear forces on the surface section are obtained. The distribution of the internal forces is set to "Continuous within Surfaces" by means of "ContinuousDistributionWithinObjects":

 '   get results
    Dim iCalc As ICalculation2
    Set iCalc = iModel.GetCalculation
    
    Dim iRes As IResults2
    Set iRes = iCalc.GetResultsInFeNodes(LoadCaseType, 1)
    
    Dim secRes() As RFEM5.SectionResult
    secRes = iRes.GetResultsInSection(2, AtNo,
      ShearForceVy,ContinuousDistributionWithinObjects, False)

Under Downloads, you will find the Excel macro and the test file in order to understand the program.