I have following function in 3ds Max Script to create a box with desired dimension…
- User
I have following function in 3ds Max Script to create a box with desired dimension entered by user in specific format. And it even checks system units scale and display unit scale, and ask user to change it to decimal inches: -- Function to create the box based on parsed dimensions fn createBoxFromDimensions dimensions placement = ( -- Check if the input is empty if dimensions == "" then ( messageBox "Error: The input field is empty.\nPlease paste the dimensions from ALL3D portal in correct format as shown below:\n\nHeight\n0 Inches\nWidth\n0 Inches\nDepth\n0 Inches." title:"ALL3D Scene Validator" icon:#critical ) else ( -- Split input into lines and initialize variables local lines = filterString dimensions "\n" local height = undefined local width = undefined local depth = undefined local valid = true
-- Check if there are enough lines to parse if lines.count >= 6 then ( -- Parse lines for expected keywords and values for i = 1 to lines.count - 1 by 2 do ( case lines[i] of ( "Height": height = (substituteString lines[i+1] " Inches" "") as float "Width": width = (substituteString lines[i+1] " Inches" "") as float "Depth": depth = (substituteString lines[i+1] " Inches" "") as float default: valid = false ) ) -- Validate all dimensions are defined if height == undefined or width == undefined or depth == undefined then valid = false ) else ( valid = false ) -- Create box if valid, otherwise show an error if valid then ( -- Create box at origin with parsed dimensions local boxObj = box length:depth width:width height:height pos:[0,0,0] name:"Overall_Dimension" boxObj.wirecolor = (color 255 0 0) case placement of ( 1: boxObj.pivot = [boxObj.center.x, boxObj.center.y, boxObj.min.z] 2: boxObj.pivot = [boxObj.center.x, boxObj.center.y, boxObj.max.z] 3: boxObj.pivot = [boxObj.center.x, boxObj.max.y, boxObj.center.z] default: boxObj.pivot = [boxObj.center.x, boxObj.center.y, boxObj.min.z] ) boxObj.pos = [0,0,0] boxObj.boxmode = true -- Destroy the dialog if DimensionDialogFloater != undefined do closeRolloutFloater DimensionDialog ) else ( messageBox "Error: Please enter the dimensions in the correct format as shown below:\n\nHeight\n0 Inches\nWidth\n0 Inches\nDepth\n0 Inches" title:"ALL3D Scene Validator" icon:#critical ) ) )fn checkAndSetUnitsToInches = ( -- Check if system unit scale is set to inches local currentSystemUnit = units.systemtype local currentDisplayUnit = units.displayType
if currentSystemUnit != #inches or currentDisplayUnit != #US then ( -- Prompt user if they want to change the unit to inches local result = queryBox ("System unit scale is " + currentSystemUnit + " and display unit scale is " + currentDisplayUnit + ".\nWould you like to change both to inches?") title:"Unit Scale Check" if result == true then ( -- Set system unit scale to inches units.systemtype = #Inches -- Set display unit scale to decimal inches units.DisplayType = #US units.USType = #Dec_In messageBox "System and display units have been set to inches." title:"Units Set" ) else ( messageBox "Units remain unchanged." title:"No Changes Made" ) ) else ( format "System and display units are already set to inches.\n" ) ) -- UI Dialog rollout DimensionDialog "Dimension Box Creator" ( editText dimensionsInput "Paste Dimensions:" height:100 radioButtons dimensionPlacement "Placement:" labels:#("Floor", "Ceiling", "Wall") button createBoxButton "Create Dimension Box" -- Event handler for button click on createBoxButton pressed do ( local dimensions = dimensionsInput.text local placement = dimensionPlacement.state createBoxFromDimensions dimensions placement ) ) - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.