Preview: Scripting#
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 or even be removed 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, 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
area.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
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 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:
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 })
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 |
Add 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("AXIS")
axis.geometry:set_line({0, 0, 0}, {30, 0, 0})
Create an axis AXIS
with plan view geometry:
local axis = sofistik.Axis.create("AXIS")
axis.plan_view:line(10)
axis.plan_view:clothoid(40, 999, 100)
axis.plan_view:arc(40, 100)
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)
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 )