Location (hwx.inspire.Attributes)#
- class Location(default=(0, 0, 0), **kwds)#
Bases:
HasReferenceFrame
,Triple
Store a location relative to another entity.
Locations are get or set in global coordinates.
Locations relative to Features have special code to stay at the same point on the feature after feature modifications like push/pull.
# Name
Type
units
str
# Name
Description
castForSet
(self, obj, value)getCoord
(self, feature, point)Converts the location on the feature into UV coordinates.
getCoordLocation
(self, feature, coord, normalized=False)Convert coordinates to location from the specified feature.
Example
from hwx.inspire import * class PointOnFace(GeneralObject): feature = Reference(Feature) location = Location(wrt=feature) model = newModel() cyl = model.createSolidCylinder() face = cyl.getFeatures(FeaturePlanar)[0] obj = PointOnFace(feature=face, location=face.location) # Locations wrt a feature move with the feature.part start = obj.location obj.feature.part.position *= math.Matrix44(origin=(1,1,1)) print('location moved from', start, 'to', obj.location) # Locations wrt a feature stay attached during geometry changes start = obj.location face.pushPull(2) assert obj.location.close(start + face.normal*2)
- class Point(x=0, y=0, z=0)#
Bases:
Point
Point in a reference frame
# Name
Description
getCoord
(self, normalized=True)Get UV coordinate on wrt feature.
isTouchingFeature
(self)Is point touching its wrt feature?
swap
(self, other)Swap location and wrt entity with another location without the rounding
- getCoord(normalized=True)#
Get UV coordinate on wrt feature. - None is returned if point is not touching feature
- isTouchingFeature()#
Is point touching its wrt feature?
- swap(other)#
Swap location and wrt entity with another location without the rounding error that is caused by converting the location to and from global coordinates.
Roughly equivalent to doing (without rounding error): self.entity1, self.entity2 = self.entity2, self.entity1 self.location1, self.location2 = self.location2, self.location1
- castForSet(obj, value)#
Converts and validates the value of the attribute before setting.
Converts the value it to its internal type (and base units if applicable).
- Parameters:
obj (GeneralObject) – Object this attribute belongs to.
value (Any) – Value of the attribute to set.
- Returns:
Validated and converted value.
- Return type:
value (Any)
- class Listener(*typesOrObjects)#
Bases:
ModelListener
# Name
Type
coord
NoneType
# Name
Description
activateModelListener
(self, attr, obj)onObjectModified
(self, part, attr)onValueChanged
(self)syncValueWithCoord
(self, value)- activateModelListener(attr, obj)#
- Activates or start listening to the data model and call the handlers,
when the specified types are created, destroyed or modified.
- getCoord(feature, point)#
Converts the location on the feature into UV coordinates.
None is returned if point is not touching feature
- getCoordLocation(feature, coord, normalized=False)#
Convert coordinates to location from the specified feature.