def get_prop(self): """Returns structural properties from layer (last child only).""" if self.depth == 2: return "" return ri.RhinoInput(self.last).get_prop()
def get_grp(self): """Returns group number from layer; -1 if not specified.""" grp = -1 if self.depth > 2: inp = ri.RhinoInput(self.path[2]) grp = inp.get_no() return grp
def build_base(self): """Sets element attributes based on Guid name from Rhino.""" # start- and endpoints of lines are nodes, but they do not need to have a point object associated to them # in this case, self.geo is None and the no, prop and name attributes stay as the default values set in the constructor if (self.geo): attr = ri.RhinoInput(rs.ObjectName(self.geo)) self.no = attr.get_no() if (self.no != -1): self.strict_naming = True self.name = attr.get_name() self.prop = attr.get_prop()
def test_square_brackets_only(self): inp = ri.RhinoInput("[]") self.assertEqual(inp.get_no(), -1) self.assertEqual(inp.get_prop(), "") self.assertEqual(inp.get_name(), "")
def test_without_square_brackets(self): inp = ri.RhinoInput("gdiv 4 { some beam}") self.assertEqual(inp.get_no(), -1) self.assertEqual(inp.get_prop(), "gdiv 4") self.assertEqual(inp.get_name(), "some beam")
def test_all(self): inp = ri.RhinoInput(" 2 [ gdiv 4 ] { some beam}") self.assertEqual(inp.get_no(), 2) self.assertEqual(inp.get_prop(), "gdiv 4") self.assertEqual(inp.get_name(), "some beam")
def test_number_and_name(self): inp = ri.RhinoInput(" 2 { some beam}") self.assertEqual(inp.get_no(), 2) self.assertEqual(inp.get_prop(), "") self.assertEqual(inp.get_name(), "some beam")
def test_number_and_property(self): inp = ri.RhinoInput(" 2 [ncs 5]") self.assertEqual(inp.get_no(), 2) self.assertEqual(inp.get_prop(), "ncs 5") self.assertEqual(inp.get_name(), "")
def test_number_only_with_whitespace(self): inp = ri.RhinoInput(" 2 ") self.assertEqual(inp.get_no(), 2)
def test_number_only(self): inp = ri.RhinoInput("2") self.assertEqual(inp.get_no(), 2)
def test_has_number(self): inp = ri.RhinoInput("4") self.assertEqual(inp.has_number(), True)
def test_does_not_have_a_number(self): inp = ri.RhinoInput("4alma") self.assertEqual(inp.has_number(), False)
def test_get_between(self): inp = ri.RhinoInput("adf [alma]") self.assertEqual(inp.get_between("[", "]"), "alma")
def test_get_before(self): inp = ri.RhinoInput("adf [alma]") self.assertEqual(inp.get_before("[", "]"), "adf ")
def get_name(self): """Returns group name from layer (last child only).""" return ri.RhinoInput(self.last).get_name()