def invisible_list_panhole(allp, get_all_child_by_attr): if not allp is None: for panel in allp: # Ищем полотно панели k3.selbyattr('FurnType=="010000"', k3.k_child, panel) # Если нашли if k3.sysvar(61) > 0: polotno = k3.getselnum(1) n = k3.getholes(polotno) arr = k3.VarArray(int(n * 15), 'arr') n = k3.getholes(polotno, 'arr') # Список всех отверстий панели lholes = [a.value for a in arr] # Список всех деталей крепежа, которым принадлежат отверстия lfix = [lholes[i] for i in range(2, len(lholes), 15)] # Реальные дети панели # Крепеж child_pan_fix = [] for e in lfix: if (k3.findobjholdg(panel, e)) > 0: child_pan_fix.append(e) if len(child_pan_fix) > 0: l_hole_rem = [] for e in child_pan_fix: # список отверстий крепежа c_hole_rem = get_all_child_by_attr(e, attrname='HoleType') for h in c_hole_rem: if not h in lfix: l_hole_rem.append(h) for e in l_hole_rem: if k3.penetrate(e, polotno) == 2: k3.invisible(k3.k_partly, e)
def allnoteed(): """""" try: nl = k3.fltrtype('Note') k3.select(k3.k_partly, k3.k_all, k3.k_done) n = k3.sysvar(61) note = Note() lsobj = [] info = k3.VarArray(54) if n > 0: for i in range(int(n)): lsobj.append(k3.getselnum(i + 1)) for i in lsobj: note.holder = i note.getinfo() #lr = sf(note) #note.info[19] = '(' + str(lr) + ') ' + str(note.info[12]) #for j in range(len(note.info)): #info[j].value = note.info[j] #k3.putnoteinfo(note.holder, info) gi = 0 while revisor(note) and gi < 3: note.info[12] = abs(note.info[12] - 1.0) for j in range(len(note.info)): info[j].value = note.info[j] k3.putnoteinfo(note.holder, info) note.getinfo() gi += 1 except: nl = k3.fltrtype(0) finally: nl = k3.fltrtype(0)
def get_allPanel(): #pnt = k3.Var() try: allp = GetListAllPanel() return allp except: try: # включаем фильтр по панелям k3.fltrparamobj(1, 61) # выбираем панель (для демонстрации) и помещаем в pnt #k3.objident(k3.k_interact, pnt) #panel = pnt.value k3.select(k3.k_partly, k3.k_all) allp = [] n = k3.sysvar(61) # выключаем фильтр k3.fltrparamobj(0) if n > 0: for i in range(int(n)): allp.append(k3.getselnum(i + 1)) return allp except Exception as inst: print(type(inst)) # the exception instance print(inst.args) # arguments stored in .args print(inst) fltrparamobj(0) # сбрасываем фильтр return None
def get_basis_lsc(p): """Возвращает результат проверки левого базиса панели""" try: cp = k3.getattr(p, 'commonpos', 0) k3.getsnap() k3.setucs(k3.k_lcs, k3.k_partly, p) k3.initarray(ARRGAB, 0) k3.selbyattr('FurnType==\"010000\"', k3.k_child, p) ps = k3.getselnum(1) k3.objgab3(ps, ARRGAB) h_difference = lambda v1, v2: (max(v1, v2) - min(v1, v2)) / 2.0 + min( v1, v2) log_minus = lambda v: v < 0 agab = [a.value for a in ARRGAB] lpcen = list(map(h_difference, agab[:3], agab[3:])) result = True in map(log_minus, lpcen) if result: k3.putmsg(str(cp) + ' Это номер с левой базой', 0) llbasis.append(p) k3.resnap() except: result = False k3.putmsg(str(cp) + ' Это номер скорее всего погашен.') return result
def getListObjVisual(): '''Возвращает список видимых объектов''' lObj = [] k3.select(k3.k_all, k3.k_done) n = int(k3.sysvar(61)) if n > 0: for i in range(1, n + 1): lObj.append(k3.getselnum(i)) return lObj
def start_ppi(): PANEL = PanelRectangle() k3.switch(k3.k_autosingle, k3.k_on) try: k3.selbyattr('FurnType=="010100"', k3.k_interact) k3.switch(k3.k_autosingle, k3.k_off) if k3.sysvar(61) > 0: el = k3.getselnum(1) start_time = time.time() pInfo = PANEL.getPanelPathInfo(el) end_time = time.time() - start_time print(str(datetime.timedelta(seconds=end_time))) except: k3.switch(k3.k_autosingle, k3.k_off)
def get_obj_scene(self, fun=None): """Заполняет список объектов сцены. Возврашает Истина если объекты есть и список составлен и Ложь если объектов сцены нет fun - функция возвращаеющая список нужных объектов """ n = 0 self.l_note=[] if fun is None: k3.select(k3.k_all) n = k3.sysvar(61) if n > 0: self.lstobj = [] for i in range(int(n)): self.lstobj.append(k3.getselnum(i + 1)) else: self.lstobj = [a for a in fun()] self.nnote = len(self.lstobj) n = len(self.lstobj) if n > 0: return True else: return False
nullout = k3.setvarinst(1, "IsUpil", 0) Panel.panelInit(pan) Panel.getPanelProperty(pan) Panel.getPanelPathInfo(pan) FrontF, NeedEskisA, NeedEskisF = isFront.isfront( Panel) # Является ли пласть F лицом if NeedEskisA: k3.setvarinst(1, "NeedEskisA", 1) if NeedEskisF: k3.setvarinst(1, "NeedEskisF", 1) k3.selbyattr('furntype==\"010000\"', k3.k_child, Panel.holder) p = k3.getselnum(1) nH = k3.getholes(p) if nH > 0: k3.VarArray(int(nH * 15), 'aHoles') nHH = k3.getholes(p, 'aHoles') aHoles = k3.VarArray(int(nHH), 'aHoles') nh = k3.Var() nh.value = int(nH) drs.drill_finder([aHoles, nh], Panel) result = (Panel.rectangle_forma, max(len(Panel.slots), len(Panel.pSlots)), 'holes' in Panel.__dict__.keys()) isEskis.value = 1 if result == (True, 0, False):
def getObj(): k3.selbyattr('dsview',k3.k_partly,k3.k_all,k3.k_done) if k3.sysvar(61)>0: obj=k3.getselnum(1) return True, obj return False, None
import k3 def getObj(): k3.selbyattr('dsview',k3.k_partly,k3.k_all,k3.k_done) if k3.sysvar(61)>0: obj=k3.getselnum(1) return True, obj return False, None Params = k3.getpar() vnumWmf = Params[0] #k3.Var('vnumWmf') k3.select(k3.k_all) lobj=[] for i in range(int(k3.sysvar(61))): lobj.append(k3.getselnum(i+1)) rs = getObj() if rs[0]: hold=k3.Var() err=k3.getobjhold(rs[1],hold) holdo = hold.value k3.line(0., 0., 0., 100., 0., 0., k3.k_done) ls = k3.Var() k3.objident(k3.k_last, 1, ls) k3.add(k3.k_partly, holdo, ls.value) k3.extract(k3.k_partly, holdo, rs[1]) k3.invisible(k3.k_wholly, lobj) k3.zoom(k3.k_oneview,k3.k_extents) k3.exp2d(k3.k_wmf, k3.k_yes, k3.k_optimized, k3.k_yes, k3.k_fit, k3.k_yes, k3.k_height, 9500, k3.k_width,9500, k3.k_inscribe, k3.k_yes, vnumWmf.value, k3.k_overwrite ) k3.visible(k3.k_wholly, lobj) rs = getObj()
sy = k3.sysvar(62) obj_k3 = k3.Var() k3.switch(k3.k_autosingle,k3.k_on) #k3.selbyattr('left(FurnType,2)==\"10\"&&Posit!=10',k3.k_prompt,str('Выберите изделие'),k3.k_interact) #3.selbyattr('Posit!=10',k3.k_prompt,str('Выберите изделие'),k3.k_interact) k3.selbyattr('IsAssign(\"FurnType\")',k3.k_prompt,str('Выберите изделие'),k3.k_stayblink,k3.k_interact,k3.k_done) sel = k3.sysvar(61) if sel==0: Arr = Ut.getListArrayAllObjectsScene(AttrFilter='IsAssign(\"FurnType\")') # k3.cancel listUP = [] listUN = [] for i in range(int(sel)): obj_k3.value = k3.getselnum(i+1) # UnitPosObj = k3.getattr(obj_k3,'UnitPos',0) listUP.append(int(k3.getattr(obj_k3,'UnitPos',0))) UnitName = k3.getattr(obj_k3,'UnitName','') # listUN.append(k3.getattr(obj_k3,'UnitPos',0)) if len(UnitName) == 0: UnitName = k3.getattr(obj_k3,'ElemName','') listUN.append(UnitName) # if sel>0.: # obj_k3.value = k3.getselnum(1) # # UnitPosObj = k3.getattr(obj_k3,'UnitPos',0) # # listUP.append(k3.getattr(obj_k3,'UnitPos',0)) # UnitName = k3.getattr(obj_k3,'UnitName','') # listUN.append(k3.getattr(obj_k3,'UnitPos','')) # if len(UnitName) == 0: # UnitName = k3.getattr(obj_k3,'ElemName','')