13 May, 2019

Automating Generative Design for Fabrication

Arguably one of the most powerful Knowledgeware Objects in CATIA is the almighty Engineering Template – an object that allows you to capture entire product structures as a template with dynamic input parameters and attributes. In particular Engineering Templates allow us to capture and re-use manufacturing data relevant to a product including fabrication information, assembly drawings, materials, machine files, etc., thus offering almost limitless opportunities for automating design to production workflows within highly efficient production pipelines.

As seen briefly in a previous post Engineering Templates can be "instantiated" (the process of creating new instances from a reference) into other tree structures. During this process new inputs and attributes can be defined to effect changes in the new instance. We can therefore create many unique instances from the same template structure by modifying inputs.

The process instantiation can be executed manually via the "Instantiate Engineering Template" tool or automated via EKL Action scripts. While the manual process can be efficient when you only have to deal with a few templates (to model an assembly for example) it is way too time consuming to instantiate numerous templates manually (to model a panelised facade for example). In the latter case we can fully automate the process via an EKL Action script saving countless hours of manual work.

To define an the automation concept of the instantiation process it is important to first understand the steps involved in the manual process. So let’s re-visit the demo model used in a previous post and go through the steps. Note that I have included a production drawing within the template to highlight an important concept of Engineering Connections. In order to maintain drawing views in the correct alignment in the instantiated product, we must create Assembly Constraints between the instantiated product and its new context. This is because the drawing views are always referred to the global coordinate system. Creating an Engineering Connection applies a transformation to the instantiated product relative to the global coordinate system in the context. This transformation also applies to the drawing views.

And below is what happens to the drawing views when we instantiate a template but do not create an Engineering Connection within the new context.

Automation Workflow

EKL provides dedicated functions for the instantiation of Engineering Templates (as well as UDFs and Powercopies). We can use these to automate the process of instantitation using an EKL Action.

At high level the process requires 5 basic steps:

  1. Gather inputs
  2. Set destination
  3. Set template parameters & inputs
  4. Instantiate template in destination product
  5. Create engineering connections between instantiated templates and destination context

The inputs to the EKL Action will be Geosets containing the input geometry required for the templates and a Destination Product. Since we are going to iterate through the inputs it is important that they are ordered correctly in their geosets or that they can be sorted by some attribute into the right order within the script itself (e.g. a sequential naming scheme).

For the script to be able to access the Engineering Template reference, it must be included in a local Resource Table or as a global resource within Data Setup. For this demonstration I have created a local resource table and added the Engineering Template for the angle profile to it. The script references this template by its logical name in the Resource Table, "VariableExtrusionTemplate".The last step of creating an engineering connection between the intantiated template product and its context is required only if there are drawings in the template to ensure the correct co-ordination of drawing views.

The video below shows the EKL Action in… well… action! Use your imagination to scale this process up to more complicated templates in large numbers and you can begin to appreciate the power of this approach for generating large and complex fabrication models where it would otherwise be too costly to create each assembly manually. (Note that while the video is edited and instantiation time is actually around 50 seconds in this case).

EKL Code

/* Action created by g.maciocci 5/5/2019 */

let centrelines, axes (List)
let template (Feature)
let profileValuePointer (ValuePointer)
let destination (VPMReference)
let refAxis (AxisSystem)
let targetAxis (AxisSystem)
let refAxisPathString, targetAxisPathString (String)
let engConstraint (MRX)
let createdInstances (List)
let createdInstance (VPMInstance)

let i (integer)

centrelines = InputCL.Query("Curve","")
axes = InputCLAxis.Query("AxisSystem","")
destination = Destination.Reference
set profileValuePointer = Profile 

i = 1
for i while i <= centrelines.Size()
    let centreline (Curve)
    let inputAxis (AxisSystem)

    //gather inputs for engineering template
    centreline = centrelines.GetItem(i)
    inputAxis = axes.GetItem(i)

    //begin instantiation of template, referencing the Engineering Template using its 
    //logical name as specified in the local Resource Table under Relations
    template = InstantiateTemplate("VariableExtrusionTemplate", destination)

    //set template inputs
    template.SetAttributeObject("CL", centreline)
    template.SetAttributeObject("CLAxis", inputAxis)

    //set template parameter using a value pointer to maintain link to parameter in skeleton
    template.SetAttributeObject("ProfileType", profileValuePointer)


    //get the created instance of the instantiated template
    createdInstances = template.GetAttributeObject("CreatedInstances")
    createdInstance = createdInstances.GetItem(1)

    //get the reference axis for the engineering connection within the instantiated template
    //in this case it is a publication and therefore we can easily get the object using Access() method
    refAxis = createdInstance.Access("EngAxis", "AxisSystem")

    //target axis for the engineering connection in this case is the same as the input axis
    targetAxis = inputAxis

    //Path Strings are required by the CreateConstraint() method
    //Create a Path String from the destination product to the reference axis inside the instantiated template
    refAxisPathString = destination.CreatePathString(createdInstance, refAxis)

    //Create a Path String from the destination product to the target axis in the skeleton
    //In this case the first argument can be NULL since the target axis is inside the destination product itself
    targetAxisPathString = destination.CreatePathString(NULL, targetAxis)

    //Create a Coincidence constraint under the destination product context between the reference axis of
    //the instantiated template and the target axis within the skeleton. Any type and multiple constraints can be
    //created. This is the equivalent of manually creating assembly constraints using EngineeringConnection tool
    engConstraint = destination.CreateConstraint("EngConnection_"+ i, "Coincidence", refAxisPathString, targetAxisPathString)

Tags: , ,

About : Guido Maciocci

Guido Maciocci is an Associate at AR-MA, a Sydney based trans-disciplinary architectural practice merging award-winning design with proven expertise in the delivery of complex buildings through the use of advanced computational design workflows, virtual construction methodologies, automation and digital fabrication.

2 thoughts on “Automating Generative Design for Fabrication”

  1. Hi Mr. Guido Maciocci,
    I am an EKL coding beginner, I really like your topic because it helps me a lot.
    I am doing a similar practice as this topic. I added the engineering constraints (same code as you did) for my instantiated engineering templates, but it gives me an error message “could not create path string” with the code line “refAxisPathString = destination.CreatePathString(createdInstance, refAxis)”
    If you have some clues to fix it, please let me know.
    Thanks in advance

    1. Hi Hendry,

      I would need to see the rest of the code and the structure of the tree in your model. The error message suggests that either refAxis has not been accessed correctly or that the targetAxis is in a different context. Could you add a screenshot of code and tree?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.