Run a Standard (Python)

Run a Standard (Python)
 1# This example shows how to create a standard in a new project
 2
 3# Create a local variable for the output toolbox
 4ot = impact.gui.output_toolbox
 5
 6# Clear the output toolbox
 7ot.clear()  # Create a local variable for the active database
 8db = impact.active_database
 9
10# Note: You should always assign impact.active_database.standard_creator
11# to a local variable
12sc = db.standard_creator
13
14# Create a local variable for the name of the standard to create
15standardName = "FEFCO 0201"
16
17# Set the standard to create
18sc.standard = standardName
19
20# Set the material
21sc.material_mts = db.find_master_tool_setting( "Corrugated|B Flute", ipMasterSettingType.mstMaterial )
22
23# Check that the IStandardCreator.create method can be called successfully
24if sc.valid:
25
26    # Add a message to the output toolbox
27    ot.add("Successfully loaded standard: " + sc.description)
28
29    # Set some of the variables
30    sc.variable_settings.variables.item("L").value = 100.00
31    sc.variable_settings.variables.item("W").value = 200.00
32    sc.variable_settings.variables.item("D").value = 150.00
33
34    # Get some dimensions settings
35    dimensionSettings = db.find_master_tool_setting( "FEFCO", ipMasterSettingType.mstDimension )
36
37    # If the dimension settings were found the use them
38    if not dimensionSettings.isNone():
39
40        sc.dimension_mts = dimensionSettings
41
42        # sc.add_overall_dimensions = True
43        sc.add_panel_dimensions = True
44
45    # Create the standard
46    drawing = sc.create()
47
48    # Check the standard was created
49    if not drawing.isNone():
50
51        # Add a message to the output toolbox
52        ot.add("Successfully created new project '" + drawing.full_name + "'")
53
54    else:
55
56        # Add an error message to the output toolbox
57        ot.add("Unable to create new project from standard")
58
59else:
60
61    # Add an error message to the output toolbox
62    ot.add("Unable to load the standard '" + standardName + "'")