def mirror_materials(selected_mtrl): mem = model.member(selected_mtrl[0]._as_tuple[0]) locator = Locator.Locator3D() locator.SetDefaults() orig_point, pt_on_plane, plane_normal, ok = mirror_plane(locator) if ok: try: to_mem = member.MemberLocate( 'Locate member to copy material to or Return to keep on current member: ' ) to_mem.number # to throw an error if user right clicks and selects 'ok' with no selection param.ClearSelection() except: to_mem = mem # if not member is seleced, the material will stay on the original member. if ok: mirror_mtrl = model.MirrorMaterialCopyToMember( selected_mtrl[0], model.member(to_mem.number), pt_on_plane, plane_normal) mirror_offset = ( orig_point - pt_on_plane ) * 2 # gets the offset that MirrorMaterialCopyToMember gives by default mirror_point = orig_point - mirror_offset # gets the corresponding point of the mirrored material mirror_mtrl_idx = mirror_mtrl._as_tuple[2] mirror_xform = Transform3D.Transform3D(to_mem.number, mirror_mtrl_idx) ref_offset = mirror_xform.t - mirror_point # negates any offset from MirrorMaterialCopyToMember such that the second point # will correspond to the original point releative to the mirrored material. if move_mtrl(to_mem, mirror_mtrl, orig_point, locator, ref_offset, mirror_xform): param.RedrawScreen()
def kf_group_interfaces_report_join(group_id): if not request.is_json: raise Exceptions.InvalidToken() data = request.json token = G.auto_verify(request) user_uuid = model.getuser_uuid(token.get("user")).uuid if not model.group.select().where(model.group.uuid == group_id): raise Exceptions.InvalidToken() group = G.get_group(group_id) if group.joinway not in ["public_join", "public_join_review"]: raise Exceptions.InvalidToken() if model.member.select().where( (model.member.is_disabled == False) & (model.member.user == user_uuid) & (model.member.group == group.id) ): raise Exceptions.InvalidToken() if group.joinway == "public_join": new = model.member(user=user_uuid, group=group_id, permission="common_user") new.save() return Response(json.dumps(model.kf_format_group_public(group)), mimetype='application/json; charset=utf-8') if group.joinway == "public_join_review": review = model.review(user=user_uuid, group=group.id) review.save() return Response(json.dumps({ "reviewId": review.id }), mimetype='application/json; charset=utf-8') if group.joinway == 'private': raise Exceptions.InvalidToken()
def kf_group_interfaces_create(): if request.is_json: data = request.json name = data.get("name") joinway = data.get("joinway", "public_join") if joinway not in ["public_join", "public_join_review", "private"]: raise Exceptions.InvalidToken() if not re.match(r"[a-zA-Z0-9\u4E00-\u9FA5_-]{4,16}$", name): raise Exceptions.InvalidToken() if model.group.select().where(model.group.name == name): raise Exceptions.InvalidToken() accessToken = data.get("accessToken") clientToken = data.get("clientToken") if not accessToken: raise Exceptions.InvalidToken() if Token.is_validate_strict(accessToken, clientToken): raise Exceptions.InvalidToken() token = Token.gettoken_strict(accessToken, clientToken) user_uuid = model.getuser_uuid(token.get("user")).uuid new_group = model.group(name=name, creater=user_uuid, manager=user_uuid, create_date=datetime.datetime.now(), joinway=joinway) new_group.save() new_manager = model.member( user=user_uuid, group=new_group.id, permission="super_manager") return Response(json.dumps({ "groupId": new_group.uuid, "timestamp": new_group.create_date.timestamp() }), mimetype='application/json; charset=utf-8')
def Point1(self): var = ( self.GetReferencePoint() + -self.HostXform.GetBasisVectorY() * 12. + self.HostXform.GetBasisVectorX() * 12. ) return var + P3D(model.member(self.member_number).ends[0].location)
def kf_group_interfaces_manage_checkjoin_access(group_id, review_id): data = G.autodata(request) token = G.auto_verify(request) user = model.getuser_uuid(token.get("user")) user_uuid = user.uuid group = G.get_group(group_id) manager = G.isManager(group_id, user_uuid) selectResult = model.review.select().where( (model.review.id == review_id) & (model.review.group == group_id) ) if not selectResult: raise Exceptions.InvalidToken() selectResult = selectResult.get() if selectResult.isEnable != True: raise Exceptions.InvalidRequestData() selectResult.isEnable = False selectResult.isAccessed = True if not model.member.select().where( (model.member.is_disabled == True) & (model.member.group == group_id) & (model.member.user == user_uuid) ): newmember = model.member( user=selectResult.user, group=selectResult.group, permission="common_user" ) newmember.save() else: joined_member = model.member.select().where( (model.member.is_disabled == True) & (model.member.group == group_id) & (model.member.user == user_uuid) ).get() joined_member.join_times += 1 joined_member.is_disabled = False for i in model.member.select().where( (model.member.group == selectResult.group) & ((model.member.permission == "manager") | (model.member.permission == "super_manager")) & (model.member.is_disabled == True) & (model.member.user != manager.uuid) ): model.message( to=i.user, title="用户 %(user)s 面向组 %(group)s 的加组申请被通过" % ( [user.uuid, user.username][bool(user.username)], group.name), body="用户 %(user)s 面向组 %(group)s 的加组申请被组管理员 %(manager)s 通过" % ([user.uuid, user.username][bool( user.username)], group.name, [manager.uuid, manager.username][bool(manager.username)]), extra=json.dumps({ "user": user_uuid, "group": group.id, "manager": manager.uuid }) ) return Response(status=204)
def IsAllowedOnMember(self, mn): return model.member(mn).member_type == model.Beam
def HostFlangeThick(self): return Shape( model.member(self.member_number).section_size ).FlangeThickness
def HostDepth(self): return Shape(model.member(self.member_number).section_size).Depth