Icon representing a recipe

Recipe: nicm25.htb.SoftAnchors v1.02

created by Nicm25

Profile


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

soft fixing as BiS! (segment select, number strength)

Best for


Code


-- created by Nicm25; function pldc() local retd=dialog.CreateDialog("SoftAnchors Ver 1.02") retd.si=dialog.AddSlider("band strength",1.0,0.5,1.5,2) retd.bt=dialog.AddButton("OK",1) return retd end function plfa(avx,avy) local retv=band.Add(avx,avx+avy,avx+avy*2,0.001,0.0,0.0,2,2,2) return retv end function plfb() local lc=0 local lfd=dialog.SelectSegments() selection.DeselectAll() for lc=1,#lfd do selection.Select(lfd[lc]) 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) local segs=1 local sege=0 local stci=0 local lc=0 if avx<-0.001 or avx>10.001 then return 1 end sege=#avs if selection.GetCount()<0.5 then plfb() end if selection.GetCount()<0.5 then return 1 end undo.SetUndo(false) for lc=segs,sege do if selection.IsSelected(lc) then stci=plfa(lc,lc>sege-2 and -1 or 1) band.SetStrength(stci,avx) end end undo.SetUndo(true) if stci>0.5 then band.SetStrength(stci,avx) end return 0 end local lfi=0 local tdr=pldc() lfi=dialog.Show(tdr) if lfi>0.5 then lfi=run(plss(),tdr.si.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, bands attaching to selected segment as the Zero Length Bands in Space.
2 arguments
select: currently selected segment will be this argument, if none select is error.
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.