ArchiFrame Manual ENen · Published 13 Nov 2026

25 Lua scripts

Lua is an open source scripting language that is used for various automations. Information about the language is available at: http://www.lua.org.

Archicad 21 and later: Any ArchiFrame Lua-script is using western 8-bit character set and strings are converted to/from utf-8. An exception to this are scripts loaded from xml-files – these scripts are using utf8 always internally. Script may change this default behaviour by setting global gScriptUtf8 to values:

  • •

    Missing/nil, default.

  • •

    0, script uses western locale.

  • •

    1, script is fully utf8.

Useful code pieces:

-- Dumps given variable into string
-- To use: ac_msgbox(dump(v))
function dump(o)
  if type(o) == 'table' then
    local s = '{ '
    for k,v in pairs(o) do
      if type(k) ~= 'number' then k = '"'..k..'"' end
      s = s .. '['..k..'] = ' .. dump(v) .. ','
    end
    return s .. '} '
  else
    return tostring(o)
  end
end

25.1 Additions to standard Lua

25.1.1 io.open()

To open a file with utf8 file name in Windows (in Macintosh file names have been utf8-encoded for a long time), use prefix utf8, in io.open(), for example:
local hFile=io.open(strFileName, "utf8,wt")

25.2 Built-in support functions

25.2.1 ac_elemget (strGuid [,strOptions])

strOptions, specify to get more data. Multiple values can be used, and possible values are:

  • •

    elem=0 Do not give element info (field header)

  • •

    props=1 Give all set properties in returned table field props (works starting from Archicad 22)

  • •

    props=2 As previous but property’s group name is included before property name and \t is added as separator. There may be properties with the same name under different groups, so this way ArchiFrame gives the full property path.

  • •

    props={GUID}, speed optimization to get just single property for the element. Returned property table is empty if the element does not have the requested property. Includes props=1, just property name included.

  • •

    categories=1 Give all categories in returned table field categories. The categories is 1-based array each item having fields:

    • •

      typeguid, the guid of the category type. This guid remains the same among different language versions.

    • •

      typename, the Archicad localized type name.

    • •

      valueguid, the guid of the category value. This guid remains the same among different language versions.

    • •

      valuename, the Archicad localized value name.

  • •

    classes Give classification data in returned table field classes. The classes is a table having classification system name as the key. The value is a table having fields:

    • •

      id, id of the classification item

    • •

      name, name of the classification item

  • •

    ifc=1 Give IFC-data

Returns table of given element having fields:

  • •

    header.typeID, element type number, 6 = object.

  • •

    header.floor, element floor number.

  • •

    header.layer, element’s layer number.

  • •

    header.id, element’s ID

  • •

    header.libGuid, library part guid if any.

  • •

    If requested, field props which is array of Archicad properties set for the element. Property name is the array key, for example value=props["propname"].strvalue. ArchiFrame sets property name to lowercase. The fields are:

    • •

      numvalue, set if it is a number

    • •

      strvalue, set if it is a string value

    • •

      guidprop, the guid of the property to be able to ask single property value after initial call getting the guid from here

    • •

      Value may be missing if property value type is currently unsupported (like value list)

For example, following properties:

Are returned from expression elem=ac_elemget (elemguid, "props=1") as:

elem.props["scandic_form"].strvalue="Form-test"
elem.props["scandic_manufacturer"].strvalue="Manu-test" …

25.2.2 ac_findobj (strObjName [, nUseSelection])

Fills table of selected or all object in active storey. Table contains object guids.

  • •

    nUseSelection, 0 = get all; 1 = get selected or all if no selection; 2 = just give selected objects.

Returns: The table.

25.2.3 ac_getobjparam (strObjGuid, strParamName [, nRowNum, nColNum])

Gives requested parameter from the object, door or window. Parameters nRowNum and nColNum indexing starts from 1. Value 0 is ignored and -1 returns the table dimension. For example to get number of rows, set nRowNum to -1 and nColNum to 0.

Special strParamName-values:

  • •

    #id, returns the element ID

  • •

    #layer, returns the Archicad layer as number

  • •

    #guid, returns element's internal GUID.

  • •

    #floor, returns the storey number.

  • •

    #pos.x, returns x-co-ordinate of an object or middle pos for opening.

  • •

    #pos.y, returns y-co-ordinate of an object or lower pos for opening.

  • •

    #level, level relative to object’s home storey.

  • •

    #levelglob, added also floor zero level.

  • •

    #angle, returns object angle in radians or reflected state for opening (0/PI).

  • •

    #mirroring, returns 0/1 reflected state for objects and doors & windows.

  • •

    #libname, returns library part name.

  • •

    #libguid, the same as GUID.

  • •

    #pen, default pen.

  • •

    #linetype, line type.

  • •

    #useobjlinetype, use object’s line types.

  • •

    # useobjsectattrs, negation of [ ] Override Object’s Attributes (1=use object’s attributes, 0=nope, use overrides)

  • •

    #mat, 3D material index

  • •

    #matname, 3D material name

For doors and windows:

  • •

    #wido_sill, sill value as GDL global WIDO_SILL.

  • •

    #oside, 1 if mirrored to x axis, 0 otherwise.

  • •

    #refside, 1 if mirrored to x axis same as oSide, 0 otherwise.

For ArchiFrame elements:

Value

Description

"#af_elemdata"

Gives information of the plank related to the element. The table fields are:

  • •

    x1, y1, z1, x2, y2, z2 Plank's base line coordinates relative to the element surface.

  • •

    bx1, bx2, bz1, by1, by2, bz2 Plank’s bounding box in parent elemen’s coordinates. Z-axis is element’s watching direction and is calculated ignoring any cuts in the plank unlike x- and y-coordinates.

  • •

    poly, plank’s polygon.

  • •

    index Plank's 1-based index.

  • •

    rotangle, rotation angle in degrees from element’s watching direction

  • •

If used from projection scripts (dimension collector or DoProjSettings()-function), ptr refers to projection plank’s master/3D plank. Also, then following extra fields are available:

  • •

    typetag, related element layer’s type: core, intstud etc. Always available for any element related plank when working with element Lua-scripts.

Fielrds bx*, bz* and poly are affected by piece’s end cuts. Lengthwise cuts are processed if all these conditions are met:

  • •

    It is a full length cut

  • •

    The cut makes just angle


Also, all values described <elemparam name="xxx">value</elemparam> are supported. Character # must be given before the element’s parameter name, for example #cutfill. Attribute values in this case are returned as two values: numeric and attribute name. Exceptions:

  • •

    #materialrgb returns single string. It is the material’s colour in format "RGB" where all color values are between 0…1. Decimal separator is dot, for example "0.5, 0, 0". If the material is GENERAL, the return value is "0".

Returns: The parameter numeric/string or nil = parameter missing.

25.2.4 ac_getattrinfo (strAttrGuid) or ac_getattrinfo (nTypeNum, nAttrIndex)

Gives information of an attribute. Parameter nTypeNum is one of API_AttrTypeID (using numbering from AC26, AC27 has dropped API_PenID, API_FontID and some other types):

API_PenID = 1,
API_LayerID = 2,
API_LinetypeID = 3 and so on,
API_FilltypeID,
API_CompWallID,
API_MaterialID,
API_CityID,
API_LayerCombID,
API_ZoneCatID,
API_FontID,
API_ProfileID,
API_PenTableID,
API_DimStandID,
API_ModelViewOptionsID,
API_MEPSystemID,
API_OperationProfileID,
API_BuildingMaterialID,
API_MarkUpStyleID

Special value -1 means floor number and return values are: 1. String telling the floor name, 2. Number telling floor global level.

Returns: The table having fields

  • •

    type, one of following: "fill", "composite", "type_as_number".

  • •

    name, the attribute name.

  • •

    thickness, for composite the total thickness and for composite layers, the layer thickness.

For composites only:

  • •

    num_layers, number of layers.

  • •

    Layers, table of layers each having similar fields as requested for fill, except thickness also set.

25.2.5 ac_objectopen(strGuid)

In special cases strGuid can be nil and the function will open the default object depending on the special usage case. Opens the object for further processing. The guid may also be a C pointer obtained from ArchiFrame. The C pointer start with @ and is followed by 8 (32 bit) or 16 (64 bit) characters. Use pointers with care – misuse will crash the program.

Parameter strGuid may begin with character >. For example, if used in plank observer script, it will work with last saved version skipping ArchiFrame’s object cache buffer.

Returns: Nothing, in case of error, Lua error is raised.

25.2.6 ac_objectget (strParamName [, nRowNum, nColNum])

Works as ac_getobjparam but for object opened with call to ac_objectopen.

25.2.7 ac_objectset (strParamName, value [, nRowNum, nColNum])

Sets the parameter only if changed.

Returns: Nothing, in case of error, Lua error is raised.

25.2.8 ac_objectdelrow(strParamName, row1)

Deletes given array row defined by 1-based index. Object must have been opened with ac_objectopen().

25.2.9 ac_objectclose ()

Saves changes if any to opened object.

25.2.10 ac_environment (strSel [, additional parameters])

Selector can be one of the following:

25.2.11 ac_environment ("lang")

Returns language of theArchicad: "eng", "fin" or "swe".

25.2.12 ac_environment ("ntos", nVal, strType, strPrefs)

Converts number to string using current Archicad-settings. Parameter strType can be "length"| "angle" | "area" | "volume". strPrefs is either "work", "dim"or "calc" and it reflects to Archicad working, dimension lines and calculation settings. Parameter nVal is the numeric value. Returns string value.

25.2.13 ac_environment ("units", strType, strPrefs)

Returns four values:

  • •

    Unit type as number

  • •

    Unit string

  • •

    Multiplication factor to convert from Archicad’s internal format to user preferences, 0=no conversion, for example: 1' 2/32"

  • •

    How many decimals to use if numeric

