def xdraw_pipes(pipes, cap=2, fit=1.0): abs_tol = TOL ang_tol = sc.doc.ModelAngleToleranceRadians for p in pipes: points = p['points'] radius = p['radius'] params = [0.0, 1.0] cap = ToObject(PipeCapMode, cap) if type(radius) in (int, float): radius = [radius] * 2 radius = [float(r) for r in radius] rail = Curve.CreateControlPointCurve([Point3d(*xyz) for xyz in points]) breps = Brep.CreatePipe(rail, params, radius, 1, cap, fit, abs_tol, ang_tol) for brep in breps: yield brep
def draw_pipes(pipes, cap=2, fit=1.0): """Draw pipes. Parameters ---------- pipes : list of dict The pipe definitions. Other Parameters ---------------- cap : {0, 1, 2}, optional fit : float, optional Returns ------- list of :class:`Rhino.Geometry.Brep` Notes ----- .. code-block:: python Schema({ 'points': lambda x: all(len(y) == 3 for y in x), 'radius': And(Or(int, float), lambda x: x > 0) }) """ abs_tol = TOL ang_tol = sc.doc.ModelAngleToleranceRadians for p in pipes: points = p['points'] radius = p['radius'] params = [0.0, 1.0] cap = ToObject(PipeCapMode, cap) if type(radius) in (int, float): radius = [radius] * 2 radius = [float(r) for r in radius] rail = Curve.CreateControlPointCurve([Point3d(*xyz) for xyz in points]) breps = Brep.CreatePipe(rail, params, radius, 1, cap, fit, abs_tol, ang_tol) for brep in breps: yield brep
def xdraw_pipes(pipes, cap=2, fit=1.0, **kwargs): guids = [] abs_tol = TOL ang_tol = sc.doc.ModelAngleToleranceRadians for p in pipes: points = p['points'] radius = p['radius'] name = p.get('name', '') color = p.get('color') layer = p.get('layer') params = [0.0, 1.0] cap = ToObject(PipeCapMode, cap) if type(radius) in (int, float): radius = [radius] * 2 radius = [float(r) for r in radius] rail = Curve.CreateControlPointCurve([Point3d(*xyz) for xyz in points]) breps = Brep.CreatePipe(rail, params, radius, 1, cap, fit, abs_tol, ang_tol) temp = [add_brep(brep) for brep in breps] for guid in temp: if not guid: continue obj = find_object(guid) if not obj: continue attr = obj.Attributes if color: attr.ObjectColor = FromArgb(*color) attr.ColorSource = ColorFromObject else: attr.ColorSource = ColorFromLayer if layer and find_layer_by_fullpath: index = find_layer_by_fullpath(layer, True) if index >= 0: attr.LayerIndex = index attr.Name = name attr.WireDensity = -1 obj.CommitChanges() guids.append(guid) return guids
def draw_pipes(pipes, cap=2, fit=1.0, **kwargs): """Draw pipes and optionally set individual name, color, and layer properties. Parameters ---------- pipes : list of dict A list of pipe dictionaries. Other Parameters ---------------- cap : {0, 1, 2}, optional fit : float, optional Returns ------- list of GUID Notes ----- A pipe dict has the following schema: .. code-block:: python Schema({ 'points': And(list, lambda x: all(len(y) == 3 for y in x)), 'radius': And(Or(int, float), lambda x: x > 0.0), Optional('name', default=''): str, Optional('color', default=None): And(lambda x: len(x) == 3, all(0 <= y <= 255 for y in x)), Optional('layer', default=None): str, }) """ guids = [] abs_tol = TOL ang_tol = sc.doc.ModelAngleToleranceRadians for p in pipes: points = p['points'] radius = p['radius'] name = p.get('name', '') color = p.get('color') layer = p.get('layer') params = [0.0, 1.0] cap = ToObject(PipeCapMode, cap) if type(radius) in (int, float): radius = [radius] * 2 radius = [float(r) for r in radius] rail = Curve.CreateControlPointCurve([Point3d(*xyz) for xyz in points]) breps = Brep.CreatePipe(rail, params, radius, 1, cap, fit, abs_tol, ang_tol) temp = [add_brep(brep) for brep in breps] for guid in temp: if not guid: continue obj = find_object(guid) if not obj: continue attr = obj.Attributes if color: attr.ObjectColor = FromArgb(*color) attr.ColorSource = ColorFromObject else: attr.ColorSource = ColorFromLayer if layer and find_layer_by_fullpath: index = find_layer_by_fullpath(layer, True) if index >= 0: attr.LayerIndex = index attr.Name = name attr.WireDensity = -1 obj.CommitChanges() guids.append(guid) return guids