SDS2 Parametric API
|
This document provides a high level overview of the SDS/2 API with references to example source code. It is assumed readers understand SDS/2 terminology and how to program in Python.
sds2_modules.py
sds2_modules.sds2_builtin_module_names()
) member
, point
, rect_plate
, rolled_section
, etc model
MemberBase
, Point3D
sds2.zip
(sds2_modules.sds2_zip_module_names()
) macro
macro/macrolib
plugins
import
modules_documented_in_quicknotes.py
dir()
for model
[a for a in dir(model) if a.find('Copy') != -1]
help()
and dir()
for "Boost Python Era" help(Component)
dir(Component)
member
point
rect_plate
, rolled_section
, etc hole_add
, bolt_add
, weld_add
mtrl_fit
, mtrl_cut
param.Units(...)
str
values everywhere model
dir()
works! Demo splice_wide_flange_rect_plate_orig.py
Point3D
class EmbedPlate(StateAccessor, MemberBase):
def init(self)
__dict__
) def Add(self)
def [Multi]Edit(self)
dialog
, model controller, ItemController
return Run() and (is_new_member or pre_state != post_state)
def CreateMaterial(self)
def OnMaterialEvent(self, mtrl_guid, material_event_id)
def OnBoltEvent(self, bolt_guid, bolt_event_id)
def OnWeldEvent(self, weld_guid, weld_event_id)
def OnMemberEvent(self, member_event_id)
def OnCopy(self)
def Mirror(self, xform)
class HandRail
def Modifies(self)
model
and shape
modules def BoundingBoxContains(self)
def Design(self)
def CreateMaterialOther(self, other)
Hash
GetSectionSize
GetViews
? Component Context (2015)
help()
/dir()
param.Units('inch')
Gadget
def CreateUI(self)
def Save(self)
def Reset(self)
def Finalize(self)
def OnGraphicalToggle(self)
OnMaterialNonGraphicalEvent(self, mtrl_guid, material_event_id)
GraphicalCreateMaterial
, et al instead of if self.graphical
view.AddMember[Preset]View
Designable
HandRail
was version 0 of the concept __dict__
Processable
Proxies
EndSplice
time_BoltedPlates
Designable
(more obvious in 2016) sds2
package
2016
gadget_protocol
sds2.lockable
sds2.breakapart
sds2.status_display
Polgyon
PLUGIN
format MaterialBase
MemberBase.AddMaterial
def GetAlternateMembLinePoints(self)
Storage
Reports.ReportWriter
CNC
IFC
Kiss
Drawing
RFI
DesignCalcs
selection_examples.py
gui_examples.py
dialog
Quick Notes Gadget
(2015) componentedit
(2015) sds2.utilities.gadget_protocol
(2016) sds2.utilities.gadget_protocol_member
(2016) Line3D
Point3D
Math3D
Transform3D
macrolib
Polygon
(2016) Tools.RunTool
) model.ChangeOneMaterial
gen_mtrl.SetPiecemark
member.Update
model.object
attribute + model.WriteOnlyThis
/model.WriteGraphical
sds2.lockable
(2016) model.object
attribute + model.WriteOnlyThis
/model.WriteGraphical
param.Units
<type 'Point3D.Point3D'>
type(Point3D.Point3D(0, 0, 0))
type(MemberBase.GetMemberLink(1,False,False).left_location)
<type 'point'>
type(point.Point(0, 0, 0))
type(member.Member(1).LeftEnd.Location)
<type 'model.point3'>
type(model.member(1).ends[0].location)
type(sds.obj.le(1).location)
<type 'modelobject'>
type(model.object(1))
type(model.member(1))
type(sds.obj.m(1))
<type 'member'>
type(member.Member(1))
MemberBase.MemberBase
type(MemberBase.GetMemberLink(1,False,False))
type(sds.obj.mb(1))
rnd_bar.RndBar
, etc.) <type 'gen_mtrl'>
type(member.Member(1).Material(0))
type(mtrl_list.MtrlLocate('Locate mtrl', 'Single'))
type(sds2.obj.gen_mt(1,0))
<type 'modelobject'>
type(model.object(1, -1, 0)
type(model.member(1).materials[0])
type(sds2.obj.mt(1,0))
type(member.Member(1).Material(0).modelobject())
<type 'mtrl_list'>
a = mtrl_list.MtrlLocate('Locate one mtrl', 'Copy')
<type 'hole_add'>
type(hole_add.Hole())
<type 'hole_list'>
hole_list
is just one hole type(sds2.obj.gen_mt(1,0).HoleList()[0])
<type 'modelobject'>
type(model.object(1, -1, 0, 0)
type(model.member(1).materials[0].holes[0])
type(sds2.obj.h(1,0,0))
type(sds2.obj.gen_mt(1,0).HoleList()[0].modelobject())
bool
, int
, str
, model.Enum
, radians, degrees, mm, inches, uuids model.object
model
, gen_mtrl.HoleList
) model
, e.g. dir(next(sds2.iterators.all_bs()))
) model
, e.g. dir(next(sds2.iterators.all_ws()))
) model
, e.g. dir(next(sds2.iterators.all_es()))
member
, quicknotes or dir(member.Member(1).LeftEnd)
sds2.lockable
(2016) help(view.MemberViewTuple)
) Component
) sds2.sub_mtrl
) evu
) cons_line
) cons_circle
) GroupMember
) CustomProperties
member.MemberProperties
mtrl_list.MtrlProperies
Drawing
) job
, fab
) evu
) cons_line
) cons_circle
) member.GroupMemberCreate
, GroupMember
) Designable.Proxies
__eq__
, __ne__
rect_plate.RectPlate
(thickness, width, p1, p2, member_number, subm_to_global) = ...
m = rect_plate.RectPlate()
m.Thickness = thickness
m.Width = width
m.Point1 = point.Point(p1) # must be specified and point.Point or tuple
m.Point2 = point.Point(p2) # must be specified and point.Point or tuple
m.MaterialOriginPoint = 'NS'
m.WorkpointSlopeDistance = m.Point1.dist(m.Point2)
m.Member = member.Member(member_number) # must be member.Member
if model.member(member_number).galvanizing:
m.SurfaceFinish = fab.Fabricator().galv_surface_finish
m.MaterialColor3d = 'Medium_material'
m.Add()
m.SetTransform(subm_to_global)
Designable.Proxies.RectPlate
(thickness, width, wkpt_slope, member_number, subm_to_global) = ...
notice, wkpt_slope instead of p1 and p2
uses reasonable SurfaceFinish automatically
uses reasonable MaterialColor3d automatically
RectPlate(
Thickness=thickness,
Width=width,
MaterialOriginPoint='NS',
WorkpointSlopeDistance=wkpt_slope,
Member=member_number,
_submaterial_to_global=subm_to_global
).Execute()
hole_add.Hole
mtrl, pt1 = ...
h = hole_add.Hole()
h.Material = [mtrl]
h.pt1 = point.Point(pt1)
h.face = 'FS Face'
h.Columns = 1
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()
Designable.Proxies.Hole
mtrl, pt1 = ...
h = Hole(
Material=[mtrl], # works for generic materials
pt1=pt1, # works for generic points
face='FS Face',
Columns=1,
Rows=1,
Locate='Center',
BoltDiameter=1.,
BoltType='AUTO',
HoleType='Standard Round'
)
h.Diameter = h.CalculateHoleSize()
h.SlotLength = h.CalculateSlotLength()
h.Execute()
weld_add.Weld
mtrl, p1, p2, depth_vector = ...
w = weld_add.Weld()
w.Material = [mtrl]
w.Type = 'Fillet'
w.Size = 3/16.
w.GrooveAngle = 45.
layout = Layout3D.Layout3D()
layout.add_node(Point3D.Point3D(p1), 0.)
layout.add_node(Point3D.Point3D(p2), 0.)
layout.set_depth_vectors(depth_vector, True)
w.layout = layout
w.create()
Designable.Proxies.Weld
/Layout3D
mtrl, p1, p2 = ...
notice no explicit depth vector
Weld(
Material=[mtrl],
Type='Fillet',
Size=3/16.,
GrooveAngle=45.,
layout=Layout3D([(p1, 0.), (p2, 1.)])
).Execute()
Plugins are python packages and modules placed in specific directories of the filesystem which extend and customize SDS/2's system behavior.
plugin
directory ExamplePlugin
__init__.py
(import ExamplePlugin
) PLUGIN
(CUSTOM_MEMBER
, PYTOOL
, or empty file) ExamplePlugin.py
class ExamplePlugin(MemberBase.MemberBase):
class ExamplePlugin(Designable.ProcessableMember.ProcessableMember):
class ExamplePlugin(Component.Component):
class ExamplePlugin(Designable.ProcessableComponent.ProcessableComponent):
help(MemberBase.RegisterMemberType)
help(PluginSetupTools.RegisterPluginSetup)
help(Component.RegisterComponentType)
help(PluginSetupTools.RegisterPluginSetup)
help(component_tools.RegisterComponentAddCommand)
len(Plugin.__name__) <= 16
MemberBase.MemberBase.SetMemberType
should be self.__class.__name__
Designable.ProcessableMember
Construction
def init(self, args, kwds):
help(job)
help(PluginSetupTools.RegisterPluginSetup)
rotation
__getstate__
/__setstate__
StateAccessor
in 7.3 Designable.Processable
in 2015 __dict__
(and thus practically solves versioning) MemberBase.UseLastSavedMemberOnAdd
Add
param.Units('inch')
help(MemberBase.RegisterMemberType)
) help(MemberBase.MemberBase.Add)
left_location
, right_location
, SetOrientation()
UseLastSavedMemberOnAdd
Component.Component.IsAllowedOnMember
filters preselection and postselection help(Component.Component.SetReferencePointForMemberUI)
ref_point
(see indicator on hover) ProcessableComponent.ref_point_in_global
ExamplePlugin().Add()
should run without exception Edit
param.Units('inch')
(..called on c-side in 2015) def Edit(self): return self.MultiEdit([])
def MultiEdit(self, others):
return clicked_ok and (is_being_added or something_changed)
return clicked_ok #other stuff handled on the c-side
__eq__/__getstate__
Component.Component.GetState
ProcessableComponent
handles graphical
toggles correctly graphical
checkbox (it is a builtin attribute) Component.Component.EditBeforeAddingToMember
Designable.Processable.HasYetToBeAddedToJob
model.member(cm.member_number).mem_stat == model.Added
not c.uuid == Uuid.Uuid()
help(componentedit
)) DesignableExamples.BoltedPlates.BoltedPlatesEdit
Copy
MemberBase.MemberBase.OnCopy
MemberBase.MemberBase.Mirror
Component.CanBeCopiedToOtherMembers
Component.IsAllowedOnMember
Component.OnMemberCopy
Component.OnMemberMirrorCopy
Component.IsAllowedOnMember
copy.deepcopy
Component.OnMemberCopy
Modifies
Design
CreateMaterial
|CreateMaterialOther
| CreateHoleMatch
|CreateHoleMatchOther
| CreateDependentMaterial
|CreateDependentMaterialOther
| ProcessFinal
|ProcessFinalOther
| GraphicalCreateMaterial
in 2015 CreateHoleOnMainMaterialOther
/CreateHoleMatchOnMainMaterialOther
in 2015 help(Component)
for more details help(Designable)
for an easier way
The Designable
package makes writing processable plugins easier by exploiting what the developer has already specified once, e.g. the API to hole match already signals what phase of process the operation must occur in and what members are involved.
The package should be easy to adopt because the syntax supported by the Proxies
module is backward compatible with the older API for adding material. Switching legacy code over to using Proxies
should just be a matter of changing import statements.
StateAccessor
Proxies
do not require many explicit attributes MaterialAddProxy.finish
, MaterialAddProxy.color
Processable
s require two methods MembersCurrentlyObserved
DesignForMember