Parameters are as "ntos" but no nVal parameter is not given. First return value numbers are:

 APIUnit_Metric=0,

 APIUnit_Centimetric,

 APIUnit_Millimetric,

 APIUnit_FootInch,

 APIUnit_FootDecInch,

 APIUnit_DecFoot,

 APIUnit_Inch,

 APIUnit_DecInch,

 APIUnit_Decimetric,

 APIUnit_DecYard,

 APIUnit_Gallon

Please note that from AC22 on the values are (decimetre added so check the unit string for imperial check):
 Meter,

 Decimeter,

 Centimeter,

 Millimeter,

 FootFracInch,

 FootDecInch,

 DecFoot,

 FracInch,

 DecInch

25.2.14 ac_environment ("userorigin")

Returns X, Y, Z of the user origin.

ac_environment ("reflevels")

Returns two numeric reference levels defined in AC.

25.2.15 ac_environment ("parsetext", strIn)

Parses texts having Archicad automatic texts like <ARCHITECT>. Returns parsed string.

25.2.16 ac_environment ("createguid")

Creates new GUID in form {4CABE438-C7F5-4B43-A6DF-B07114D6BDDF}.

ac_environment ("strreplace", strSource, strFind, strReplace)

Does find & replace without any character being pattern.

25.2.17 ac_environment ("layer", strName, nShow, nSetMask)

Shows (1) or hides (0) given layer(s). Name may contain wild characters * and ?, for example, “structural*”. If parameter nShow is -1, it will return the state of the layer (if wild card, the state of first matching layer). State is bit combination:

  • •

    1, bit0, is visible: 0 = hidden, 1 = visible.

  • •

    2, bit1, is locked.

  • •

    4, bit2, is mine in TeamWork.

  • •

    16, bit4, is forced to wireframe.

  • •

    32, bit5, the layer belongs to an Xref.

Optional parameter nSetMask defines which bits to apply from nShow to the layer status bits.

Another mode is nShow with value -2. Then the given layer will be created as visible if it is not created already (then its status is not changed). Call this again to set the status of newly created layer if needed. Returns negative error code if creating the layer failed, otherwise positive layer index.

Returns numeric status of the edited layer

25.2.18 ac_environment ("rebuild", nRegenerate)

Rebuilds display (for example after showing/hiding layers). With nRegenerate value 1 rebuild is done deeper.

25.2.19 ac_environment ("tolog", strText)

Puts given text to a log window (not a dialog).

25.2.20 ac_environment ("bittest", value, bitnum)

Returns value 0/1 for given bit in the value. Parameter bitnum must be between 0…31.

25.2.21 ac_environment ("getsel")

Returns table of selected element’s guids. Processes all element types. Return value nil means no selection.

25.2.22 ac_environment ("setsel", tblGuids)

Sets selection to given guid tbl which must start indexing from [1]. Nil = remove selection.

25.2.23 ac_environment ("suspendgroups", bSusped)

Sets suspending the groups to given bool value (false = nope, others = suspend). Returns previuous state of suspending: false = not suspended, true = yes.

25.2.24 ac_environment ("getcurrwindow")

Returns type of current window:

  • •

    1, floor plan (Google for text APIWind_FloorPlanID to get all values).

  • •

    2, section.

  • •

    3, detail.

  • •

    4, 3D window.

25.2.25 ac_environment ("getall", nFilterBits, nElemType1, nElemType2,…, nElemTypeN)

Returns table of all element’s guids (never nil but table can be empty).

nFilterBits as in API-calls, for example APIFilt_OnVisLayer|APIFilt_OnActFloor is 2+4 = 6. -1 = default: APIFilt_OnVisLayer|APIFilt_OnActFloor if current window is floor plan; APIFilt_OnVisLayer if current layer is anything else. ArchiFrame sets global gnListingAll to value 1 if selected (*) whole model even if in floor plan.

25.2.26 ac_environment ("filterelem", guid, nFilterBits)

Checks if given element fulfils the filter (for example is on visible layer which is number 2). Returns true or false.

ac_environment ("filedialog", bSaveAs, strTitle, strFilter, strFileExt)

Runs open or save as file dialog if bSaveAs is true. Parameter strTitle is the title of the dialog box, strFilter is in format "Text files (*.txt)|*.txt|All (*.*)|*.*|", strFileExt is the default file extension without the period. Returns nil if cancelled.

25.2.27 ac_environment ("findattr", nAttrType, strAttrName)

Find given attribute by name, strAttrName may contain wildcards and multiple values may be given with vertical bar. Returns 0 if not found.

ac_objectset("iMc", ac_environment("findattr", 6, "*tre-osb*|Tre-Mahogny"), add, 10)

nAttrType must be one of following (number increases by one for each line).

API_PenID = API_1,
API_LayerID,
API_LinetypeID,
API_FilltypeID,
API_CompWallID,
API_MaterialID,
API_CityID,
API_LayerCombID,
API_ZoneCatID,
API_FontID,
API_ProfileID,
API_PenTableID,
API_DimStandID,
API_ModelViewOptionsID,
API_MEPSystemID,
API_OperationProfileID,
API_GraphicOverrideID,
API_BuildingMaterialID,

25.2.28 ac_environment ("luacomchars", nCodePage)

Sets LuaCOM-interface’s global character set. Default is ANSI (0) and other possible value is UTF8 (65001). Returns previous setting that must be restored so that other sripts are not affected.

25.2.29 ac_environment ("acver")

Returns current Archicad-version as number: 19=1900, 20=2000, 21=2100 etc.

25.2.30 ac_environment ("solidsub", tblTargets, tblOperators)

Makes solid subtraction connection between all targets and operators that have intersecting bounding box. Both tables must be 1-based arrays.

25.2.31 ac_environment ("scriptdir")

Returns two values:

  1. 1.

    Path to the script not including the last path character (C:\Folder for example or C: if root folder)

  2. 2.

    Current path sepator character, either "/" or "\"

25.2.32 ac_environment ("mkdir", strPath)

Creates given folder. Returns true=succeeded, false=failed

25.2.33 ac_environment ("setautotext", strKey, strVal)

Sets given autotext. Please note that strKey is given without <>. Causes an error if fails. Example:
ac_environment("setautotext", " PROJECTNAME", "My Project")

25.2.34 ac_environment ("gridnext", x, y, dirx, diry)

Calculates next grid position from given position in given direction and returns information about the grid. Returns four values:

  • •

    Status: 0=no suitable grid, 1=moved to grid but grid not parallel or in 90 deg angle to the direction vector, 2=grid was parallel to direction vector and the result is good.

  • •

    x, y: the coordinates of the calculated position

  • •

    Information of the grid as a table having fields:

    • •

      x,y,z Grid origin

    • •

      angle Grid angle in radians

    • •

      mainx,mainy Spacing

25.2.35 ac_msgbox (strText)

Shows message box. Useful for debugging.

25.2.36 ac_mbstoutf8 (strIn)

Converts given text encoding into UTF8. Returns converted string.

25.2.37 ac_utf8tombs(strIn, codepage)

Converts given utf8 text into requested codepage. Parameter codepage must be ne of the following numbers:

CC_Default		= 0,
CC_System		= 1,
CC_User		= 2,
CC_Application	= 3,
CC_Legacy		= 4,

CC_WestEuropean	= 11,
CC_EastEuropean	= 12,
CC_Baltic		= 13,
CC_Cyrillic		= 14,
CC_Greek		= 15,
CC_Turkish		= 16,

CC_Hebrew		= 21,
CC_Arabic		= 22,

CC_Thai		= 31,
CC_Japanese		= 32,
CC_TradChinese	= 33,
CC_SimpChinese	= 34,
CC_Korean		= 35,

CC_Symbol		= 40

Returns converted string.

25.2.38 ac_geo (strSel [, additional parameters])

Selector can be one of following:

ac_geo ("linex", x1first, y1first, x2first, y2first, x1second, y1second, x2second, y2second)

Gives intersection point of two lines. Lines are infinite length. Returns: No value = no intersection pt, (X, Y) = the intersection point.

ac_geo ("linedist", x1, y1, x2, y2, x, y)

Calculates point distance from line. Return three values: Distance from the line (negative to the left and positive at right hand side), distance from beginning point towards end (negative before line starting point) and length of given line.

ac_geo ("calctranworld3", origfrom, vecxfrom, vecyfrom, veczfrom, origto, vecxto, vecyto, veczto)

Calculates transformation matrix [1...12] for given coordinate worlds. Returns table [12]. To transform a point, use:

Xnew = x*tblTran [1]+ y*tblTran [2]+ z*tblTran [3]+tblTran [4].

Ynew = x*tblTran [5]+ y*tblTran [6]+ z*tblTran [7]+tblTran [8].

Znew = x*tblTran [9]+ y*tblTran [10]+ z*tblTran [11]+tblTran [12].

Due to historical reasons, the offset values at [4], [8] and [12] work only with global coordinate system. Please find function MatInitTran from default ArchiFrameElements.xml to see how to transform from any world to any other world.

ac_geo ("matmul", mat1, mat2)

Multiplies matrix1 with matrix2. Matrices are in format calctranworld3 uses, col 4 is just added.

ac_geo ("linepolyx", x1, y1, x2, y2, tblPolys, [extendLine=false, onEdgeInside=true])

Calculates intersection of given line and table of polygons (format as in af_request (“getpoly”,…)). TblPolys is 1-based table of separate polygons (to be able to handle split surfaces).

If the two last parameters are missing, the shown default values are used.

Returns 1-based table of line segments each segment having fields x1, y1, x2, y2. Nil if there is no intersection.

ac_geo("polysdist", poly1, poly2)

Calculates minimum distance between two polygons (not polygon lists).

