About this project...
Installation instructions...
Note: The following examples are cumulative, meaning each additional code block depends on having ran the previous blocks.
aide_render is intended to provide an environment for building and rendering AIDE python projects. An AIDE project is a collection of Python classes that define the representation of some Fusion 360 files, as well as the files themselves. To make Fusion 360 project, use the builder classes specified in aide_render to develop a component with various design parameters. Abstractly, this would look like:
from aide_render.builder_classes import HP, DP, Component
from aide_design.units import unit_registry as u
class SpecialComponent(Component):
# HP and DP are subclasses of u.Quantity from python.
# This is where you specify defaults for a certain class.
a_hydraulic_parameter = HP('5 meter')
a_design_parameter = DP(24, u.meter)
# static methods are used so that the functions don't depend on the existence of
# these classes
@staticmethod
def special_add(a,b):
return a+b
def __init__(self, passed_in_param):
self.output_parameter = self.special_add(passed_in_param, self.a_hydraulic_parameter)
Now that our component is built, we can render the design parameters that will be used to scale the Fusion file like so:
my_component = SpecialComponent(DP(30*u.meter))
from aide_render.builder import render
rendered = render(my_component)
print(rendered)That will return a dictionary of ONLY THE DESIGN PARAMETERS. This means anything that was a DP class will be put into the dictionary. The rendered dict is below - notice how the HP parameter is not included:
{'default_design_parameter': <Quantity(24, 'meter')>, 'output_parameter': <Quantity(35 meter, 'dimensionless')>}Finally, to get the YAML that is passed to aide_draw, simply use the aide_render yaml library to dump the dict:
from aide_render.yaml import dump, load
dump(rendered)
# "{a_design_parameter: !DP '24 meter', output_parameter: !DP '35 meter '}\n"In this example, we'll show how to subclass a component that already exists and then include another component to be rendered within it.
Say we have another component that is a whole lot like the Component we made, but it has one added feature. Let's build that:
class MoreSpecialComponent(SpecialComponent):
def __init__(self, a_special_component):
self.special_component = a_special_component
super(MoreSpecialComponent, self).__init__(DP('3 meter'))Read CONTRIBUTING.