MCPcopy Index your code
hub / github.com/CadQuery/cadquery / build

Method build

cadquery/cqgi.py:85–130  ·  view source on GitHub ↗

Executes the script, using the optional parameters to override those in the model :param build_parameters: a dictionary of variables. The variables must be assignable to the underlying variable type. These variables override default values in the script :param b

(self, build_parameters=None, build_options=None)

Source from the content-addressed store, hash-verified

83 raise NotImplementedError("not yet implemented")
84
85 def build(self, build_parameters=None, build_options=None):
86 """
87 Executes the script, using the optional parameters to override those in the model
88
89 :param build_parameters: a dictionary of variables. The variables must be
90 assignable to the underlying variable type. These variables override default values in the script
91 :param build_options: build options for how to build the model. Build options include things like
92 timeouts, tessellation tolerances, etc
93 :raises: Nothing. If there is an exception, it will be on the exception property of the result.
94 This is the interface so that we can return other information on the result, such as the build time
95 :return: a BuildResult object, which includes the status of the result, and either
96 a resulting shape or an exception
97 """
98 if not build_parameters:
99 build_parameters = {}
100
101 start = time.perf_counter()
102 result = BuildResult()
103
104 try:
105 self.set_param_values(build_parameters)
106 collector = ScriptCallback()
107 env = (
108 EnvironmentBuilder()
109 .with_real_builtins()
110 .with_cadquery_objects()
111 .add_entry("__name__", "__cqgi__")
112 .add_entry("show_object", collector.show_object)
113 .add_entry("debug", collector.debug)
114 .add_entry("describe_parameter", collector.describe_parameter)
115 .build()
116 )
117
118 c = compile(self.ast_tree, CQSCRIPT, "exec")
119 exec(c, env)
120 result.set_debug(collector.debugObjects)
121 result.set_success_result(collector.outputObjects)
122 result.env = env
123
124 except Exception as ex:
125 result.set_failure_result(ex)
126
127 end = time.perf_counter()
128 result.buildTime = end - start
129
130 return result
131
132 def set_param_values(self, params):
133 model_parameters = self.metadata.parameters

Calls 10

set_param_valuesMethod · 0.95
set_debugMethod · 0.95
set_success_resultMethod · 0.95
set_failure_resultMethod · 0.95
BuildResultClass · 0.85
ScriptCallbackClass · 0.85
EnvironmentBuilderClass · 0.85
add_entryMethod · 0.80
with_cadquery_objectsMethod · 0.80
with_real_builtinsMethod · 0.80