Worked Examples
This page points at real HiStruct/FCS components and explains the main ideas you should copy into your own work.
Example 1: AgentRoofCalc (Gable Roof Calculator)
Source folder: D:\GitHub\fcs-lab-01\AgentRoofCalc.fcc\
What it demonstrates
- clean separation between defaults, UI definitions, geometry, and root orchestration
- computed outputs derived from user inputs
- a simple but real 3D model made from prisms and roof shells
- component view setup through
Views.fcscdxandProjectionSettings.fcsdrv
Parameters and computed outputs
The parameter surface is split across two files:
RoofInput.fcscontains the default valuesRoofInputType.fcsdefines the parameter UI structure
Default inputs in RoofInput.fcs:
inLength_m := 10.0
inWidth_m := 8.0
inEaveHeight_m := 3.0
inRidgeHeight_m := 5.0
Computed outputs in RoofInput.fcs:
outHeightDiff_m := inRidgeHeight_m - inEaveHeight_m
outHalfSpan_m := inWidth_m / 2.0
outSlopeAngle_rad := Atan2(outHeightDiff_m, outHalfSpan_m)
outSlopeAngle_deg := outSlopeAngle_rad / Unit.deg
outSlopeWidth_m := Sqrt(outHeightDiff_m**2 + outHalfSpan_m**2)
outRoofArea_m2 := 2.0 * outSlopeWidth_m * inLength_m
outPerimeter_m := 2.0 * (inLength_m + inWidth_m)
RoofInputType.fcs then wraps those values in grouped parameter items such as:
- dimensions (
inLength_m,inWidth_m,inEaveHeight_m,inRidgeHeight_m) - roof type selection
- read-only result fields (
outSlopeAngle_deg,outRoofArea_m2,outPerimeter_m)
3D geometry in RoofShape.fcs
The shape script builds:
- wall vertices at ground and eave level
- a prism volume for the walls
- two roof slope surfaces as shells
Key pattern:
volume {vWalls} prism 1 2 layer (lWalls)
area 11 boundary curve +11 +12 +13 +14
area 12 boundary curve +21 +22 +23 +24
shell {sRoof1} area 11 layer (lRoof)
shell {sRoof2} area 12 layer (lRoof)
That is a very common FCS composition pattern: use a solid volume for the main body and shell surfaces for lightweight roof geometry.
Root orchestration in main.fcs
The root file wires defaults, UI, outputs, and geometry together:
input := RoofInput
InputPageDimensions_ParameterItemClasses := RoofInputType{
NameSpace := "input."
}.typeDefinition
gblock {gbRoof} gclass (RoofShape{ input = input })
Important idea: the component instance state lives under input, while the actual 3D model is emitted by a gblock using RoofShape.
View configuration
Views.fcscdx connects the component to a reusable camera preset:
{
"Views": [
{
"Name": "viewDefault",
"HumanName": "Default view",
"Description": "Default 3D view",
"FcsModelFile": "main.fcs",
"ProjectionSettingsFile": "ProjectionSettings.fcsdrv"
}
],
"Drawings": []
}
This is the standard pattern for telling HiStruct which FCS file to render and which projection preset to use.
Example 2: SkyNetRecognizer (REST API Integration)
Source folder: D:\GitHub\fcs-lab-01\SkyNetRecognizer.fcc\
What it demonstrates
- calling external services from FCS
- trigger-driven async workflows with
InitByGet - embedding image previews in the parameter UI with
ItemComment - projecting a downloaded map onto the scene as a ground texture
- chaining recognition and download actions into a single user flow
Direct REST call with Fcs.Web.RestClient
SkynetRecognizer.fcs shows the low-level API pattern:
skynetEvaluatorClient := Fcs.Web.RestClient{
BaseAddress := "https://skynet-roof-recon-v1.azurewebsites.net/api/"
}
response = skynetEvaluatorClient.GetResponseObject("HelloWorld?code=...&name=ko2o")
This is the simplest example of talking to a REST endpoint directly from FCS.
Trigger-based async operations in main.fcs
The main component uses parameter actions plus InitByGet to call the recognition API and then fetch outputs.
Recognition trigger:
recognitionTrigger = {
Constraints = [
{
Variable = "reconResponse",
Condition = False,
InitByGet = {
Url = url,
MediaFormat = "object"
},
Explanation = "Recognition done!"
}
],
}
Normals download trigger:
downloadNormalsTrigger = {
Constraints = [
{
Variable = "normalsImageBase64",
Condition = False,
InitByGet = {
Url = reconResponse.normals_url,
MediaFormat = "base64"
},
Explanation = "Normals downloaded!"
}
],
}
Chained execution:
processMapImageTrigger = {
Constraints = [
recognitionTrigger.Constraints,
downloadNormalsTrigger.Constraints
],
}
This pattern is especially useful when one remote step produces URLs or identifiers needed by the next step.
Image display in the parameter UI
ItemComment is used to render HTML previews:
mapImageHtml = (inMapImageUrl == "") ? "" : (
"" + "<img src='" + inMapImageUrl + "' width='256' style='padding: 5px;' />"
)
normalsImageHtml = (normalsImageBase64 == "") ? "" : (
"" + "<img src='data:image/png;base64," + normalsImageBase64 + "' width='256' style='padding: 5px;' />"
)
And those HTML strings are exposed with:
Fcs.Parameter.ItemComment{ Identifier = "mapImageHtml" }
Fcs.Parameter.ItemComment{ Identifier = "normalsImageHtml" }
This is a strong pattern for thumbnails, previews, validation images, and lightweight report-like UI content.
Environment ground texture for map overlay
The component also uses the incoming map image as a scene texture:
env = (inMapImageUrl == "") ? {} : {
ground = {
type = "plain",
level = -1,
groundColor = { R = color, G = color, B = color }
},
otherGrounds = {
map = {
type = "plain",
size = {
x = mapSize,
y = mapSize
},
position = { x = -mapSize / 2, y = -mapSize / 2 },
texture = {
size = {
x = mapSize,
y = mapSize
},
url = inMapImageUrl
}
}
}
}
That makes the 3D scene line up visually with the same image being sent to the recognizer.
Manifest and view setup
SkyNetRecognizer.fcscdm connects the component to its view and page definitions:
{
"FcsScript": "main.fcs",
"Views": {
"Views": [
{
"Name": "DefaultView",
"ProjectionSettingsFile": "Gallery.fcsdrv",
"DrawSettingsFile": "SkyNetRecognizer.fcsdrs"
}
]
},
"ComponentPages": [
{
"Name": "PageSettings",
"HumanName": "Settings",
"ParameterDescriptionsIdentifier": "InputPageGallery_ParameterItemClasses",
"DefaultViewName": "DefaultView"
}
]
}
The important idea is that the component is not just geometry: it is also a UI, a workflow, and a view configuration.
Takeaways
Use AgentRoofCalc when you want to learn the basic FCC structure.
Use SkyNetRecognizer when you want to learn how FCS components can orchestrate remote APIs, reactive parameter actions, inline HTML previews, and scene overlays.