Skip to content

Element

The module provides functionality to create, manage, and synchronize structural elements (Beam and Truss) in the model.

Note.

All the codes below assumes the initial import and MAPI Key definition.

from midas_civil import *
MAPI_KEY('eyJ1ciI6InN1bWl0QG1pZGFzaXQuY29tIiwicGciO252a81571d')

Constructor

To create elements function corresponding to element type should be used.

  • Truss : Element.Truss( )
  • Beam : Element.Beam( )
  • Plate : Element.Plate( )

Class Attributes

Element.elements -> List of all elements.

Node(0,0,0,id=1)    # Create Node at 0,0,0 with ID = 1
Node(1,1,1,id=2)    # Create Node at 1,1,1 with ID = 2
Node(2,2,2,id=3)    # Create Node at 2,2,2 with ID = 3

beam_1 = Element.Beam(1,2)  # Create Beam connecting Node 1 and Node 2 (default ID = 1)
beam_2 = Element.Truss(2,3)  # Create Truss connecting Node 2 and Node 3 (default ID = 2)

for elem in Element.elements:
    print(f'ELEM ID = {elem.ID} | TYPE = {elem.TYPE} | NODE = {elem.NODE}')
# Output :
# ELEM ID = 1 | TYPE = BEAM | NODE = [1, 2]
# ELEM ID = 2 | TYPE = TRUSS | NODE = [2, 3]

Methods

Element.json

Returns a JSON representation of all Nodes defined in python.

beam_1 = Element.Beam(1,2)   # Create Beam connecting Node 1 and Node 2

print(Element.json())

# Output :
# {'Assign': {1: {'TYPE': 'BEAM', 'MATL': 1, 'SECT': 1, 'NODE': [1, 2], 'ANGLE': 0}}}

Element.create

Sends the current element list to the Civil NX using a PUT request.
New elements are created and existing elements(same ID) in Civil NX will be updated.

Node(0,0,0,id=1)    # Create Node at 0,0,0 with ID = 1
Node(1,1,1,id=2)    # Create Node at 1,1,1 with ID = 2
Node(2,2,2,id=3)    # Create Node at 2,2,2 with ID = 3

beam_1 = Element.Beam(1,2)  # Create Beam connecting Node 1 and Node 2 (default ID = 1)
beam_2 = Element.Beam(2,3)  # Create Beam connecting Node 2 and Node 3 (default ID = 2)

Node.create()
Element.create()

Element.get

Fetches elements from the Civil NX and return the JSON representation.
-Here, Civil model had 1 beam element

print(Element.get())
# Output
# {'ELEM': {1: {'TYPE': 'BEAM', 'MATL': 1, 'SECT': 1, 'NODE': [1, 2], 'ANGLE': 0}}}

Element.sync

Retrieves Element data from the Civil NX and rebuilds the internal element list.
-Here, Civil model had 1 beam element

Element.sync()
for elem in Element.elements:
    print(f'ELEM ID = {elem.ID} | TYPE = {elem.TYPE} | NODE = {elem.NODE}')
# Output
# ELEM ID = 1 | TYPE = BEAM | NODE = [1, 2]

Element.delete

Deletes all element data from both Python and Civil NX.

Element.delete()