Returns the distance, 0=intersecting or touching.

25.2.39 ac_optiondlg (strID, strTitle, tblSettings)

Runs setting dialog and saves settings application a specific way – usually to user specific configuration file and to the current pln-file. Dialog looks like:

And code to run this is:

gbAskOptions=true
gbCnc-ToDb=true

-- CNC- writing settings, raises error if canceled
function GetCnc-Options()
	local	tblSettings, bRes, sErr, s, n

	-- Ask only once
	if gbAskOptions==false then
		return true
	end

	tblSettings={}
	tblSettings		[1]	={}
	tblSettings[1].cfgonly	=1
	tblSettings	[1].type	=2
	tblSettings[1].prompt	="Save CNC- to production DB"
	tblSettings	[1].key	="cnc-db"
	tblSettings[1].defvalue	=0

	tblSettings		[2]	={}
	tblSettings[2].cfgonly	=1
	tblSettings	[2].type	=1
	tblSettings[2].prompt	="Handling of oversized up/downcuts"
	tblSettings	[2].key	="cnc-cut"
	tblSettings[2].valuelist="\"1:Do not write cnc-\",\"2:Write cnc-\""
	tblSettings[2].defvalue	=1

	bRes,sErr=ac_optiondlg("LDCN", "CNC- settings", tblSettings)
	if not bRes then
		if sErr~=nil then
			RaiseError(sErr)
		else
			RaiseError("CANCELLED")
		end
	else
		if tblSettings[1].value==0 then
			gbCnc-ToDb=false
		else
			gbCnc-ToDb=true
		end
	end

	gbAskOptions=false
end

Parameters:

Param

Description

stride

Four letter long ID of the settings. Always start ID with LD not to mix it with application's own settings. For example LDCN.

strTitle

Dialog title, set to nil if you just want to get the saved settings into the table tblSettings. No dialog is shown in this case.

tblSettings

Table of the settings items.

Return values: Boolean bRes, string strErr: bRes is true if dialog was run ok and closed with OK, false in case of internal error or dialog cancelled. In case of internal error strErr is set.

Settings table has fields:

Field

Description

cfgonly

Optional number:

  • •

    0 or missing, save option to cfg and pln-file.

  • •

    1, save setting only to cfg-file (global to user).

type

Numeric type:

  • •

    1, value list/combo box.

  • •

    2, check box.

  • •

    3, length edit.

  • •

    4, any text.

prompt

To setting-column in the dialog.

key

Unique key for the setting inside this setting dialog.

defvalue

Default value to be used if no previously saved settings.

value

If given for input: Value is not loaded from settings but instead this value is used.

On output: The actual setting.

valuelist

Given if type is 1. Contains items in format: "Number: Item text". Number is used as unique ID for the item. Items are separated with comma. Note Lua syntax for adding quotation marks in the string: "\"1:Do not write cnc-\", \"2:Write cnc-\"".

25.2 ArchiFrame-specific functions

25.2.1 af_request (strSelector [, additional parameters])

Parameter strSelector defines what is requested:

Value

Description

"getstring"

str = af_request("getstring", str_id, lang_code)

Gives the localized string from data/ArchiFrameStrings.

  • •

    str_id is the id=”xxx” in the xml-file:
    <string id="pieces">pcs</string>

  • •

    lang_code can be omitted, then the current ArchiFrame language string is given

Example: af_request("getstring", "pieces")

Returns the localized string or parameter str_id if the string is not found.

"singlemat"

TblMat = af_request ("singlemat", "id"), returns table for single material or nil if material does not exist. Passed id is searched for case insensitive. Fields are:

  • •

    id, material id.

  • •

    name, name.

  • •

    shape, "block" | "plane" | "round".

  • •

    thickness, height, in meters.

  • •

    height, in meters.

  • •

    m3factor, volume factor.

  • •

    typename, the name to show in UI: If id and name are different: name (id), or just id if they are the same.

  • •

    xmlutf8, full xml-definition of the material. Used for example in quantity takeoffs to read extra attributes from ArchiFrameBlocks.xml

"matlist"

Returns table of all materials in material list as Lua hash-table (not 1-based indexed table). They key is the material ID and data is what singlemat gives plus field index telling the 1-based index in the order the materials are defined in ArchiFrameBlocks.xml.

"plankinfo"

tblRes = af_request ("plankinfo", strPlankGuid, plankInfoProj, tblSettings), returns information about given plank. If strPlankGuid is missing, uses currently opened object/plank. If plankInfoProj is given, it contains projection information. tblSettings is optional settings. More info later.

It is possible to get geometry information for element objects (in that case returns the framing geometry taking possible rotframing="x" attribute into account) or even Archicad beams, walls, doors, windows and columns too by giving strPlankGuid. Table has fields:

  • •

    ptr, plank’s or board’s internal C-pointer (memory address) starting with character @ and followed by 8 or 16 digit hex address. Can be used as plank identifier in plank operations and in ac_objectopen. Ptr is valid only during current operation – it may not be saved for later use and misusing ptr will cause whole program to crash.

  • •

    guid, plank’s guid (nil for new pieces not yet created into Archicad).

  • •

    type, 1 = plank, 2 = log object, 4 = board.

  • •

    begc,  start point in model coordinates beg. X, Y, Z.

  • •

    endc,  end point in model coordinates end. X, Y, Z.

  • •

    len, plank length.

  • •

    width, width.

  • •

    height, height.

  • •

    typename, plank/board type name for listings.

  • •

    matname, the name="xxx" from ArchiFrameBlocks.xml

  • •

    vecx, vecy, vecz, plank’s geometry axes.

  • •

    masterelemguid, guid of the floor plan/3D piece if current part is projection piece

  • •

    ownerelemguid, if belonging to an element, the owning element’s guid. Missing if not part of an element. You can use for example "elem_quantities" with this guid.

  • •

    ownerelemid, if belonging to an element, the owning element ID string. Missing if not part of an element.

  • •

    del, true = marked for delete, false = nope. 

  • •

    begoff, for log object cnc-writers: Offset from X-coordinate zero point to actual plank start. Positive extends, negative shortens (opposite to plank dir).

  • •

    tblWeather, set if the plank is part of weather boards. Has fields:

    • •

      wbguid, GUID of the weatherboard group, actually GUID of the plank holding the whole group’s internal data.

    • •

      pa, pb, pc, pd, plane equation – pa, pb, pc is the normal vector towards the wall.

    • •

      vecy, vertical vector X, Y, Z.

    • •

      vecx, horizontal vector always pointing right looked to the surface from normal vector's opposite direction.

  • •

    tblSides, table of geometry for each side [1]…[6] each having fields:

    • •

      origc, 3D origin.

    • •

      vecx, vecy, Direction vectors for surface axes.

    • •

      vecz, normal vector pointing outside of the piece.

    • •

      dx, dy, surface size in X- and Y-directions.

  • •

    idgenerated, if plank/board has parameter “ID generation string” set, this is the visible ID as parsed in the object.

Quantities if requested:

  • •

    kgpermeter, for planks only. Use with len. Only if tblSettings.quant>=1

  • •

    kgperliter, for boards only. Use with net area or board’s gross area. Only if tblSettings.quant>=1

  • •

    acvol, the real GDL-object’s volume. Only if tblSettings.quant>=2 and succeeded. Slow to calculate.

If plankInfoProj is given, the plank is projected to given plane. Result is saved to field elemdata and has the same members as with #af_elemdata. Parameter plankInfoProj must contain fields (plankinfo queried for an element is fine):

  • •

    begc, plane’s origin.

  • •

    vecx, vecy, vecz, 3D axes

Optional tblSettings may contain following fields:

  • •

    idsep Given to override object’s parameter iShowIDSep. Useful in cut lists to get real projection visible ID.

  • •

    quant If set to non-zero, ArchiFrame gives quantity information

Returns nil if failed.

"parseinfo"

af_request("parseinfo", strParse, guidPlankBoard)
Parses special
tags inside parameter strParse. Please see the list of the tags.

Returns the parsed string.

“getpoly”

tblRes = af_request ("getpoly", tblSettings, strPlankGuid), returns polygon information for given strGuid elem (plank, board, element). If strPlankGuid is missing, uses currently opened object/plank. If the given strPlankGuid refers to an ArchiFrameElement-object, this returns the framing polygon taking possible rotframing="x" attribute into account.

tblSettings for boards may be nil. If given, it may contain following fields:

  • •

    side, 1 = top, 2 = front, 3 = bottom, 4 = back. Which side to process.

  • •

    tblguids, instead of processing single part’s polygon, unify polygons of all given elements. Useful for example to join exploded cladding pieces.

  • •

    polynum,  if surface is split by groove(s), there may be multiple polygons. Number of the polygon to return 1…N. If missing 1st one will be returned.

  • •

    tooldia, milling tool diameter for overbegin and overendin, default = 10 mm.

  • •

    holes, value:

    • •

      Missing, give full polygon with holes.

    • •

      0, throw holes away.

    • •

      1, will return list of holes (openings) in the element. If given result field poly is 1-based array of the holes polygons.

  • •

    continuous, value:

    • •

      0 no change to polygon(s)

    • •

      1 add 0,4 mm part to the polygon top and bottom to get holes for doors which may extend to the bottom of the wall. If no setting holes specified, the 0,4 mm filling will be added inside the polygon. With holes, filling is added to the outside. Acts like this setting:

  • •

    expand, if given, the value to expand the polygons, positive gives bigger polygons (also if holes requested), negative smaller.

  • •

    fromboard, with value 1 gives polygon list from the boards belonging to the element (same format as for holes). May contain many polygons if surface is split. In owning element’s rotated coordinate world.
    With value 2 the polygon extra info is taken from board object’s parameter iPolygon. With value 2 parameter strPlankGuid must be a board guid. Result fields overbegin, overendin and cutfromobj come from object instead of calculated values. Use value 2 only if board object’s parameter iSawlines is nonzero. NOTE! If holes are requested, they will be returned clockwise instead of standard ccw for contour line. Value 2 implies also givelist = 1.

  • •

    givelist, with value 1 returns always [1]-based polygon list. Otherwise single polygon unless holes or fromboard is given.

  • •

    calcopening, with value 1 calculates openingtype-field using the related element object’s links to Archicad-walls/openings.

  • •

    camera, if given contains projection plane as given from "plankinfo"-request:

    • •

      begc, plane’s origin.

    • •

      vecx, vecy, vecz, 3D axes.

