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.
Attribute Table# Name
Type
units
str
Method Table# Name
Description
castForGet
(self, obj, value)Converts and returns the location value to gui units.
castForSet
(self, obj, value)Converts and validates the location value before setting it.
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, obj=None, attr=None)#
Bases:
Point
Point in a reference frame
Attribute Table# Name
Type
guiLabel
property
guiValue
property
Method Table# 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 location value before setting it.
- Parameters:
obj (GeneralObject) – Object this attribute belongs to.
value (list[float]) – Value of the attribute to set.
- Returns:
Validated and converted value.
- Return type:
- castForGet(obj, value)#
Converts and returns the location value to gui units.
- class Listener(*typesOrObjects)#
Bases:
ModelListener
Attribute Table# Name
Type
coord
NoneType
Method Table# 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.
- class UV(iterable=(), /)#
Bases:
tuple
Method Table# Name
Description
resolve
(self, normalize=False)
- 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.