def addPoint(self, pt): pt3D = Convert.Point3dToP3D(pt) self.pts.append(pt3D) # find new center self.ptCenter = GeometryOperations.midPoint(self.pts)
def drawFrame(_plane, _scale): # Annotation Layer layerName = "Annotation-Frame" rs.EnableRedraw(False) if not rs.IsLayer(layerName): rs.AddLayer(layerName) rs.LayerColor(layerName, Color.FromArgb(100, 100, 100)) ptPointOnXAxe = GeometryOperations.movePoint(_plane[0], _plane[1]) ptPointOnYAxe = GeometryOperations.movePoint(_plane[0], _plane[2]) ptPointOnZAxe = GeometryOperations.movePoint(_plane[0], _plane[3]) x = rs.AddLine(_plane[0], ptPointOnXAxe) rs.ScaleObject(x, _plane[0], (_scale, _scale, _scale)) rs.CurveArrows(x, 2) y = rs.AddLine(_plane[0], ptPointOnYAxe) rs.ScaleObject(y, _plane[0], (_scale, _scale, _scale)) rs.CurveArrows(y, 2) z = rs.AddLine(_plane[0], ptPointOnZAxe) rs.ScaleObject(z, _plane[0], (_scale, _scale, _scale)) rs.CurveArrows(z, 2) rs.ObjectColor(x, (200, 100, 100)) rs.ObjectColor(y, (100, 200, 100)) rs.ObjectColor(z, (100, 100, 200)) rs.ObjectLayer(x, layerName) rs.ObjectLayer(y, layerName) rs.ObjectLayer(z, layerName) rs.AddGroup("Annotation-Frame") rs.AddObjectsToGroup((x, y, z), "Annotation-Frame") rs.EnableRedraw(True)
def isPointInRange(self, pt): boolIsCloseToEveryone = True for ptMemeber in self.pts: # I evaluate if there is some distance larger than critical distance, if yes it is not part fo cluster. if GeometryOperations.distance2Points(ptMemeber, pt) > self.radius*2: boolIsCloseToEveryone = False break if boolIsCloseToEveryone: return True else: return False
def drawVector(vector, origin): """ this function draws vector in rhino """ layerName = "Annotation-Vector" if not rs.IsLayer(layerName): rs.AddLayer(layerName) rs.LayerColor(layerName, Color.FromArgb(150, 50, 50)) print(rs.VectorLength(vector)) lineID = rs.AddLine(origin, GeometryOperations.movePoint(origin, vector)) rs.CurveArrows(lineID, 2) rs.ObjectLayer(lineID, layerName) rs.ObjectColor(lineID, (150, 150, 150)) return lineID