Returns table having following fields or nil = not supported type:

  • •

    numpolys, number of polygons (in case of split surface).

  • •

    x1, y1, x2, y2, the bounding box of the polygon. Currently polygon is always normalized to have x1, y1 at 0, 0. Not valid if holes or expand given.

  • •

    xoff, yoff, currently always 0, 0. The offset from the lower left corner of the raw board material. Not valid if holes or expand given.

  • •

    area, area of the polygon(s) with holes reduced.

  • •

    poly, if single polygon: [1]-based array of polygon points from the front surface. If givelist was specified, is 1-based array to single polygon’s point array. Contour end points are not duplicated to be same as contour begin. Each point has members:

    • •

      x,y, the point position.

    • •

      isbeghole, set only if point is begin of a hole.

    • •

      isendcontour, set only if point is end of a contour.

    • •

      isendpolygon, set only if point is last point of the polygon, always with isendcontour.

    • •

      overbegin, length of line inside the polygon extended by tooldia from next point to current point. Use to check for any overcut in cnc.

    • •

      overendin, length of line inside the polygon extended by tooldia from previous point to current point. Use to check for any overcut in cnc.

    • •

      cutfromobj, if board object had parameter iSawlines set, this tells if the cut from current point to next point is set by user: 0 = no cut, 1 = do the cut.

    • •

      openingtype, if edge from current pt to next pt is related to an opening (set only for element objects):

      • •

        0, not related to an opening or related to an empty opening.

      • •

        11 window top.

      • •

        12 window right.

      • •

        13 window bottom.

      • •

        14 window left.

      • •

        15 window unknown.

      • •

        21-25 door similar.

      • •

        111-115 empty window similar.

      • •

        121-125 empty door similar.

  • •

    err, error message if there was an error in extend operation. nil =ok.

“delplank”

Marks currently opened object/ac_objectopen() to be deleted. Deletes all related projections etc.

"getselplanks"

Returns guid table of selected plank objects. If selection contains projections, its master 3D plank will be returned instead. For historical reasons indexing of this starts from [0] and you need to use Lua pairs instead of ipairs:

for i,v in pairs(tblSel) do

xxx

end

To get only boards, give second parameter “board”. With any other value, only planks are collected.

tblBoards = af_request ("getselplanks", "board")

All planks&boards having parameter’s Special type value 1 (part of combined element source) are skipped.

"getsellisting"

Returns table to be used as source elements for listing/cnc-. If anything selected, the lists are limited to the selection. If no selection, the result contains:

  • •

    All visible elements in current floor if in floor plan.

  • •

    All visible elements in the model if in 3D.

In both cases all planks&boards having parameter’s Special type value 1 (part of combined element source) are skipped.

Returns 1-based array of tables containing fields:

  • •

    guid

  • •

    ptr

  • •

    id

  • •

    type, element type as:

    • •

      1 = plank.

    • •

      2 = log.

    • •

      4 = board.

If no elements, returns nil.

"getselelemobjs"

Returns 1-based table of guids for ArchiFrameElement-objects related to selection.

"afclick"

t=af_request("afclick", tblSettings)

Asks user to click a plank or board. Parameter tblSettings has fields:

  • •

    line, true will cause ArchiFrame to ask for two points

  • •

    prompt, the prompt shown at bottom of Archicad-window while waiting the user to click in the model.

  • •

    elems, elements where user can click. Typically selection.

Returns table having fields:

  • •

    begc, first clicked point

  • •

    endc, if line was requested

  • •

    elems, table of clicked elements each having fields

    • •

      guid, guid of the clicked plank/board

    • •

      side1, 1-based side number: 1=top, 2=front, 3=bottom, 4=back, 5=begin, 6=end

    • •

      x1,y1: First clicked point on surface coordinates

    • •

      x2,y2: Set if line was requested

Please see data-folder/ArchiFrameBlocks.xml part <mctool name="Element lifting drillings floor" for an example.

"autocut"

t=af_request("autocut ", tblSettings)

Automatically cuts planks with given settings. Parameter tblSettings may have these fields:

  • •

    elemguid, required guid of the element layer to process. ArchiFrame automatically finds the supporting layer under the target.

  • •

    minlen, piece’s minimum length (default is 500 mm)

  • •

    maxlen, maximum length for a piece, 0=use the maxlen defined for the plank type (default is 0)

  • •

    minoverlap, minimum distance of cuts between adjacent studs (default is 600 mm)

  • •

    overlapruledist, maximum distance where minoverlap has effect. With default value 1200 mm, a cut 1200 mm or more from target will not have any effect

  • •

    gap, extra total gap between cut pieces. Previous values are used without taking this gap value into account.

Does not return any value. The error message is dumped to the log window in case of error.

"flushmc"

Flushes ArchiFrame’s internal machining table to the object’s parameters. Must be used after calling "adjustbegend" and similar for temporary plank before closing the plank to get all machinings offset correctly.

Also normalizes the board’s polygon which is needed if you adjust the x1,y1 from 0,0. If the polygon’s origin was not 0,0 the machinings are moved accordingly.

“getbegendplane”

TblPlane = af_request ("getbegendplane", "beg", nOptions).

Returns global cutting plane for current plank’s begin or end (replace “beg” with “end”). Parameter tblPlane has fields pa, pb, pc, pd defining the plane equation.

With numeric values any side can be queried, replace “beg” with values (see About the planks):

  • •

    “1”, top.

  • •

    “2”, front.

  • •

    “3”, bottom.

  • •

    “4”, back.

  • •

    “5”, begin.

  • •

    “6”, end.

If parameter nOptions is missing or is 0, first cut for begin or end will be returned. With value 1, the result is always straight relative to the plank.

“adjustbegend”

af_request ("adjustbegend", "beg", tblPlane).

Adjusts currently opened plank’s end (“beg” or “end”) to given global plane. Parameter tblPlane has fields pa, pb, pc, pd defining the plane equation.

"cutplank"

af_request ("cutplank", tblPlane)

Splits currently opened plank into two pieces. Parameter tblPlane defines the cutting plane in global coordinates.

Returns values:

  • •

    None à no valid cut – plank untouched.

  • •

    strPtr à Return value is the guid/ptr string of the new plank.

"joinplanks"

af_request ("joinplanks", strGuid1, strGuid2).

Joins given planks together. The requirements to join are:

  • •

    Planks must be parallel.

Returns: true = ok and strGuid2 marked to be deleted at the end of the undo-scope, nil = nothing done.

"adjusttoside"

af_request ("adjusttoside", tblSettings, strGuidTarget, tblGuidOperators).

Adjust to side operation as with adjust to side tool palette. Parameter tblSettings may have fields.

  • •

    doadjust, 0 = no adjusting, 1 = adjust (default).

  • •

    gap, gap in the joint, default = 0.

  • •

    cutop, how to cut:

  • •

    0 = just cut (default).

  • •

    1 = remove upwards.

  • •

    2 = remove downwards.

  • •

    3 = keep the part closer to set keep origin.

  • •

    endshape, the end shape:

  • •

    0 = angled, extend and keep existing cuts (default).

  • •

    1 = as 0 but do not extend.

  • •

    2 = as 0 but delete any existing cuts.

  • •

    3 = straight not intersecting with operator piece delete existing cuts.

  • •

    4 = straight extend to touch operator plane fully delete existing cuts.

  • •

    5 = as 4 but do not delete existing cuts.

  • •

    planepa, planepb, planepc, planepd, use this plane instead of operators.

  • •

    keeporig, table xyz of origin to define which part to keep.

  • •

    cuttoendplane, adjust to last intersecting plane instead of the first: 0 = no (default), 1 = yes.

  • •

    expandopfind, if given, the operator is expanded with given value to test if there is an intersection between the planks. Useful to handle cases where angled planks touch just with a corner.

  • •

    skipopsides, bit mask to skip checking operator sides. bit0 = top, bit1 = front etc. Bit 1 means skip checking this operator side. Default = 0, do not skip any side.

  • •

    domark, 0 = no marking (default), 1 = markings.

  • •

    marklines, 0 = to sides, 1 = to center.

  • •

    marktext, text for marking, tags as in the tool palette.

  • •

    markposx, text position 0 = left, 1 = center, 2 = right.

  • •

    markposy, text position 0 = bottom, 1 = center, 2 = top.

  • •

    markfontsize, in centimeters, 0 = default.

  • •

    markdir, text in line’s direction.

Returns: nil = nothing done, tblNewPlanks = table of edited/new planks from the operation.

“editplank”

af_request ("editplank", tblEdit)

