Hi all,
Iāve written the script below, however once in the online 3D visualiser, I get āAn error occurred while generating the resultsā and āCould not show visualisation, please try with different input.ā
Iāve tried a few different changes including the addition of params. in front of the parameters as well as changing **kwargs to āGroupā.
.translate doesnāt seem to work and at one point I had the error message: Attributeerror: Materialā¦ātranslateā (I cannot remember the middle part).
Any help and guidance is much appreciated!
Jordan
CODE------------------------------------------------------
from viktor import ViktorController, Color
from viktor.parametrization import ViktorParametrization, Text, NumberField
from viktor.views import GeometryView, GeometryResult
from viktor.geometry import Group, Material, SquareBeam
#inputs -------------------------------------------------outr
class Parametrization(ViktorParametrization):
abstract=Text("# Determine suitable pad dimensions.")
subtitle=Text("### Inputs")
load=NumberField('Outrigger Load', suffix='kN')
pad_length=NumberField('Outrigger Pad Length', min=1, default=500, suffix='mm')
pad_width=NumberField('Outrigger Pad Width', min=1, default=500, suffix='mm')
pad_thickness=NumberField('Outrigger Pad Thickness', min=1, default=40, suffix='mm')
subbase_thickness=NumberField('Sub-base thickness', min=1, default=250, suffix='mm')
capping_thickness=NumberField('Capping layer thickness', min=1, default=250, suffix='mm')
subBase_pbt=NumberField('Sub-base AGBP', suffix='kN/m2')
capping_pbt=NumberField('Capping layer AGBP', suffix='kN/m2')
subgrade_pbt=NumberField('Subgrade AGBP', suffix='kN/m2')
#execution ----------------------------------------------
class Controller(ViktorController):
label='Outrigger Pad'
parametrization=Parametrization
@GeometryView("3D", duration_guess=1)
def visualize_pad(self, params, **kwargs):
geometry_group=Group([]) # Create an empty group to hold all the geometry
pad_length=params.pad_length
pad_width=params.pad_width
pad_thickness=params.pad_thickness
subbase_thickness=params.subbase_thickness
capping_thickness=params.capping_thickness
#3D pad
pad_appearance=Material('Plastic', color=Color(255,255,0))
pad=SquareBeam(pad_length, pad_width, pad_thickness, material=pad_appearance)
pad_appearance.translate((0,0,pad_thickness/2))
#3D subbase
subbase_appearance=Material('MOT Type 1', color=Color(172,159,128))
subbase=SquareBeam((pad_length+1000), (pad_width+1000), subbase_thickness, material=subbase_appearance)
subbase_appearance.translate((0,0,subbase_thickness/2))
#3D capping
capping_appearance=Material('MOT Type 1', color=Color(151,138,108))
capping=SquareBeam((pad_length+1500), (pad_width+1500), capping_thickness, material=capping_appearance)
capping_appearance.translate((0,0,capping_thickness/2))
#3D subgrade
subgrade_appearance=Material('Earth', color=Color(105,97,77))
subgrade=SquareBeam((pad_length+2000), (pad_width+2000), 250, material=subgrade_appearance)
subgrade_appearance.translate((0,0,-250))
geometry_group.add([pad,subbase,capping,subgrade])
return GeometryResult(geometry_group)