Coupler (hwx.inspire.motion)#
- class Coupler(self, entity1=None, entity2=None, entity3=None, scales=None, **kwargs)#
Bases:
MotionObject
Simulates the rotational or translational movements of connected parts.
- A coupler allows us to specify a mathematical ratio which affects the movement
of parts. It is useful for conceptual prototyping and general motion modeling.
# Name
Type
property
folder
str
icon
str
property
redrawWhenUnitsChanged
bool
# Name
Description
flipEntities
(self)Reverses the order of entities used to create a coupler. Also revereses
getAxisJoint
(obj, axisHint=None, ignore=None)Returns a candidate joint with axis(allows the connecting parts to move).
getCandidates
(part, skip=None, distance=0)Scan out from the passed in part through the part-joint connectivity graph
getExistingCouplerBetweenParts
(*args)Returns the coupler that (probably) couples the given parts, or None.
getRatioString
(self)Return a string of the format {scale1} : {scale2} [: {scale3}]
getUnambiguousJointType
(joint)Return ‘ROTATION’ if the given joint or entity with implicit joints can
hideCouplers
()inferRatio
(a, b=None)Given two parts, or a free joint with two parts, try to give two integer
isAmbiguous
(joint)Return True if the given joint/entity /w implicit joint would be a valid
showCouplers
(on=True)Show graphics for the contact while in the context
Example
from hwx import inspire from hwx.inspire import motion M44 = inspire.math.Matrix44 model = inspire.newModel() for i in range(2): model.createSolidBlock(z=.2, position=M44(origin=(0,0,i))), model.createSolidBlock(z=.2, position=M44(origin=(0,0,i+.2)), ground=True), # Cut hole through boxes cyl = model.createSolidCylinder(height=100, radius=.25) for box in model.parts: box.booleanSubtract(cyl, keepTools=True) cyl.destroy() # Create joints through holes for hole in model.holes.aligned: inspire.Joint(hole, type='Pin', behavior='Rigid') joint1, joint2 = model.joints # Motor to make parts spins motor = motion.Motor(joint2, duration=10, type='ANGLE', value=360) # Create coupler coupler = motion.Coupler(entities=[joint1, motor], scales=[1,2]) print('Ratio:', coupler.getRatioString()) print('Do a Motion Analysis to see Block 1 spin') # To help visualize spinning for box in model.parts[::2]: corner = box.features[6] motion.Tracer(pen=corner, location=corner.location) inspire.fitView()
- property type1#
Type of coupling used for the first joint entity.
The Type can be Rotational or Translational.
- property scale1#
Scale for the Joint 1 Coupling.
By default the scale is 360 deg for Rotational and 100 mm for Translational coupling.
- property type2#
Type of coupling used for the second joint entity.
The Type can be Rotational or Translational.
- property scale2#
Scale for the Joint 2 Coupling.
By default the scale is 360 deg for Rotational and 100 mm for Translational coupling.
- property type3#
Type of coupling used for third joint entity.
The Type can be Rotational or Translational.
- property scale3#
Scale for the Joint 3 Coupling.
By default the scale is 360 deg for Rotational and 100 mm for Translational coupling.
- property reverseDirection#
Reverses the direction of Rotation or Translation of the coupler, if True.
- property reverse3rdDirection#
Reverses the direction for Joint 3 Coupling, if True.
- property entities#
List of joint entities coupled.
- property types#
Specifies the type of coupling for each coupled entities.
- property color#
Color of the coupler.
- property entity1#
The first joint entity used for coupling.
- property entity2#
The second joint entity used for coupling.
- property entity3#
The third joint entity used for coupling.
- property scales#
Specifies the scale value to determine the coupler ratio.
- flipEntities()#
Reverses the order of entities used to create a coupler. Also revereses the ratio to match.
- property location#
Returns the mid-location of all the joints used to create a coupler.
- property entityset#
Returns a frozenset of entities used to create the coupler.
- getRatioString()#
Return a string of the format {scale1} : {scale2} [: {scale3}]
- static inferRatio(a, b=None)#
Given two parts, or a free joint with two parts, try to give two integer values that define their relative movement ratio, i.e. giving a rack and a pinion will return a and b where the pinion rotating b degrees moves the rack a meters.
If scales can not be inferred, return None.
If a free joint is provided, and shape identification fails on the parts, this will attempt to use the surface information in the free joint to infer the ratio.
- static isAmbiguous(joint)#
Return True if the given joint/entity /w implicit joint would be a valid subject for both rotational and translational coupling.
- static getUnambiguousJointType(joint)#
Return ‘ROTATION’ if the given joint or entity with implicit joints can be coupled rotationally, “TRANSLATION” if it can only be coupled translationally, or None if it cannot be coupled at all.
- static getAxisJoint(obj, axisHint=None, ignore=None)#
Returns a candidate joint with axis(allows the connecting parts to move).
Raises ValueError if no candidate joint can be found.
- Parameters:
obj (AnalyticalShapeData, Part) – obj can be an AnalyticalShape instead of a Part, in which case data from it will be used to pick a better candidate. This will never raise when given an AnalyticalShape if it doesn’t on the part that AnalyticalShape is made from; if the data from the AnalyticalShape prove that none of the candidates it would have returned otherwise make sense, it will just return one of them anyway.
axisHint (math.Vector) – Is an approximation of the rotation axis of the part, and it is used to enhance the heuristic results.
ignore (CouplerCandidates) – To skip any specific candidate.