def __transform_base_polygon__(self, path, polyline3D_contur): """ Transforms the base polygon3D Args: path: only the first segment is needed polyline3D_contur: will be transformed to placed perpendicular on the first segment of the path Returns: transformed polyline3D_contur """ pnt1 = path.GetPoint(0) pnt2 = path.GetPoint(1) diff_x = pnt2.X - pnt1.X diff_y = pnt2.Y - pnt1.Y diff_z = pnt2.Z - pnt1.Z tmp_plane = AllplanGeo.Plane3D( AllplanGeo.Point3D(0, 0, 0), AllplanGeo.Vector3D(diff_x, diff_y, diff_z)) matrix = AllplanGeo.Matrix3D() matrix = tmp_plane.GetTransformationMatrix() result = AllplanGeo.Transform(polyline3D_contur, matrix) matrix2 = AllplanGeo.Matrix3D() matrix2.SetTranslation(AllplanGeo.Vector3D(pnt1.X, pnt1.Y, pnt1.Z)) result = AllplanGeo.Transform(result, matrix2) return result
def add_windows(self, build_ele, com_prop_stroke, wall_length, wall_width, wall_thickness): p_x = build_ele.win_x.value p_y = 0 p_z = build_ele.win_z.value void_length = build_ele.win_length.value void_width = build_ele.win_width.value void_thickness = wall_thickness void = AllplanGeo.Polyhedron3D.CreateCuboid(void_length, void_thickness, void_width) trans_to_ref_point_2 = AllplanGeo.Matrix3D() trans_to_ref_point_2.Translate(AllplanGeo.Vector3D(p_x, p_y, p_z)) void = AllplanGeo.Transform(void, trans_to_ref_point_2) self.model_ele_list.append( AllplanBasisElements.ModelElement3D(com_prop_stroke, void)) #--------------------------------------------------------------------------------------# #----------------------------------Void Handle-----------------------------------------# #--------------------------------------------------------------------------------------# origin = AllplanGeo.Point3D(0, 0, 0) originwin = AllplanGeo.Point3D(p_x, 0, p_z) win_plength = AllplanGeo.Point3D(p_x + void_length, 0, p_z) win_pwidth = AllplanGeo.Point3D(p_x, 0, p_z + void_width) win_pointx = AllplanGeo.Point3D(p_x + void_length / 2, 0, p_z) win_pointz = AllplanGeo.Point3D(p_x, 0, p_z + void_width / 2) handle_winlength = HandleProperties( "windowsMoveLength", win_plength, originwin, [("win_length", HandleDirection.x_dir)], HandleDirection.x_dir, True) self.handle_list.append(handle_winlength) handle_winwidth = HandleProperties( "windowsMoveWidth", win_pwidth, originwin, [("win_width", HandleDirection.z_dir)], HandleDirection.z_dir, True) self.handle_list.append(handle_winwidth) handle_winx = HandleProperties("windowsMoveX", win_pointx, originwin, [("win_x", HandleDirection.x_dir)], HandleDirection.x_dir, False) self.handle_list.append(handle_winx) handle_winz = HandleProperties("windowsMoveZ", win_pointz, origin, [("win_z", HandleDirection.z_dir)], HandleDirection.z_dir, False) self.handle_list.append(handle_winz) return void
def add_door(self, build_ele, com_prop_stroke, wall_length, wall_width, wall_thickness): d_x = build_ele.door_x.value d_y = 0 d_z = 0 door_length = build_ele.door_length.value door_width = build_ele.door_width.value door_thickness = wall_thickness door = AllplanGeo.Polyhedron3D.CreateCuboid(door_length, door_thickness, door_width) trans_to_ref_point_3 = AllplanGeo.Matrix3D() trans_to_ref_point_3.Translate(AllplanGeo.Vector3D(d_x, d_y, d_z)) door = AllplanGeo.Transform(door, trans_to_ref_point_3) self.model_ele_list.append( AllplanBasisElements.ModelElement3D(com_prop_stroke, door)) #--------------------------------------------------------------------------------------# #----------------------------------Door Handle-----------------------------------------# #--------------------------------------------------------------------------------------# origin = AllplanGeo.Point3D(0, 0, 0) door_plength = AllplanGeo.Point3D(d_x + door_length, 0, 0) door_pwidth = AllplanGeo.Point3D(d_x, 0, door_width) door_pointx = AllplanGeo.Point3D(d_x, 0, 0) handle_doorlength = HandleProperties( "DoorMoveLength", door_plength, door_pointx, [("door_length", HandleDirection.x_dir)], HandleDirection.x_dir, True) self.handle_list.append(handle_doorlength) handle_doorwidth = HandleProperties( "DoorMoveWidth", door_pwidth, door_pointx, [("door_width", HandleDirection.z_dir)], HandleDirection.z_dir, True) self.handle_list.append(handle_doorwidth) handle_doorx = HandleProperties("doorMoveX", door_pointx, origin, [("door_x", HandleDirection.x_dir)], HandleDirection.x_dir, False) self.handle_list.append(handle_doorx) return door
def create_geometry(self, build_ele): """ Create the element geometries Args: build_ele: the building element. """ #----------------- Extract palette parameter values wall_length = build_ele.Length1_1.value wall_width = build_ele.Width1_1.value wall_thickness = build_ele.Thickness1_1.value void_active = build_ele.chkb_win.value door_active = build_ele.chkb_door.value join1_type_added = build_ele.join1_type_active.value join1_type_select = build_ele.join1_type.value join2_type_added = build_ele.join2_type_active.value join2_type_select = build_ele.join2_type.value #------------------------------------ Create wall------------------------------------------# wall = AllplanGeo.Polyhedron3D.CreateCuboid(wall_length, wall_thickness, wall_width) trans_to_ref_point_1 = AllplanGeo.Matrix3D() trans_to_ref_point_1.Translate(AllplanGeo.Vector3D(0, 0, 0)) wall = AllplanGeo.Transform(wall, trans_to_ref_point_1) #----------------------------Create Component Property--------------------------------------# com_prop_base_bodies = AllplanBaseElements.CommonProperties() com_prop_base_bodies.GetGlobalProperties() com_prop_base_bodies.Color = 1 com_prop_stroke = AllplanBaseElements.CommonProperties() com_prop_stroke.GetGlobalProperties() com_prop_stroke.Stroke = 9 # dots com_prop_stroke.HelpConstruction = True self.model_ele_list.append( AllplanBasisElements.ModelElement3D(com_prop_stroke, wall)) #------------------ Append Element to Wall -------------------------------------------------# if (void_active): void = self.add_windows(build_ele, com_prop_stroke, wall_length, wall_width, wall_thickness) err, wall = AllplanGeo.MakeSubtraction(wall, void) if (door_active): door = self.add_door(build_ele, com_prop_stroke, wall_length, wall_width, wall_thickness) err, wall = AllplanGeo.MakeSubtraction(wall, door) if (join1_type_added): join1 = self.add_joins_left(build_ele, com_prop_stroke, type=join1_type_select) err, wall = AllplanGeo.MakeSubtraction(wall, join1) if (join2_type_added): join2 = self.add_joins_right(build_ele, com_prop_stroke, type=join2_type_select) err, wall = AllplanGeo.MakeSubtraction(wall, join2) #---------------------------------------Add Wall Element----------------------------------------# self.model_ele_list.append( AllplanBasisElements.ModelElement3D(com_prop_base_bodies, wall)) #-----------------------------------------------------------------------------------------------# #-----------------------------------------wall handle-------------------------------------------# #-----------------------------------------------------------------------------------------------# origin = AllplanGeo.Point3D(0, 0, 0) wall_plength = AllplanGeo.Point3D(wall_length, 0, 0) wall_pwidth = AllplanGeo.Point3D(0, 0, wall_width) wall_pthickness = AllplanGeo.Point3D(0, wall_thickness, 0) handle_walllength = HandleProperties( "WallMoveLength", wall_plength, origin, [("Length1_1", HandleDirection.x_dir)], HandleDirection.x_dir, True) self.handle_list.append(handle_walllength) handle_wallwidth = HandleProperties( "WallMoveWidth", wall_pwidth, origin, [("Width1_1", HandleDirection.z_dir)], HandleDirection.z_dir, True) self.handle_list.append(handle_wallwidth) handle_wallthickness = HandleProperties( "WallMoveThickness", wall_pthickness, origin, [("Thickness1_1", HandleDirection.y_dir)], HandleDirection.y_dir, True) self.handle_list.append(handle_wallthickness)