Icon representing a recipe

Recipe: nicm25.htb.EdgeBinder v1.02

created by Nicm25

Profile


Name
nicm25.htb.EdgeBinder v1.02
ID
104865
Shared with
Public
Parent
None
Children
None
Created on
June 30, 2021 at 12:01 PM UTC
Updated on
June 30, 2021 at 12:01 PM UTC
Description

attaching band to cut edge! (nullable segment select, number threshold, number length, number strength)

Best for


Code


-- created by Nicm25; function pldc() local retd=dialog.CreateDialog("EdgeBinder Ver 1.02") retd.la=dialog.AddLabel(" none... ...many") retd.sn=dialog.AddSlider("threshold",1.0,0.0,1.0,2) retd.si=dialog.AddSlider("band length",0.0,0.0,1.0,2) retd.ss=dialog.AddSlider("band strength",1.0,0.5,1.5,2) retd.bt=dialog.AddButton("OK",1) return retd end function plfa(avx,avy,avz,ava,avb) local lc=1 local lfx=0 local lfy=0.0 local lfd=structure.GetCuts() undo.SetUndo(false) for lc=1,#lfd do if #lfd<lc+0.5 then undo.SetUndo(true) end if lfd[lc]>ava-0.5 and lfd[lc]<avb-0.5 then lfy=structure.GetDistance(lfd[lc],lfd[lc]+1) if lfy>avx then lfx=band.AddBetweenSegments(lfd[lc],lfd[lc]+1,3,1,0) band.SetGoalLength(lfx,lfy*avy) if avz<0.995 or avz>1.005 then band.SetStrength(lfx,avz) end end end end end function plss() local lc=1 local retd={} for lc=1,structure.GetCount() do retd[lc]=selection.IsSelected(lc) and 1 or 0 end return retd end function run(avs,avx,avy,avz) local segs=0 local sege=0 local lc=0 local lfx=0.0 if avx<-0.001 or avx>1.001 or avy<-0.001 or avy>1.001 or avz<-0.001 or avz>10.001 then return 1 end lfx=avx>0.999 and 0.0 or 21.66/(avx+0.1)-16.6 sege=#avs if selection.GetCount()>1.5 then for lc=1,sege do if avs[lc]>0.5 then if segs<0.5 then segs=lc else sege=lc end end end else segs=1 for lc=1,sege do if structure.IsLocked(lc) then segs=lc+1 end end end if segs>sege-1 then print("not supported partial puzzle") return 1 else plfa(lfx,avy,avz,segs,sege) end return 0 end local lfi=0 local tdr=pldc() lfi=dialog.Show(tdr) if lfi>0.5 then lfi=run(plss(),tdr.sn.value,tdr.si.value,tdr.ss.value) if lfi>0.5 then print("terminated by exception error") end end

Comments


Nicm25 Lv 1

thank you for your interest.
this is by product of bootstrap, where i prepare tools myself from beginning
and my personal 'Hand Tools, Bands such package'(htb).

In this little script, look for end of cut proteins and attaches bands.
4 arguments
select: currently selected segment will be this argument(not in dialog), if none select is 'all apply'.
threshold: based on distance, you can adjust to ignore edges that are close enough.
range: 0.0-1.0, default: 1.0, function: 1.0 is all valid, 0.0 is almost ignore
length: set band length, multiply by current distance and pulling.
range: 0.0-1.0, default: 0.0, function: 1.0 is current distance, 0.0 is zero distance
strength: set band strength, same as band strength
range: 0.5-1.5 (ext0.0-10.0), default: 1.0, function: 1.0 is standard, 0.5 is weak, 1.5 is intense
int return: whether it was successfully. function: 0 is okay, else is problem

Nicm25 Lv 1

improved to undo history into one task.
other that, there are no changes to specifications.