def __init__(self, coord_input, pyp_path, str_table_service): """ Initialization of class Line3DInteractor Args: coord_input: coordinate input pyp_path: path of the pyp file str_table_service: string table service """ self.coord_input = coord_input self.pyp_path = pyp_path self.str_table_service = str_table_service self.first_point_input = True self.first_point = AllplanGeo.Point3D() self.model_ele_list = None self.build_ele_service = BuildingElementService() #### self.current_point = AllplanGeo.Point3D() self.valid_input = False self.b_use_input_pnt = True self.polyline_lenght = 0.0 self.frist_run_transf = True self.cont_polyline = AllplanGeo.Polyline3D() #----------------- read the data and show the palette print(pyp_path + "\\DryWall_3.pal") result, self.build_ele_script, self.build_ele_list, self.control_props_list, \ self.build_ele_composite, part_name, self.file_name = \ self.build_ele_service.read_data_from_pyp(pyp_path + "\\DryWall_3.pal", self.str_table_service.str_table, False, self.str_table_service.material_str_table) if not result: return self.palette_service = BuildingElementPaletteService( self.build_ele_list, self.build_ele_composite, self.build_ele_script, self.control_props_list, self.file_name) self.palette_service.show_palette(part_name) self.points = [] #----------------- get the properties and start the input self.com_prop = AllplanBaseElements.CommonProperties() self.set_common_properties() self.coord_input.InitFirstPointInput( AllplanIFW.InputStringConvert("From point"))
def create_element(build_ele, doc): """ Creation of element (only necessary for the library preview) Args: build_ele: the building element. doc: input document """ del build_ele del doc com_prop = AllplanBaseElements.CommonProperties() com_prop.GetGlobalProperties() poly = AllplanGeo.Polyline3D() poly += AllplanGeo.Point3D(0, 0, 0) poly += AllplanGeo.Point3D(0, 0, 1000) poly += AllplanGeo.Point3D(500, 0, 1000) poly += AllplanGeo.Point3D(500, 500, 2000) model_ele_list = [AllplanBasisElements.ModelElement3D(com_prop, poly)] return (model_ele_list, None, None)
def add_joins_right(self, build_ele, com_prop_stroke, type=1): wall_length = build_ele.Length1_1.value wall_width = build_ele.Width1_1.value wall_thickness = build_ele.Thickness1_1.value j_a = build_ele.type2_a.value j_c = build_ele.type2_c.value j_d = build_ele.type2_d.value join2_point = AllplanGeo.Polygon2D() path2 = AllplanGeo.Polyline3D() ref_pnt = AllplanGeo.Point2D(0, 0) if (type == 1): j_b = wall_thickness / 2 join2_point += AllplanGeo.Point2D(0, -j_a / 2) join2_point += AllplanGeo.Point2D(-j_c, -j_d / 2) join2_point += AllplanGeo.Point2D(-j_c, j_d / 2) join2_point += AllplanGeo.Point2D(0, j_a / 2) join2_point += AllplanGeo.Point2D(0, -j_a / 2) if not GeometryValidate.is_valid(join2_point): return path2 += AllplanGeo.Point3D(wall_length, j_b, 0) path2 += AllplanGeo.Point3D(wall_length, j_b, wall_width) if (type == 2): j_b = build_ele.type2_b.value join2_point += AllplanGeo.Point2D(-j_a / 2, 0) join2_point += AllplanGeo.Point2D(-j_d / 2, j_c) join2_point += AllplanGeo.Point2D(j_d / 2, j_c) join2_point += AllplanGeo.Point2D(j_a / 2, 0) join2_point += AllplanGeo.Point2D(-j_a / 2, 0) if not GeometryValidate.is_valid(join2_point): return path2 += AllplanGeo.Point3D(wall_length - j_b, 0, 0) path2 += AllplanGeo.Point3D(wall_length - j_b, 0, wall_width) handle_b2 = HandleProperties( "Moveb2", AllplanGeo.Point3D(wall_length - j_b, 0, 0), AllplanGeo.Point3D(wall_length, 0, 0), [("type2_b", HandleDirection.x_dir)], HandleDirection.x_dir, True) self.handle_list.append(handle_b2) if (type == 3): join2_point += AllplanGeo.Point2D(0, 0) join2_point += AllplanGeo.Point2D(-j_c, 0) join2_point += AllplanGeo.Point2D(-j_c, j_d) join2_point += AllplanGeo.Point2D(0, j_a) join2_point += AllplanGeo.Point2D(0, 0) if not GeometryValidate.is_valid(join2_point): return path2 += AllplanGeo.Point3D(wall_length, 0, 0) path2 += AllplanGeo.Point3D(wall_length, 0, wall_width) err, join2 = AllplanGeo.CreatePolyhedron(join2_point, ref_pnt, path2) if not GeometryValidate.polyhedron(err): return self.model_ele_list.append( AllplanBasisElements.ModelElement3D(com_prop_stroke, join2)) return join2
def add_joins_left(self, build_ele, com_prop_stroke, type=1): wall_length = build_ele.Length1_1.value wall_width = build_ele.Width1_1.value wall_thickness = build_ele.Thickness1_1.value j_a = build_ele.type1_a.value j_c = build_ele.type1_c.value j_d = build_ele.type1_d.value join1_point = AllplanGeo.Polygon2D() path1 = AllplanGeo.Polyline3D() ref_pnt = AllplanGeo.Point2D(0, 0) if (type == 1): j_b = wall_thickness / 2 join1_point += AllplanGeo.Point2D(0, -j_a / 2) join1_point += AllplanGeo.Point2D(j_c, -j_d / 2) join1_point += AllplanGeo.Point2D(j_c, j_d / 2) join1_point += AllplanGeo.Point2D(0, j_a / 2) join1_point += AllplanGeo.Point2D(0, -j_a / 2) if not GeometryValidate.is_valid(join1_point): return path1 += AllplanGeo.Point3D(0, j_b, 0) path1 += AllplanGeo.Point3D(0, j_b, wall_width) if (type == 2): j_b = build_ele.type1_b.value join1_point += AllplanGeo.Point2D(-j_a / 2, 0) join1_point += AllplanGeo.Point2D(-j_d / 2, j_c) join1_point += AllplanGeo.Point2D(j_d / 2, j_c) join1_point += AllplanGeo.Point2D(j_a / 2, 0) join1_point += AllplanGeo.Point2D(-j_a / 2, 0) if not GeometryValidate.is_valid(join1_point): return path1 += AllplanGeo.Point3D(j_b, 0, 0) path1 += AllplanGeo.Point3D(j_b, 0, wall_width) handle_b1 = HandleProperties("Moveb1", AllplanGeo.Point3D(j_b, 0, 0), AllplanGeo.Point3D(0, 0, 0), [("type1_b", HandleDirection.x_dir)], HandleDirection.x_dir, False) self.handle_list.append(handle_b1) if (type == 3): join1_point += AllplanGeo.Point2D(0, 0) join1_point += AllplanGeo.Point2D(j_c, 0) join1_point += AllplanGeo.Point2D(j_c, j_d) join1_point += AllplanGeo.Point2D(0, j_a) join1_point += AllplanGeo.Point2D(0, 0) if not GeometryValidate.is_valid(join1_point): return path1 += AllplanGeo.Point3D(0, 0, 0) path1 += AllplanGeo.Point3D(0, 0, wall_width) err, join1 = AllplanGeo.CreatePolyhedron(join1_point, ref_pnt, path1) if not GeometryValidate.polyhedron(err): #NemAll_Python_Utility.ShowMessageBox("error",1) return #NemAll_Python_Utility.ShowMessageBox("pass2",1) self.model_ele_list.append( AllplanBasisElements.ModelElement3D(com_prop_stroke, join1)) return join1
def __create_model_element__(self, input_pnt): """ Creates the element Args: input_pnt: input point Returns: Elementlist """ if len(self.points) < 1: return if self.b_use_input_pnt == False: #calc only without mouse movement, this means for create self.polyline_lenght = 0.0 for index in range(1, len(self.points)): line_tmp = AllplanGeo.Line3D(self.points[index - 1], self.points[index]) self.polyline_lenght += AllplanGeo.CalcLength(line_tmp) if len(self.points) == 1: if self.b_use_input_pnt == False: self.model_ele_list = [] return line = AllplanGeo.Line3D(self.points[0], input_pnt) self.model_ele_list = [ AllplanBasisElements.ModelElement3D(self.com_prop, line) ] return if len(self.points) >= 2: # polyline could be created polygon = AllplanGeo.Polyline3D() for point in self.points: polygon += point if self.b_use_input_pnt == True: polygon += input_pnt if self.frist_run_transf == True: #prepare polygon for being a DRYWALL #self.cont_polyline = AllplanGeo.Polyhedron3D.CreateCuboid() #self.wall1_thickness #self.wall2_thickness #self.wall3_thickness #self.wall4_thickness #2 #self.wall1_type #self.wall2_type #self.wall3_type #self.wall4_type #3 #self.midWidth #self.height lenght = 1000 width = 500 base_pnt = AllplanGeo.Point3D() base_pnt.X -= lenght / 2 base_pnt.Y -= width / 2 polyline3D_contur = AllplanGeo.Polyline3D() polyline3D_contur += base_pnt polyline3D_contur += AllplanGeo.Point3D(base_pnt.X + lenght, base_pnt.Y, base_pnt.Z) polyline3D_contur += AllplanGeo.Point3D(base_pnt.X + lenght, base_pnt.Y + width, base_pnt.Z) polyline3D_contur += AllplanGeo.Point3D(base_pnt.X, base_pnt.Y + width, base_pnt.Z) polyline3D_contur += base_pnt self.frist_run_transf = False self.cont_polyline = self.__transform_base_polygon__( polygon, polyline3D_contur) if not self.cont_polyline.IsValid(): return print("path polygon = ", ' ', polygon) objlist = AllplanGeo.Polyline3DList() objlist.append(self.cont_polyline) vector = AllplanGeo.Vector3D() err, polyhedron = AllplanGeo.CreateSweptPolyhedron3D( objlist, polygon, True, True, vector) if not GeometryValidate.polyhedron(err): elems = [] elems.append( AllplanBasisElements.ModelElement3D(self.com_prop, polygon)) elems[-1].SetAttributes( self.create_attribute_list(self.polyline_lenght)) self.model_ele_list = elems return elems = [] elems.append( AllplanBasisElements.ModelElement3D(self.com_prop, polyhedron)) elems[-1].SetAttributes( self.create_attribute_list(self.polyline_lenght)) self.model_ele_list = elems return