Standard Creating

Standard Creating
 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()
 8
 9# Create a local variable for the active database
10db = impact.active_database
11
12# Note: You should always assign impact.active_database.standard_creator
13# to a local variable
14sc = db.standard_creator
15
16# Create a local variable for the name of the standard to create
17standard_name = "Dynamic Constraints Rectangle"
18
19# Set the standard to create
20sc.standard = standard_name
21
22# Set the material
23sc.material_mts = db.find_master_tool_setting("Corrugated|B Flute", ipMasterSettingType.mstMaterial)
24
25# Check that the IStandardCreator.create() method can be called successfully
26if sc.valid:
27
28    # Add a message to the output toolbox
29    ot.add("Successfully loaded standard: " + str(sc.description))
30
31    # Set some of the variables
32    # sc.variable_settings.variables.item("L").value = 100.00
33    sc.variable_settings.variables.item("W").value = 200.00
34    sc.variable_settings.variables.item("D").value = 150.00
35
36    sc.variable_settings.variables.item("USE_DC").value = False
37
38    if sc.has_parametric_constructions:
39        ot.add("Has Parametric Constructions")
40
41    # Get some dimensions settings
42    dimension_settings = db.find_master_tool_setting("FEFCO", ipMasterSettingType.mstDimension)
43
44    # If the dimension settings were found the use them
45    if not dimension_settings.isNone():
46        sc.dimension_mts = dimension_settings
47
48        # sc.add_overall_dimensions = True
49        sc.add_panel_dimensions = True
50
51    # Create the standard
52    drawing = sc.create()
53
54    # Check the standard was created
55    if not drawing.isNone():
56
57        # Add a message to the output toolbox
58        ot.add("Successfully created new project '" + drawing.full_name + "'")
59
60    else:
61
62        # Add an error message to the output toolbox
63        ot.add("Unable to create new project from standard")
64
65else:
66
67    # Add an error message to the output toolbox
68    ot.add("Unable to load the standard '" + str(standard_name) + "'")
69