Edits single plank, tblEdit has following fields (give only the fields to edit). Edits are applied in order of this list (mat before xmlsetting for example):

  • •

    guid, must be given.

  • •

    createtemp, if set to value 1 (please note numeric, not bool), the original plank remains as it is and ArchiFrame creates temporary item which is deleted when current operation ends. Does not copy operations linked to the original piece.

  • •

    duplicate, if set to value 1 (please note numeric, not bool) creates a copy of the source that can be edited with other fields below. Works with element and non-element related planks.

  • •

    mat, plank material id.

  • •

    thickness, sets the thickness if the original material ID is variable size block. Do not specify if giving fixed size mat.

  • •

    height, sets the height if the original material ID is variable size block. Do not specify if giving fixed size mat.

  • •

    setpos,sets new begin and end coordinates and allows changing the orientation of the plank with vecz. This is a table having fields:

    • •

      begc, new begin coordinates x, y, z

    • •

      endc, new end coordinates x, y, z

    • •

      vecz, new z-axis x, y, z

  • •

    xmlsettings, any settings to apply to the plank. Needs to have any parent tag (for example <s></s> and then children as described here.

  • •

    elemdata, geometry in element’s coordinate world. If begin or end is edited, give all three XYZ-coordinates.

  • •

    swapdir, if set to value 1 (please note numeric, not bool) current plank will be swapped

  • •

    save, with number value 1 makes sure the plank has guid and exist in Archicad.

An example of making duplicate and moving it in global z one meter up:

local tblEdit = {}

tblEdit.guid = guidPlank
tblEdit.duplicate = 1
tblEdit.setpos = {}
tblEdit.setpos.begc = {x = info.begc.x, y = info.begc.y, z = info.begc.z + 1}
tblEdit.setpos.endc = {x = info.endc.x, y = info.endc.y, z = info.endc.z + 1}
tblEdit.setpos.vecz = {x = info.vecz.x, y = info.vecz.y, z = info.vecz.z}
tblEdit.mat = "STD 2x6"
tblEdit.save = 1

af_request ("editplank", tblEdit)

Returns ptr in form @1234567812345678 to the original or temporary item.

"boardgap"

af_request ("boardgap", tblGuids, tblSettings)

Adds specified gap between board edges. Parameters:

  • •

    tblGuids, 1-based table of boards to process

  • •

    tblSettings, settings used in the process. Fields:

    • •

      gap, gap to leave between touching edges between the boards

"cmpplanks"

af_request ("cmpplanks", strGuid1, strGuid2).

Compares two planks (not comparing the IDs). Comparison can be used for example in listings to make sure that planks having similar ID are similar. Return value:

  • •

    nil, could not compare – only planks and boards are supported.

  • •

    <0, item1 < item2.

  • •

    0, item1 = item2.

  • •

    >0, item1 > item2.

"checkids"

af_request ("checkids", tblGuids).

Checks that given planks & boards with the same ID are really the same. Parameters:

  • •

    tblGuids, 1-based array of items to check. Can contain also @ptr in addition to GUIDs.

Returns: true=all good, false=errors found and dumped to the log window

"plankx"

af_request ("plankx", strGuidTarget, sideTarget, strGuidCheck)

Checks if there is intersection between two planks. Parameters:

  • •

    strGuidTarget, target plank

  • •

    sideTarget, intersection bound box is calculated to this side 1-6

  • •

    strGuidCheck, the other part of the intersection

Returns table with fields:

  • •

    poly, nil if no intersection to sideTarget. Otherwise has bounding box with fields bx1, by1, bx2, by2 in target side’s coordinates

  • •

    polyclip, as previous but clipped to the actual surface ignoring any machinings in the plank.

  • •

    plankinfox, target plank shrunk to cover the common area, nil=no intersection.

"mc_getenv"

af_request ("mc_getenv")

Retrurns environment information for cnc-writers in a table having fields from ArchiFrameBlocks.xml / cnclimits:

  • •

    gromaxdepth

  • •

    nailmindistplank

  • •

    nailmindistboard

  • •

    dtangle in degrees

"mc_getnewmcid"

af_request ("mc_getnewmcid")

Generates new machining id for the plank opened by ac_objectopen().

"mc_findtextpos"

af_request ("mc_findtextpos", nSide14, dX1, dTextWidthMeter, dFontHeightMeters)

Calculates position for plank ID that is as close as possible to dX1. If parameter dFontHeightMeters is given, its value is used instead of the text size in the ArchiFrame marking.

Moves the text away from any existing markings and grooves.

Returns the best calculated position.

"mc_explodepanel"

af_request ("mc_explodepanel", guidBoardElem, tblSettings).

Explodes given ArchiFrameBoard-object into separate temporary planks that will not be created into the model (to be used for listings and cnc-).

  • •

    guidBoardElem, guid of the ArchiFrameBoard-object.

  • •

    tblSettings, currently not supported.

Returns 1-based table of plank @pointers. Nil = no planks created.

"mc_nailings"

af_request("mc_nailings", tblTargets, tblGuidsBehind, tblSettings)

Makes nailings to given planks or boards.

Parameter tblSettings may contain following fields:

  • •

    spacing_edge, spacing at board edges. Default = 100 mm.

  • •

    spacing_mid, spacing at middle of board. Default = 200 mm.

  • •

    mindist_board, minimum distance from the board edge. Default = 10 mm.

  • •

    maxdist_board, maximum distance from the board edge. Default = 25 mm.

  • •

    mindist_plank, minimum distance from the plank edge. Default = 10 mm.

  • •

    mindist_nails, minimum distance between nails in planks. Default = 25 mm.

  • •

    spacing_plank_cross, spacing for crossing planks, default = 50 mm.

  • •

    spacing_plank_parallel, spacing for parallel planks, default = 200 mm.

"mc_sawcuts"

af_request ("mc_sawcuts", guidElem, bViewBack, bAllowOrphan, tblSettings)

Finds all placed ArchiFrameSawCut-objects that are over any projection of boards owned by given element using default orientation having saw blade on the right side. Parameters:

  • •

    guidElem, GUID of the element whose saw cuts are returned.

  • •

    bViewBack, false = View from front (default), true = from back.

  • •

    bAllowOrphan, false = only collect saw cuts touching boards (default), true = map saw cuts to the closest projection

  • •

    tblSettings, optional settings that may have fields:

    • •

      frontside, collect saw cuts only from projections having this side 1-6 in the front at the projection. 0 or missing=no limit (default)

Returns 1-based table of saw cuts ordered by lineindex (main contour first) each item having fields:

  • •

    x1,y1,x2,y2, coordinates on given element’s coordinate system looked from front.

  • •

    angledeg, saw blade angle looking in saw line direction positive tilts to left and neg to right.

  • •

    depth, cut depth, 0 = through the layer.

  • •

    overbeg, 0 = no overcut at begin, 1 = overcut at begin.

  • •

    overend, as previous for the end.

  • •

    bladeside, -1 = left from the line, 0 = center, 1 = right.

  • •

    elemguid, saw blade element guid.

  • •

    ishole, is it for polygon’s hole 0/1.

  • •

    lineindex, order number inside polygon, holes indexes start from 1000000, if polygon is split, the gap between each is 1000. Successive numbers combine single contour line (for polygon contour or poygon hole).

"mc_hatches"

af_request ("mc_hatches", guidElem, bViewBack, strLayer).

Finds all Archicad hatches from given layer that are over any projection owned by given element. Parameters:

  • •

    guidElem, GUID of the element whose saw cuts are returned.

  • •

    bViewBack, false = View from front, true = from back and swap coordinates.

  • •

    strLayer, layer name where to collect the hatches, empty means all layers

Call mc_sawcuts before this to specify bAllowOrphan.

Returns 1-based table of hatches each item having fields:

  • •

    elemguid, saw blade element guid.

  • •

    poly, hatch polygon

"mc_getacc"

af_request ("mc_getacc", guidElem)

Finds all placed ArchiFrameAccessory and ArchiFrameElMarkers-objects that are inside any projection of given element. Scans all projections and related objects. In future may return more library part. Please check ac_elemget.header.libGuid to process the correct library parts and use ac_environment ("filterelem") to get only visible ones if needed. Parameters:

  • •

    guidElem, GUID of the element

Returns 1-based table of resulting guids or nil=no objects related to the element.

"mc_getcutinfo"

af_request ("mc_getcutinfo", tblInfo)

Calculates information if a cut projected to one of the plank’s sides. Parameters are given in a table which has fields:

  • •

    guid, required GUID of the element that is processed

  • •

    mcindex, required 1-based index of the machining to process

  • •

    cutlineside, optional 1-based side number where to anchor the cut

Returns a table having fields (btl-fields refer to btl cut code 010), angles are in radians:

  • •

    fullcut, does the cut go cut whole plank: 0=no, 1=yes

  • •

    side1, 1-based best surface to anchor the cut

  • •

    x1, y1, x2, y2, cur plane’s line on the surface

  • •

    btl_p06, angle between cut edge and reference edge

  • •

    btl_p07, inclination between face and reference side

  • •

    btl_p08, lengthwise angle at cut bottom

  • •

    btl_p11, depth of the cut

  • •

    btl_p12, Length of the cut (from x1,y1 à x2,y2)

"aflang"

Language selected into ArchiFrame: eng/fin/swe/nor/ger/ita.

"afpaths"

Gives current settings paths ending to path separator character (\ in Win and / in Mac) as multiple return values:

1. Current path of the add-on folder

2. Current data folder

3. Current user specific data folder

"dim_section"

af_request("dim_section", strLayer, tblSettings)

Available only in dimension line scripts. Parameters:

  • •

    strLayer, comma separated list of layers to include. Wild card characters *? are accepted.

  • •

    tblSettings, if given may contain fields:

    • •

      skipbottom, value 1 will remove bottom_force planks from the resulting polygon list if there is at least one 2ndbottom_force plank in the element.

    • •

      projtype, if given and set to value "full", will take infinite projection instead of zero depth on the projection plane.

    • •

      filterfunc, a Lua-function name to decide whether a piece will be included in the operation (true) or not (false). The function signature is:
      function SectDimFilterCoreR(ptrPlank, typetag)
      return true -- to include

      end

      The parameters passed to it: the ptr to the plank and its typetag (bottom_force etc).

Builds table of section polygon bound boxes. Section is made unifying the ArchiFrameElement-objects and the related planks/boards. Each returned table cell has these fields:

  • •

    x1, y1, x2, y2 Polygon bounding box

  • •

    ?_minx, ?_miny, ?_maxx, ?_maxy The closest and furthest polygon point polygon's four edges. Replace ? with left/right/top/bottom, for example point(right_minx,right_miny) is the lowest point on the right hand side of the polygon. If there is just single point at the edge, min- and max-points are the same.

"dim_camera"

af_request("dim_camera")

Available only in dimension line scripts. Gives current projection camera. Returns table having fields:

  • •

    begc: plane’s origin

  • •

    vecx, vecy: plane’s axes

  • •

    vecz: plane’s normal vector, camera’s watching direction

  • •

    pa, pb, pc, pd: plane’d equation

"elem_automodules"

af_request("elem_automodules ", tblSettings)

Groups opening related framing parts with CNC-Module ID. Without any settings each opening gets own ID and IDs start from A. Parameter tblSettings can be nil and if not, it may contain these fields:

  • •

    id: Starting ID, default="A"

  • •

    sameid: if given and value is true, all modules will have the same ID

  • •

    studgroups: If given and value is 1, the touching stud groups are defined as modules. Default is false.

  • •

    openingsfirst: If given and value is 1, just the first studs next to the openings are picked. Otherwise, the module is extended to all touching studs.

  • •

    mat_bottom: If given, there will be horizontal piece added to the bottom of the module. Its parameter iElemGroup is set to vertical_x_module

  • •

    mindist_bottom: If given, defines the minimum distance from the opening’s lowest horizontal piece to the bottom of the module that the mat_bottom will be applied. Default=0.

"xmltoelem"

af_request("xmltoelem", elemGuid, strXml)

Applies the settings in the strXml into the given element. Parameter elemGuid may be nil to use object opened by the previous ac_objectopen()-call.

Return value: false=no changes, true=target was changed (and set internally to need saving or if non-plank from internal buffer, it is saved automatically before returning)

"xl_init"

Initializes connection to Excel writer libXL.

When processing elements, there are these additional requests available:

Value

Description

"elemcorethickness"

Returns the element core thickness.

“elem_getpolyscount”

Returns number of polygons making up the element. Currently always 1.

“elem_getpoly”

af_request ("elem_getpoly ", polyNum).

polyNum is currently unused and should be 1.

Creates Lua globals that are available at initial create planks phase. Please see Lua-scripts with elements.

“elem_getinfo”

Returns table containing information about current element. Table fields are:

  • •

    vecx, lengthwise axis. For vertical elements, this has zero z.

  • •

    vecy, for vertical elements this is 0,0,1.

  • •

    vecz, the watching direction for the element.

“elem_createplanks”

Issue when script has set up information for new planks. Please see Lua-scripts with elements.

“elem_getstudmat”

Gives ID of random (actually first one sorted by plank’s GUID) vertical plank in the element. If no planks yet, gives ID of first material definition of the element.

“elem_marknoplanks”

af_request ("elem_marknoplanks", x1, y1, x2, y2, nDelExisting), marks give rectangle in the element not to get any planks from spacing rules.

  • •

    nDelExisting, optional parameter to delete existing planks from given polygon. With value 1 deletes plank intersecting the polygon.

"elem_quantities"

af_request ("elem_quantities", strElemGuid, nOpenLayers [, tblSettings] )

Gives quantities for single element or layered element. Parameters:

  • •

    strElemGuid, nil = use the parent element given from environment, str = guid.

  • •

    nOpenLayers, 0 = Open just given single element, 1 = Open every layer.

  • •

    tblSettings, if given may contain fields:

    • •

      tblguids If given, calculate the “geo” bounding box from these pieces. 1-based array of string guids.

    • •

      external If present and true, will add also external planks

    • •

      quant Level of quantity calculation to speed up operation if quantities not needed, 0=minimal, 100=all (default). Additional flags to be added to base value 0 or 100:

      • •

        256, return openinginfo

Returns table containing information for separate layers and total quantities.

  • •

    tblelems, the elements.

  • •

    quant, sum of quantities for each layer.

  • •

    geo, origin of master element and 3D bounding box. Please see end of this section for description. Not taking rotframing="x" attribute into account.

  • •

    geoframing, as previous but takes possible rotframing="x" attribute into account. Bounding box fields are not set here.

  • •

    comptype, type name of the composite element type, nil = could not get it.

  • •

    templateid, for own element types the based on type id, nil = not own element type.

  • •

    xmlutf8, in this level contains composite xml referencing layers and having settings for the whole composite.

  • •

    guidstamp, guid of the related element stamp object, nil if no stamp

  • •

    tblguidcutlist, 1-based table of the related cut lists, nil if no cut lists

  • •

    corners, the corner types for each side or nil=not defined. Fields corners.left, corners.right, corners.bottom and corners.top

  • •

    offedges, edge offsets for the element. Please see next item.

  • •

    offopenings, opening offsets for the element. Fields:

    • •

      id, the preset id. If not matching to existing presets, this is empty string "".

    • •

      layers, 1-based array of tables each having fields:

      • •

        layertype, finish_ext etc..

      • •

        layerindex, negative before core, 0=core, positive after core

      • •

        left, right, top, bottom, the offsets for each side having fields:

        • •

          is, is it checked (numeric, not Boolean)

        • •

          off, the offset value positive extending it

  • •

    openinginfo, filled only if requested. Gives information of all Archicad doors and windows related to the core layer or if the given layer if opened just one layer. Fields:

    • •

      guid, the Archicad door/window guid

    • •

      id, the Archicad door/window ID

    • •

      libpart, the related Archicad library part name

    • •

      x1,x2,y1,y2, the bounding box of the opening projected to the core/given layer.

Fields for single element:

  • •

    guid, element’s guid.

  • •

    id, element’s id.

  • •

    elemtypeid, for example “WALL 173 K600”.

  • •

    elemtype, for example “core”, “intstud”, “boarding_int” etc from type=”xxx” xml-attribute.

  • •

    templateid, for own element types the based on type id, nil=not own element type.

  • •

    xmlutf8, element’s xml-definition in utf8-characters.

  • •

    areanet, element area calculating openings in m2.

  • •

    areagross, openings not reduced in m2.

  • •

    layertypenum:

    • •

      0 = planks.

    • •

      1 = boards.

    • •

      2 = paneling (planks belonging to this layer are paneling/cladding).

  • •

    tblplanks, 1-based array of planks belonging to this layer containing fields:

    • •

      guid, the plank guid.

    • •

      ptr, temporary pointer to the plank.

    • •

      external, true=is external plank (only if requested), false/nil=owned by parent element

  • •

    tblboards, 1-based array of boards containing fields (nil if no boards):

    • •

      guid, the board element.

    • •

      ptr, temporary pointer to the board.

    • •

      id, the board id.

    • •

      thickness, its thickness.

    • •

      width, height, the size of the board.

    • •

      ispanel, 0 = no, 1 = board contains panel/cladding.

  • •

    tblac,1-based array of the related Archicad-elements’ guids (walls, floors, roofs)

The quantity fields for single element or combined for multilayer element as calculated in weight tools:

  • •

    elemvolume, full volume from polygon area * thickness.

  • •

    elemvolumereduced, the planks and boards including insulation boards reduced from element volume. Please see newer insuvolume below.

  • •

    elemweight, total element weight elemweightreduced + plankweight + boardpanelweight plus related openings weight.

  • •

    elemweightreduced, insulation weight. This old name is kept to be backwards compatible.

  • •

    insuweight as previous but more logical name

  • •

    plankvolume.

  • •

    plankweight all planks

  • •

    boardpanelvolume includes insulation boards

  • •

    insuvolume, volume of insulation (either boards or automatically calculated if insulation weight for the layer is non zero)

  • •

    boardpanelweight excluding insulation boards

  • •

    openingweight, combined weight of related openings.

The geometry information from geo-table:

  • •

    orig.x, orig.y, orig.z, origin of the core-element. Compared to "plankinfo" origin is at element’s front instead of back.

  • •

    vecx, vecy, vecz, direction vectors of the element, vecz is the front projection watching direction. Compared to "plankinfo" vecy and vecz are swapped.

  • •

    x1, x2, y1,y2, z1, z2, minimum and maximum coordinates of any plank or board in element’s axes (see Element object). Please note that these are nil if there are no planks or boards related to the element.

  • •

    len, as in "plankinfo", polygon xMax-xMin

  • •

    height, as in "plankinfo", polygon yMax-yMin

  • •

    width, as in "plankinfo", element’s thickness

“elem_domarkings”

af_request ("elem_domarkings", strXml).

Like the xml-definition, may refer to settings inside <presettings>-tag:
<markings ref = "mark_big"/>.

25.2.1.1 Element layers

af_request ("elem_openparent", guidElem).

GuidElem can be nil to get current element.

Resulting table contains fields:

Field

Description

id

ID of element type from ArchiFrameElements.xml:

  • •

    <elemtype class="wall" id="WALL 173+42 VERT" idstamp="173+42">.

guid

Guid of the core layer/single layer element object.

ptr

Another temporary ID for the master element.

thickness

Total thickness of the layered elements including any empty space between elements.

tblelems

Table of individual elements.

Tblelems is indexed by 1-based index in the same order as defined in ArchiFrameElements.xml. The table contains these fields:

Field

Description

id

ID of the referenced element or same as parent element if single layer element:

  • •

    <layer ref="WALL 173 K600" anchorname1="Core ext"…

type

Type of the element layer (core for single layer elements): <layer ref="WALL 42x42 VERT" … type="intstud">.

guid

Guid of the element object.

ptr

Another temporary ID for the layer element.

zoff

Offset in watching direction to first surface.

xsize

Maximum width of the element. Lower left corner has always coordinates 0, 0. For walls this is the element length in floor plan.

ysize

Maximum height of the element. For walls this is the height.

thickness

Layer’s thickness, logically zsize.

x1off

Offset from core layer’s left-hand side: positive extends over core.

x2off

Offset from core layer’s right-hand side: positive extends over core.

y1off

Offset from core layer’s lower side: positive extends over core.

y2off

Offset from core layer’s upper side: positive extends over core.

af_request (“elem_closeparent”, nSave).

Closes the current multilayer element.

Parameter

Description

nSave

1 = Save changes, with any other value all changes are discarded.

af_request ("elem_openlayer", guidElem), af_request ("elem_closelayer").

Opens the given layer to edit planks and element polygon shape. Close does not save the changes, it just clears internal information. The changes are finally saved with elem_closeparent.

af_request (“elem_moveside”, nCorner, offset).

Moves side of an element layer.

Parameter

Description

nCorner

1 = left, 2 = right, 3 = bottom, 4 = top.

offset

Positive extends, negative makes smaller.

25.2.1.2 Element relations

af_request (“elem_getrelations”, guidElem [, xtolerance}).

Gets the relations for single element layer. GuidElem can be nil to process current element layer.

Parameter

Description

GuidElem

Element layer, nil = use current layer.

xtolerance

How far from the intersection the element’s end may be, default = 1 mm. Use if core is shortened over that in the corner type.

Returns 1-based table of relations. Each relation items which are tables also have following fields:

Field

Description

guidother

Guid of the related element layer object.

typeother

Type of the related element layer: <layer ref="WALL 42x42 VERT" … type="intstud">.

reltype

Numeric value:

  • •

    1 to begin.

  • •

    2 to end.

  • •

    3 to middle (or crossing elements).

x1,x2

Intersection coordinates minimum and maximum values in X-axis. Can be outside the element area, negative before left hand side, bigger than length right from right hand side.

x1off,x2off

Maximum distance from min/max point to the intersection of other plank

angledeg

Angle in degrees between current element’s X-axis and other’s X-axis (which direction may have been swapped). Positive = on the left hand side, negative = on the right hand side.

25.2.1.3 Element lintels

af_request (“elem_lintels”, settings) or af_request (“lintels”, settings).

Creates lintels according to passed setting table. Single lintel settings item contains these fields:

Field

Description

minwidth

Minimum width of the opening to use these rules. Place definition for longest first and continue with shorter ones.

mat

Material ID for the lintel beam.

thickness, height

If material ID is generic without fixed size, these must be given.

matstud

If given and non-empty, the material ID for additional studs. Original is moved further from the opening.

front

Number of lintel beams to front side of the element, 0 = none.

back

Number of lintel beams to back side of the element, 0 = none.

delorg

0 = keep source plank and place beams above it.

beamvertical

0 = if beam material’s thickness is bigger than its height, place as original piece

1 = beam always has global rotation of zero having its bottom downwards.

extorg

0:

1:

totop

0 = place lintel just above the opening (default).

1 = place the lintel below top sill.

cutabove

0 = extend studs above the lintel beam to bottom of the beam and create grooves, 1 = cut studs above lintel beams.

studs

Number of additional studs, 0 = just create grooves to existing studs.

extbeamtosides

0 = Beams end to inner side of the furthest studs (king studs), default

1 = Extend beam to the outer side of the king stud

joinbeamsdist

Joins newly created lintel beams closer or equal to the given value:

The unit for the value is meters and value -1 or smaller will skip applying this rule.

xmlbeam

Settings for the new beams (studs will have same settings as original ones), for example (also setting the projection pieces’ settings):

gsXmlBeam="<s><elemparam name=\"material\">Paint-06</elemparam>" ..

"<newelemprojside><objparam name=\"iFill\">25 %</objparam><objparam name=\"iFillPen\">20</objparam></newelemprojside>" ..

"<newelemprojtop><objparam name=\"iFill\">25 %</objparam><objparam name=\"iFillPen\">20</objparam></newelemprojtop>" ..

"</s>"

Starting point:

These settings:

The result:

25.3 Lua-scripts with planks

ArchiFrame has a mechanism that allows the user to write custom code to edit any new or edited plank. There are two possible places:

  1. 1.

    Before the plank is saved to Archicad in its cleanup operation. Then the plank does not have properties and categories since it does not have yet a guid if it is a new one. The called function has fixed name of OnPostClean. Use this always if you don’t need properties and categories since this has basically no impact to the performance.

  2. 2.

    After the plank is saved to Archicad having all properties and categories set from xml. The called function has fixed name of OnPostSave. Useful if you need to work on the properties and categories.

The functions are under tag <observer> in ArchiFrameBlocks(Changes).xml. ArchiFrame will scan for tag names observer, observer1, observer2 etc. up to observer9 adding the contect of the new tags to the end of existing script. Please see examples in ArchiFrameBlocks.xml. The default implementation of the OnPostClean generates automatic reinforcements for I-shaped beams and sets some calculation parameters.

OnPostSave is called always if the plank or board is changed by the user or internally by ArchiFrame for 3D and projection parts. OnPostClean is called only for the 3D planks if there is a change in its geometry. Then for caching for example property GUIDs, it is possible to define function OnPostInit() that will be called once at the beginning of an undo session.

This mechanism allows setting properties automatically according to the plank’s parameters, for example it is possible to copy the plank length from object’s parameter iLen to a property like this:

gfnOrgPostClean = OnPostClean         -- Save original function
gsGuidPropMemberNumber = nil          -- To speed up things: Save the guid to be able to quickly check if it exists & set it

function OnPostInit()
  gsGuidPropMemberNumber = nil        -- Called once per active operation environment
end

-- Called just after the plank is saved to AC for master AND projection planks because master plank is saved after projections are updated (before calling this function).
-- And anyway AC-properties for master plank are updated only after saving the part to AC.
-- nCode  1=new plank, 2=edit old
-- Return value: 0=no change, 1=changed - save again
function OnPostSave( sGuid, nCode )
  local res, s

  res, s=pcall(OpenObj, sGuid)   -- Silent fail
  if not res then
    return 0
  end

  local info, currLen, xmlTot

  res = 0
  xmlTot = ""
  info = af_request("plankinfo")
  
  if not info then
    ac_objectclose()
    return res
  end
  
  if info.type == 1 then
    -- It is a plank
    res = 0
    currLen = ac_objectget("iLen")
    if currLen then
      -- It is a plank having the needed parameter
      xmlTot = xmlTot .. string.format('<prop group="IW COMMON PROPERTIES" name="Lumber Length" value="%s"/>', string.format("%0.8f", currLen))
    end
  end

  if xmlTot ~= "" then
    xmlTot = "<t>" .. xmlTot .. "</t>"
    if af_request("xmltoelem", sGuid, xmlTot) then
        -- Nope - we do not set any parameters, return zero: res = 1
    end
  end

  ac_objectclose()
  return res    -- Changed or not (caller will detect if changes in properties - no need to return that from here)
end

25.4 Lua-scripts with elements

It is possible to create planks to the element with script instead of xml-definitions. The script gets information about element contour lines including openings. Contour line is always counterclockwise for both main contour and openings. For the main contour the left-hand side is towards the element and for openings, the right-hand side.

Lua globals set by ArchiFrame when handling elements:

Name

Description

gGuidElem

Element object’s GUID to be used for ac_objectopen. Core layer or the owning layer for options scripts.

gGuidElemStamp

Set if handling element stamp, nil = unknown.

gElemIdStamp

The element ID to put into stamp:

<elemtype class = "wall" id = "WALL 100 C/C 600" idstamp="50x100">.

gAdjustElems

For options and corner scripts: Set to true if processing setting palette, nil if creating element planks.

Edges are in Lua global gtblEdges and one line contains the following fields:

Field

Description

index

Index to identify the edge.

x1,y1,x2,y2

Edge coordinates in element's coordinate system. Lower left corner is (0, 0).

gx1,gy1,gz1
gx2,gy2,gz2

Edge coordinates in global model 3D-coordinates. Missing if there is no plank related to this edge.

holeindex

0 = contour line, other = opening number 1…N.

used

Is there a plank for this place from earlier <planks>-definitions:

  • •

    0, no.

  • •

    1, yes.

  • •

    2, yes from <planks axis = "unused" …>-tag.

tblPlankNums

Indexes to the planks created to this edge in creation order, nil = no planks yet. For historical reasons this contains just single plank having the longest common part with the polygon edge.

tblPlankNumsAll

Unlike previous, this has all planks intersecting with the polygon edge. Sorted in the edge’s direction. Please note that the plank may be listed in multiple gtblEdges-items if the plank extends over many edges.

Planks to be created are placed into table gtblCreate which has fields:

Field

Description

group

Group name for <operations>-section.

id

Material id.

thickness

Material size if not fixed by material id.

height

Material size if not fixed by material id.

zoff

As in xml-definitions.

z1, z2

Additional z-offset added to zoff to the begin and the end.

rotangle

As in xml-definitions.

x1,y1,x2,y2

Plank's reference line on element's surface.

lineside

Defines reference line alignment: -1 = left, 0 = middle (default), 1= right. This does not work always – if not, the rotangle +90/-90 should be used instead.

fixlen

If given, sets fixed length to the plank.

guidsettings

If given, the plank settings like pens, fills etc. are taken from this existing plank.

copyops

Related to guidsettings: If value = 1 all existing linked machinings (operations) like automatically updating grooves are copied from plank pointed by guidsettings.

xmlsettings

Settings as XML-settings for an Archicad element.

xmlsettingsproj

Settings to be applied to the related projection planks. Under the root tag there may be settings with these tag names:

  • •

    newelemprojside

  • •

    newelemprojtop

mayturn

If given and set to true, ArchiFrame may turn the plank to be best in the element elevation.

postlua

Lua-script inside <tag> to be run after the plank has been actually created internally. May refer to base script with attribute ref = “name”.

extendtoelem

Possible values (bit mask so you can combine the options):

  • •

    Missing or 0, no effect.

  • •

    Non-zero or 1, given line is extended to cover whole element polygon and split if there is an opening intersecting the line.

  • •

    2, cut with polygon edges (gable cut).

  • •

    4, discard the new split parts (do not extend over holes)

force

Controls overlapping pieces, possible values:

  • •

    false/0 = do not add if there is already a plank (default)

  • •

    true/1 = keep rather this plank than any existing one

  • •

    2 = create even if outside the element

  • •

    3 = leave old intersection piece(s) under new forced piece

Additional modifier to be added to the force-value:

  • •

    256, adjust any existing parallel piece to this added one

Number of existing planks is in global gnPlanks. New planks are appended according to table gtblCreate. Script may define operations for the planks by creating global variable gxmlOperations. Its format is like section Operations between the planks <operations>. For the script planks it is possible to refer to those using index number instead of group name, using format #number (for example target = "#1"). Many numbers may be used by separating numbers with comma, for example target = “#1, 2, 3, 4”. For example adjusting to successive planks together:

-- Adjust these two together
strXmlOp = string.format( 
    "%s" ..
    "<joinends target=\"#%d\" operator=\"#%d\">\n" ..
    "    <joinends conntype=\"endtoend\" jointgap=\"0\"></joinends>\n" ..
    "</joinends>\n",
    strXmlOp, gnPlanks+i, gnPlanks+i+1)

Please see also ac_getobjparam.

ArchiFrame provides these additional functions to this task:

Function

Description

af_hasedgex ( edge, vecx, vecy )

Checks whether an infinite area starting from given edge to given direction, intersects with any other edge. This is used to detect for example top side of the element (vex = 0 and vecy = 1, upwards).

Returns. True = intersection found, false = no intersection.

In addition to creating new planks, it is possible to edit planks defined earlier. To do so, ac_objectopen() is called with string format #index, where index is 1-based index to the plank. In dimension line scripts adding exclamation mark after dash will return the related 3D-piece instead of projection piece (#!%d). For example:

<!-- Sets different pen for studs -->
<script id="setcolours">
  <![CDATA[
gnPlankCount=0
gtblCreate = {}

 for i=1,gnPlanks do
  ac_objectopen(string.format("#%d",i))
  
  -- Vertical (studs) with different pen
  x2=ac_objectget("iEndX")
  y2=ac_objectget("iEndY")
  if x2*x2+y2*y2<0.001 then
    ac_objectset("#pen", 3)
  end
  ac_objectclose()
 end
]]>
</script>

25.4.1 Script to set planks’ or boards’ IDs inside an element, <renumscript>, <renumscriptnew>

<renumscriptnew> was added for backwards compatibility. It works just as <renumscript> except when using it ArchiFrame allows having an empty definition for the script to be used with element templates.

It is possible to set prefix and postfix to the ID based for example on plank’s role in the element. To do that, the recommended way is to include following line to the element definition xml under xml-tag <layer> after all <planks>-definitions or for boards the xml-path is layers/boarding/renumscript (please search for text renum from the default data/ArchiFrameElements.xml):

<renumscript ref="kwrenum"></renumscript>

This refers to a script in xml-path archiframe/elem/settings/scripts:

        <script id="kwrenum">
          <![CDATA[
-- Loaded once per element, called for each plank current plank opened already
-- Returns table having optional fields:
-- idpre  To be added before ID, if starting with !, will not be visible
-- idpost To be added after ID, if starting with !, will not be visible
function GetPlankRenumData(guidElem)
  local s, t
  
  t={}
  s=ac_objectget("iElemGroup")
  if s=="vertical_y" then      -- vertical_y_openingdouble for double opening pieces
    t.idpost="!A"
  end
  return t
end
]]>
        </script>

This example script sets the text “!A” to be appeneded after the plank ID. Exclamation mark ! means that the text is actually not appended – it just makes sure that planks classified as opening studs will get their own ID.

Another prefix is #num that tells ArchiFrame that this plank group should be numbered starting from the given number.

Third prefix is equation mark = which will cause the plank’s ID to be set exactly as given omitting the starting =.

For example, a plank renum script:

        <script id="renum_by_role">
          <![CDATA[
-- Loaded once per element, called for each plank current plank opened already
-- Returns table having optional fields:
-- idpre  To be added before ID
-- idpost To be added after ID
-- For both, the special characters:
-- !, will not be visible
-- #num, useful for idpre - will define the starting number for the planks (not visible either)
function GetPlankRenumData(guidElem)
  local s, t, res
  
  t={}
  s=ac_objectget("iElemGroup")
  
  res="#1"
  if string.match(s, "^vertical_x.*") then
    res="#200"
  elseif string.match(s, "^lintel.*") then
    res="#250"
  elseif string.match(s, "^bottom_force.*") or string.match(s, "^2ndbottom_force.*") then
    res="#300"
  elseif string.match(s, "^top_force.*") or string.match(s, "^2ndtop_force.*") then
    res="#400"
  elseif string.match(s, "^nogging.*") then
    res="#500"
  end

  t.idpre=res
  return t
end
]]>

And a board renum script:

        <script id="renum_board_example">
          <![CDATA[
-- Loaded once per element, called for each board current board opened already
-- Returns table having optional fields:
-- idpre  To be added before ID
-- idpost To be added after ID
-- For both, the special characters:
-- !, will not be visible
-- #num, useful for idpre - will define the starting number for the planks (not visible either)
-- =, as the first character will set the idpre as it is to the target
function GetPlankRenumData(guidElem)
  local dx, dy, t, res
  
  t={}
  dx=ac_objectget("iCurrWidth")
  dy=ac_objectget("iCurrHeight")
  
  res=""
  if math.abs(dx-1.2)<0.0001 and dy>2 then
    local s
	
    -- Make ID: (owning element ID)#FULL
    s = ac_getobjparam(gGuidElem, "#id")
    res="=" .. s .. "#FULL"
  end

  t.idpre = res
  return t
end
]]>
        </script>

25.4.2 The corner script callback functions

If called from corner tool palette, Lua global gAdjustElems is set to true. Also these globals are present:

  • •

    gbCornerFindOther, UI value for check box Find connecting corner.

  • •

    gbCornerAdjustOther, UI value for check box Adjust connecting corner.

Set (sSettings, guidParent, nCorner).

Called to set single corner for given parent element. There are two cases when this function is called:

  • •

    When new element is created and corner types are already set.

  • •

    When corner type is changed from another type or from default using corner tool palette.

Parameter

Description

sSettings

Previous settings string, “” = default settings.

guidParent

Guid of the master element, use af_request (“elem_getparent”, guidParent) to process.

nCorner

1 = left, 2 = right, 3 = bottom, 4 = top.

OnPlanksCreated (sSettings, guidElem, layerType, nCorner).

Called when planks for element outline and openings are placed but before (stud) spacing rules are applied. This script places the planks specific to the corner type.

Parameter

Description

sSettings

Previous settings string, “”= default settings.

guidElem

Current element’s guid.

layerType

Type of the related element layer: <layer ref = "WALL 42x42 VERT" … type="intstud">.

nCorner

Corner to handle 1 = left, 2 = right.

25.4.3 Lua scripts with element options

Element options have fixed function names:

Function

Description

Has()

Called by ArchiFrame to find out if the option is set for options UI.

Return: -1 = Not known/no planks, 0 = nope, 1 = has.

Settings(sSettings)

Called by ArchiFrame when user clicks Settings-button in UI.

Return: nil = canceled, "" = clear settings/use defaults, str = settings str.

Set(sSettings)

Called to set the option on either from options UI (gAdjustElems == true) or when creating element planks.

Reset()

Called to cancel the option from options UI.

GetName(sSettings, baseName)

Called to make special name for the options, for example, when user has set the settings to non-default. BaseName is string of the option name, add it to the front of the result string.

Return: string to show in UI.

25.4.4 Lua script to adjust generated saw cuts

ArchiFrame searches for fixed file name ArchiFrameSawCuts.lua from user specific settings folder when creating the saw cuts for selection:

If the script exists, it is loaded and this function is called:

-- tblLines is a table having auto-created saw lines for each polygon list edge following standard polygon rules: contour line ccw, holes cw
-- projWorld is geometry world of the owing ArchiFrameElement
-- guidElem Owner ArchiFrameElement
-- polyList Polygon list of the parts that saw cuts are created to, can be passed ac_geo("linepolyx",...)
-- Return value: either tblLines as passed here or it adjusted
function AdjustSawLines(tblLines, projWorld, guidElem, polyList)

Each item in tblLines has fields:

Field

Description

x1, y1

The starting point of the saw cut

x2, y2

The ending point of the saw cut

depth

The depth of the saw cut (0=default)

edgetype

The edge’s door/window type, please see the edge types from here.

tooltype

1=saw blade, 2=router

overbeg

Boolean: is there overcut at begin

overend

Boolean: is there overcut at end

angledeg

The saw cut angle in degrees

skip

Boolean: Script can set this item to skip this saw cut

toleft

Boolean: Is the saw cut on the left side of the line (default=false)

groupid

String: If saw cuts should be grouped in cnc-output, ""=no grouping

groupnum

Number: Sequence number inside the group (must be unique if group is used)

polyind

Polygon index in case of split surface (input only for the Lua-script)

contourind

0=outline, >0=hole index in current polygon (input only for the Lua-script)

25.5 Other Lua extensions

Http-requests interface.

Res = curl_httpget ("http://www.google.com").

Makes http-get request. Returns server reply or causes an error if failed.