Scripting#
Command |
SOF_TEST_SCRIPT_OPEN |
Tooltip |
Opens a palette for the scripting API based on Lua. |
Sidebar |
Tools |
For many use cases the parametrics provided by the tried and tested Parametrics in Bridge Design (CABD) are sufficient.
In addition, SOFiPLUS provides a scripting API based on Lua for edge cases.
Warning
This feature is in public preview. It may change at any time.
Create a Structural Point#
The available properties are:
number |
Element number. [1 …] |
position |
XYZ Location of point. |
support_pzz |
Supports. Available: pxx, pyy, pzz, px, py, pz, mb |
Create the point at position (0,0,0):
local spt = sofistik.Point.new({0, 0, 0})
spt.number = 1
Modify the position at a later point in time:
spt.position = {10, 0, 0}
Assign a support:
spt.support_pzz = true
Use a variable and a loop to create multiple points:
local x = 10.0
local count = 20
for y=1,count do
local spt = sofistik.Point.new({ x, y, y*0.1 })
end
Create a Structural Line#
The available properties are:
number |
Element number. [1 …] |
group |
Primary group number. |
type |
Beam type: CENTRIC, REFERENCE, COLUMN, CCOLUMN, TRUSS, CABLE, SECTION, NONE |
section |
Cross section number. |
section_at_start |
Cross section number at start. |
section_at_end |
Cross section number at end. |
geometry |
Modify the geometry of the object. |
length |
Length of the curve. |
start_point |
|
end_point |
Create a line between two points:
local sln = sofistik.Line.new()
sln.number = 1
sln.group = 99
sln.geometry:set_line({0, 0, 0}, {1, 0, 0})
Create a structural line as a polyline, i.e. connecting several points starting at (0,0,0):
local sln = sofistik.Line.new()
sln.geometry
:move_to({0, 0, 0})
:line_to({1, 0, 0})
:line_to({1, 1, 0})
:line_to({2, 3, 0})
Print the length of the line to the console:
print( sln.length )
Assign a cross section:
sln.section = 5
Assign different cross sections at start and end with linear interpolation:
sln.section_at_start = 1
sln.section_at_end = 2
Choose a beam type:
sln.type = sofistik.SLN.CENTRIC
Create a Structural Area#
The available properties are:
number |
Element number. [1 …] |
group |
Primary group number. |
thickness |
Element thickness. |
geometry |
Modify the geometry of the object. |
alignment |
Align the coordinate system to, for example, a structural point. |
Create a rectangle with thickness 0.2:
local area = sofistik.Area.new()
area.number = 1
area.group = 99
area.thickness = 0.2
area.geometry:set_quad({0, 0, 0}, {1, 0, 0}, {1,1,0}, {0,1,0})
Create a triangle:
area.geometry:set_tri({0, 0, 0}, {1, 0, 0}, {1,1,0})
Create an arbitrary polygonal area:
local area = sofistik.Area.new()
area.geometry
:move_to({0, 0, 0})
:line_to({1, 0, 0})
:line_to({2, 0.5, 0})
:line_to({1, 1, 0})
:line_to({0, 1, 0})
:close()
Align generated elements vertically:
area.align_elements = sofistik.SAR.AlignTop
area.align_elements = sofistik.SAR.AlignCenter
area.align_elements = sofistik.SAR.AlignBottom
Common Operations on Elements#
Assign element numbers.
Assign a number:
elem.number = 1
Note
If the number is already assigned to another element, the next free number will be assigned instead.
Move objects.
Move the object a relative distance 1.0 along global X, 2.0 along global Y and -3.5 along global Z:
spt:move({ 1, 2, -3.5 })
Align local X-axis of area relative to a point, and rotate around local Z
sar.alignment.target = spt
sar.angle = 90
CABD / Bridge : Create an Axis#
The available properties are:
geometry |
Set the geometry of the axis as a 3D curve. |
plan_view |
Set the geometry of the axis as a combination of plan view and elevation view geometric objects. |
placements |
Modify the placements assigned to the axis. |
secondary |
Provides access to secondary axes (for example, offset curves). |
variables |
Variable progressions along the axis. Used by sections and offset curves. |
domain |
Min and max station value ( |
Create an axis AXIS
as 3D line along global X with length 30.0:
local axis = sofistik.Axis.create_primary_3d("AXIS")
axis.geometry:set_line({0, 0, 0}, {30, 0, 0})
Create an axis AXIS
with plan view geometry:
local axis = sofistik.Axis.create_plan_view_elevation("AXIS")
axis.plan_view:line(10)
axis.plan_view:clothoid(40, 999, 100)
axis.plan_view:arc(40, 100)
Check if an axis is derived from a 3D curve (create_primary_3d
):
if axis.is_3d then
print("it is a free curve")
end
Let’s add placements.
Create placements at a specific stations:
axis.placements:create_at_s(0)
axis.placements:create_at_s(10.5)
Let’s create structural lines between placements.
Create placements at a specific stations:
local axis = sofistik.Axis.create("AXIS")
axis.geometry:set_line({0, 0, 0}, {30, 0, 0})
local plc1 = axis.placements:create_at_s(0)
local plc2 = axis.placements:create_at_s(10.5)
local sln = sofistik.Line.new(gax, plc1, plc2)
sln.section = 1
Let’s add a secondary axis offset by constant distances along Y and Z (local to primary axis).
Note
The name of a secondary axis needs to be a single uppercase character from the range A-Z.
axis.secondary:create_offset("L", -4.0, 0.0)
axis.secondary:create_offset("R", 4.0, 0.0)
Add a secondary axis offset with the distance in local Y
defined by a variable H
.
Note
Available as of version 2023.
axis.variables:create("H")
axis.secondary:create_offset("R", "H", 0.0)
CABD / Bridge : Link vertices of elements#
SOFiPLUS and AutoCAD objects provide various interesting vertices by name. These vertices can be linked.
For example, an end point of a structural line can be linked to a vertex of a structural area polygon, or an end point of another structural line or even to a placement on an axis.
In all cases a relative offset can be specified (optionally).
A use case would be to link the cables of a cable stayed bridge to the placements on an axis thereby making it easier to modify the geometric design of the bridge.
Attention
Make sure to avoid circular references.
SOFiPLUS will stop processing the associative links when encountering a circular reference. They can be difficult to track down.
Source parameters are specified first, target last:
link_endpoint_to_endpoint(sln, "sln.startpoint", sar, "vertex.0")
Link to placement:
link_endpoint_to_placement_on_axis(axis, plc, sln, "sln.startpoint")
Link to placement with offset:
link_endpoint_to_placement_on_axis(axis, plc, sln, "sln.endpoint", {1,0,0})
Loading#
In version 2024 basic support for free loads were added.
There are several features which are not supported yet:
Element-bound loads
Relative and absolute offsets on line loads
Variable loads
Create a point load:
load = sofistik.PointLoad.new()
load.position = {10,0,0}
load.type = sofistik.LoadType.PG
load.value = 10.0
Create a line load:
load = sofistik.LineLoad.new()
load.geometry:set_line({0, 0, 0}, {40, 0, 0})
load.type = sofistik.LoadType.PG
load.value = 10.0
The load distribution can be chosen:
load.distribution = sofistik.LineLoadDistribution.Uniform
load.distribution = sofistik.LineLoadDistribution.Linear
Create a line load with linear load value distribution:
load = sofistik.LineLoad.new()
load.geometry:set_line({0, 0, 0}, {40, 0, 0})
load.type = sofistik.LoadType.PG
load.distribution = sofistik.LineLoadDistribution.Linear
load.first_value = 10.0
load.last_value = 20.0
- Alternative syntax (index-based) to assign values:
load:set_value_at(0, 10.0) load:set_value_at(1, 20.0)
Area loads can be created similar to how structural areas are created. The geometry
property is similarly available.
Create an area load from an existing geometry:
area = ... -- This needs to be a closed segmented curve
load = sofistik.AreaLoad.new()
load.copy_geometry_from(crv)
load.type = sofistik.LoadType.PG
load.value = 10.0
Create an area load from 4 points:
load = sofistik.AreaLoad.new()
load.geometry:set_quad({0,0,0}, {10,0,0}, {10,10,0}, {0,10,0})
load.type = sofistik.LoadType.PG
load.value = 10.0
AutoCAD Commands, Objects and Geometry#
At any time in your script, you can run arbitrary AutoCAD commands.
Note
If an AutoCAD command does not properly end, then the script execution will be stopped.
Zoom to extents:
acad.command[['_.zoom _e]]
Create an AutoCAD line:
acad.command[[_line 0,0,0 0,5,0\n\n]]
Note
Note that \n
indicates a new line and represents pressing RETURN
in interactive mode.
Most objects share these properties:
layer |
AutoCAD layer name |
print( sln.layer )
Curve like objects share these properties:
length |
Length of the curve. |
start_point |
|
end_point |
print( sln.length )