--- //////////////////////////////////////////////////// --- --- © SlayerK 2007/02/22 --- Script for change parameters of multiple tools --- beta version 0.7 --- --- WARNING: Save you comps to be on a safe place --- --- for bugs and reports: slayerk@mail.ru --- --- //////////////////////////////////////////////////// function isin(elem) for i, j in allToolsNames do if elem==j then return true end end return false end function clearModifiers(tbl) local tmp={} for i=1, table.getn(tbl) do if isin(tbl[i]:GetAttrs().TOOLS_RegID) then table.insert(tmp, tbl[i]) end end return tmp; end function getMin(tbl) if table.getn(tbl)==0 then return(-1) end local minTl=0 local minInps=1000000 numInps=0 for i=1, table.getn(tbl) do numInps=table.getn(tbl[i]:GetInputList()) if numInps0) do nowMin=1 if isSeen(tools[nowMin]:GetAttrs().TOOLS_RegID)==false then table.insert(seen, tools[nowMin]:GetAttrs().TOOLS_RegID) iInfo=getInpsNames(tools[nowMin]) sheets=mulInps(sheets, iInfo) end table.remove(tools, nowMin) end --~ print("ok") if table.getn(sheets)==0 then print("No sheet Inputs") return 0 end table.sort(sheets, function (a,b) return (b.nm > a.nm) end) tools=comp:GetToolList(true) tools=clearModifiers(tools) -- IUP --/////////////////////////////////////////////// message="Here palced values\nof FuID to copy\nin TextField" nowAc=1 selTp=sheets[1].tp nowTp=sheets[1].tp xVal="" yVal="" tVal="" fVal="" active ="255 255 255" passive ="64 64 64" textCol ="0 0 0" getList(sheets, "lst") infoFuID=iup.multiline{size="10x10", expand="YES", fgcolor=active, bgcolor=passive, value=message} listFuID=iup.list{expand="YES";fgcolor=active} --iup.list{"Item 1 Text","Item 2 Text","Item 3 Text"; expand="YES",value="1"} cordX=iup.text{size="50x"} cordY=iup.text{size="50x"} cordS=iup.hbox{iup.label{title="X:"}, cordX, iup.label{title="Y:"}, cordY} inputType=iup.label{title=sheets[nowAc].tp} textFld=iup.text{size="200x"} textInp=iup.hbox{inputType, textFld} btn_set=iup.button{title="Apply", size="100x20"} setList=iup.vbox{textInp, cordS, btn_set; gap=10, alignment="ACENTER"} iup.SetAttribute(cordX, "FGCOLOR", textCol) iup.SetAttribute(cordY, "FGCOLOR", textCol) iup.SetAttribute(textFld, "FGCOLOR", textCol) currentVal=getParameter(sheets[1].id) if nowTp~="Point" then tVal=currentVal iup.SetAttribute(textFld, "VALUE", currentVal) iup.SetAttribute(cordS, "ACTIVE", "NO") iup.SetAttribute(textFld, "BGCOLOR", active) iup.SetAttribute(cordX, "BGCOLOR", passive) iup.SetAttribute(cordY, "BGCOLOR", passive) else iup.SetAttribute(cordX, "VALUE", tostring(currentVal[1])) iup.SetAttribute(cordY, "VALUE", tostring(currentVal[2])) xVal=currentVal[1] yVal=currentVal[2] iup.SetAttribute(textFld, "ACTIVE", "NO") iup.SetAttribute(textFld, "BGCOLOR", passive) iup.SetAttribute(cordX, "BGCOLOR", active) iup.SetAttribute(cordY, "BGCOLOR", active) end -- Event functions --///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function clearFuIDlist() for i=1, 10 do listFuID[i]=nil end end function listFuID:action(tVar, i, v) if selTp=="FuID" then iup.SetAttribute(textFld, "VALUE", tVar) tVal=tVar end end function lst:action(t, i, v) nowAc=i selTp=sheets[i].tp iup.SetAttribute(inputType, "TITLE", sheets[i].tp) currentVal=getParameter(sheets[i].id) clearFuIDlist() if (sheets[i].tp=="Point") then if currentVal=="?" then currentVal={"?", "?"} else xVal=currentVal[1] yVal=currentVal[2] end iup.SetAttribute(cordX, "VALUE", tostring(currentVal[1])) iup.SetAttribute(cordY, "VALUE", tostring(currentVal[2])) else tVal=currentVal iup.SetAttribute(textFld, "VALUE", currentVal) end if (sheets[i].tp=="FuID") then dostring("fuIDAttrs=" .. tools[1]:GetAttrs().TOOLS_Name .. "." .. sheets[i].id .. ":GetAttrs()") inpCtrlType=string.gsub(fuIDAttrs.INPID_InputControl, "ID", "") dostring("idMat=" .. tools[1]:GetAttrs().TOOLS_Name .. "." .. sheets[i].id .. ":GetAttrs().INPIDT_" .. inpCtrlType .. "_ID") -- iup.SetAttribute(infoFuID, "VALUE", tblToString(idMat, "\n", "")) clearFuIDlist() for i, j in idMat do listFuID[i]=tostring(j) end else iup.SetAttribute(infoFuID, "VALUE", message) end if isChange(nowTp, sheets[i].tp) then if nowTp~="Point" then iup.SetAttribute(textFld, "ACTIVE", "NO") iup.SetAttribute(textFld, "BGCOLOR", passive) iup.SetAttribute(cordS, "ACTIVE", "YES") iup.SetAttribute(cordX, "BGCOLOR", active) iup.SetAttribute(cordY, "BGCOLOR", active) else iup.SetAttribute(cordS, "ACTIVE", "NO") iup.SetAttribute(cordX, "BGCOLOR", passive) iup.SetAttribute(cordY, "BGCOLOR", passive) iup.SetAttribute(textFld, "ACTIVE", "YES") iup.SetAttribute(textFld, "BGCOLOR", active) end nowTp=sheets[i].tp iup.Refresh(setList) end end function btn_set:action() local do_s="" local operation="" local incX="" local incY="" local _tVal=tVal local _xVal=xVal local _yVal=yVal local newVal=0 local chX=1 local chY=1 for i=1, table.getn(tools) do tlName=tools[i]:GetAttrs().TOOLS_Name if sheets[nowAc].tp=="Number" then if eyeon.isin( {"+","-","/","*"}, string.sub(_tVal,1,1)) then operation=string.sub(_tVal, 1, 1) _tVal=string.sub(_tVal, 2, string.len(tVal)) end if tonumber(_tVal)==nil then print("Entered data isn't Number") return end if operation=="" then do_s=tlName .. "." .. sheets[nowAc].id .. "[" .. comp:GetAttrs().COMPN_CurrentTime .. "]=" .. _tVal else do_s=tlName .. "." .. sheets[nowAc].id .. "[" .. comp:GetAttrs().COMPN_CurrentTime.. "]=" .. tlName .. "." .. sheets[nowAc].id .. "[" .. comp:GetAttrs().COMPN_CurrentTime .. "]" .. operation .. _tVal end dostring(do_s) end if sheets[nowAc].tp=="Point" then if eyeon.isin( {"+","-","/","*"}, string.sub(xVal,1,1)) then incX=string.sub(xVal, 1, 1) _xVal=string.sub(xVal, 2, string.len(xVal)) end if eyeon.isin( {"+","-","/","*"}, string.sub(yVal,1,1)) then incY=string.sub(yVal, 1, 1) _yVal=string.sub(yVal, 2, string.len(yVal)) end dostring("tmpVar = " .. tlName .. "." .. sheets[nowAc].id .. "[" .. comp:GetAttrs().COMPN_CurrentTime .. "]") if (tonumber(_xVal)==nil) then chX=0 end if (tonumber(_yVal)==nil) then chY=0 end -- INCREMENT FOR ELEMENTS ------------------------------------------------------------------------------------------- newVal=0 if chX==1 then if incX~="" then if incX=="+" then newVal=tmpVar[1]+tonumber(_xVal) end if incX=="-" then newVal=tmpVar[1]-tonumber(_xVal) end if incX=="*" then newVal=tmpVar[1]*tonumber(_xVal) end if incX=="/" then newVal=tmpVar[1]/tonumber(_xVal) end _xVal=newVal end do_s = tlName .. "." .. sheets[nowAc].id .. "[" .. comp:GetAttrs().COMPN_CurrentTime.. "]={" .. _xVal .. ", " .. tmpVar[2] .. "}" dostring(do_s) else _xVal=tmpVar[1] end if chY==1 then if incY~="" then if incY=="+" then newVal=tmpVar[2]+tonumber(_yVal) end if incY=="-" then newVal=tmpVar[2]-tonumber(_yVal) end if incY=="*" then newVal=tmpVar[2]*tonumber(_yVal) end if incY=="/" then newVal=tmpVar[2]/tonumber(_yVal) end _yVal=newVal end do_s = tlName .. "." .. sheets[nowAc].id .. "[" .. comp:GetAttrs().COMPN_CurrentTime.. "]={" .. _xVal .. ", " .. _yVal .. "}" dostring(do_s) end ------------------------------------------------------------------------------------------- end if (sheets[nowAc].tp=="Text") or (sheets[nowAc].tp=="FuID")then if tVal~="?" then do_s=tlName .. "." .. sheets[nowAc].id .. "[" .. comp:GetAttrs().COMPN_CurrentTime .. ']="' .. tVal .. '"' dostring(do_s) end end end end function cordX:action(c, after) xVal=after end function cordY:action(c, after) yVal=after end function textFld:action(c, after) tVal=after end --///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// dlg=iup.dialog{ iup.hbox{ iup.vbox{ iup.hbox{ iup.frame{ iup.hbox{ lst; gap=5 }; title="Choose Parameter", size="300x50", fgcolor=active } }, iup.hbox{ iup.frame{ setList; title="Set To:", size="300x110", fgcolor=active } }, }, iup.vbox{ iup.frame{ iup.vbox{ listFuID; gap=5 }; size="100x150" } } }; margin="10x10", title="© 2007 SlayerK Multiple Parameter Changer", resize="no", bgcolor="64 64 64" } dlg:show() iup.MainLoop()