Standard Creating (Python)

Standard Creating (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 = "Dynamic Constraints Rectangle"
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    sc.variable_settings.variables.item("USE_DC").value = False
35
36    if sc.has_parametric_constructions:
37        ot.add("Has Parametric Constructions")
38
39    # Get some dimensions settings
40    dimensionSettings = db.find_master_tool_setting( "FEFCO", ipMasterSettingType.mstDimension )
41
42    # If the dimension settings were found the use them
43    if not dimensionSettings.isNone():
44
45        sc.dimension_mts = dimensionSettings
46
47        # sc.add_overall_dimensions = True
48        sc.add_panel_dimensions = True
49
50    # Create the standard
51    drawing = sc.create()
52
53    # Check the standard was created
54    if not drawing.isNone():
55
56        # Add a message to the output toolbox
57        ot.add("Successfully created new project '" + drawing.full_name + "'")
58
59    else:
60
61        # Add an error message to the output toolbox
62        ot.add("Unable to create new project from standard")
63
64else:
65
66    # Add an error message to the output toolbox
67    ot.add("Unable to load the standard '" + standardName + "'")