Direction (hwx.inspire.Attributes)#

class Direction(default=(0, 0, 1), **kwds)#

Bases: HasReferenceFrame, Triple

Specify a direction relative to another entity.

Directions are get or set in global coordinates.

Directional components are [x,y,z].

Directions are not normalized, this is required to match Inspire behaviour of showing non normalized directions in Property Editor.

Method Table#

Name

Description

castForGet (self, obj, value)

Returns and validates the specified value.

getGuiValue (self, obj, component=None, **kwds)

Formats the direction value to display it in the Property Editor.

Example

from hwx.inspire import *

class Arrow(GeneralObject):
   part      = Reference(Part)
   direction = Direction((2,0,0), wrt=part)

model = newModel()
cyl = model.createSolidCylinder()
obj = Arrow(part=cyl)

# Directions aren't stored normalized
print(obj, "magnitude =", obj.direction.magnitude())

# Directions wrt a part rotate with it
cyl.position = cyl.position.rotz(180)
assert obj.direction.close((-2,0,0))
castForGet(obj, value)#

Returns and validates the specified value.

getGuiValue(obj, component=None, **kwds)#

Formats the direction value to display it in the Property Editor.

Parameters:
  • obj (GeneralObject) – Object to get direction value from.

  • component (str) – Specifies which component of the direction is needs formatting. Component can be ‘x’, ‘y’ or ‘z’.

Returns:

Formatted direction value.

Return type:

str

class Vector(x=0, y=0, z=0, obj=None, attr=None)#

Bases: Vector

Vector in a reference frame

Value#

alias of Vector