SDS2 Parametric API
 All Classes Namespaces Functions Variables Pages
Packages
Designable Namespace Reference

Packages

namespace  Existing
namespace  Processable
namespace  ProcessableComponent
namespace  ProcessableMember
 This module provides a base class for processable custom members.
namespace  Proxies

Detailed Description

This package provides modules that make writing custom members and components easier.

Existing, Proxies, Processable, ProcessableComponent, and ProcessableMember are modules that ensure process is handled correctly and allows developers to write the material creation logic as if it was executed in a single scope the way a traditional parametric can be.

The main contribution of this package is in the Proxies and Processable modules because they solve one of the biggest, unnecessary problems of writing plugins. The rest of this documentation discusses the issue in more detail.

The traditional way of adding new materials, bolts, welds, and holes is inconvient for custom members and components because they have to be added in different scopes for different members. In the case of components, they might be added by entirely different instances of the plugin. Thus, these material, bolt, weld, and hole objects should support pickling so they can be persisted as part of the plugin.

An example is in order. Consider adding a plate with a hole to one member, a second plate to a different member, and then hole and bolt match the two. We want to write something like the following.

def add_rect_plate(thickness, width, p1, p2, origin, member_number, subm_to_global): m = rect_plate.RectPlate() m.Thickness = thickness m.Width = width m.Point1 = point.Point(p1) m.Point2 = point.Point(p2) m.MaterialOriginPoint = origin m.WorkpointSlopeDistance = m.Point1.dist(m.Point2) m.Member = member.Member(member_number) m.Add() m.SetTransform(subm_to_global) return m

def AddBoltedPlates(mem1, mem2, p1, p2, width, thickness = .5): xform = Transform3D.MemberTransform(p1, p2) x_dir = xform.GetBasisVectorX() y_dir = xform.GetBasisVectorY() z_dir = xform.GetBasisVectorZ() mid_p1_p2 = Point3D.Interpolate(p1, p2, .5) w2 = width / 2. to_center_width = -w2 * y_dir

rp1 = add_rect_plate(thickness, width, p1, p2, 'FS', mem1, xform)

h = hole_add.Hole() h.Material = [rp1] h.pt1 = point.Point(mid_p1_p2 + to_center_width) h.face = 'FS Face' h.Columns = h.Rows = 1 h.Locate = 'Center' h.BoltDiameter = 1. h.BoltType = 'AUTO' h.HoleType = 'Standard Round' h.Diameter = h.CalculateHoleSize() h.SlotLength = h.CalculateSlotLength() h.Create()

rp2 = add_rect_plate(thickness, width+1., p1, p2, 'NS', mem2, xform)

hm = hole_add.Hole() hm.Material = [rp2] hm.Holes = [h] hm.BoltDiameter = h.BoltDiameter hm.BoltType = h.BoltType hm.HoleType = 'Standard Round' hm.Diameter = hm.CalculateHoleSize() hm.SlotLength = hm.CalculateSlotLength() hm.Create()

b = bolt_add.Bolt() b.Material = [rp1] b.Match = [rp2] b.Diameter = h.BoltDiameter b.BoltType = h.BoltType b.Direction = 'Out' b.SuppressWarnings = 'Yes' b.IsFieldBolt = 'Field' if mem1 != mem2 else 'Shop' b.AddMatch()

The problem with custom members and components is that rp1 and h are added in CreateMaterial, rp2 in CreateMaterialOther, hm in CreateHoleMatch, and b in CreateDependentMaterial. Hence the developer is responsible for untangling the natural way to write this design. Since RectPlate, Hole, and Bolt can't be stored as part of the pickle it becomes harder than it should be (notice hm.Holes depends on h and attributes of b depend on rp1, rp2, and h). When the number of materials, bolts, welds, and holes gets large unraveling this by hand becomes tedious and error prone.

Another problem that this package attempts to solve is the complexity of conforming to the process protocol. Notice, when rp1, h, rp2, hm, and b are defined the program knows exactly which member the objects should go on. If instead of actually adding them to the job, AddBoltedPlates stored them in a list to be added later, then generic implementations of Modifies and the the material creation methods could simply use this list to do the correct thing. AddBoltedPlates becomes the plugin's Design method and is as natural to write as a traditional parametric.