Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- macroScript scale_all category:"For Home" tooltip:"Fuse_knotes" buttonText:"Fuse Knotes"
- (
- try( DestroyDialog ::Fuse_knotes )catch()
- rollout Fuse_knotes "Fuse Knotes" width:162 height:120
- (
- fn IsSpline obj = iskindof obj SplineShape OR iskindof obj Line
- spinner knotsthreshold "Knots Thresh: " fieldwidth:60 align:#center range:[0.001,1e7,1]
- pickbutton btn_spl_base "Select Base Spline" width:140 filter:IsSpline align:#center
- pickbutton btn_spl_add "Select Add Spline" width:140 filter:IsSpline align:#center
- button btn_start "Start" width:140 height:31 align:#center
- fn FuseSplineKnots splineA splineB thresh:0.01 =
- (
- if not (IsSpline splineA) then return false
- if not (IsSpline splineB) then return false
- local knotsPositions = #()
- local knotsCount = numknots splineA
- for sA = 1 to (numsplines splineA) do
- (
- for kA = 1 to (numknots splineA sA) do
- (
- append knotsPositions (getKnotPoint splineA sA kA)
- )
- )
- undo "Fuse Knots" on
- (
- for sB = 1 to (numsplines splineB) do
- (
- for kB = 1 to (numknots splineB sB) do
- (
- local knotPos = getKnotPoint splineB sB kB
- local bestDist = 1e30
- local bestKnot
- for kA = 1 to knotsCount do
- (
- local dist = distance knotsPositions[kA] knotPos
- if dist < thresh do
- (
- bestDist = dist
- bestKnot = kA
- )
- )
- if bestKnot != undefined then
- (
- setKnotPoint splineB sB kB knotsPositions[bestKnot]
- )
- )
- )
- updateShape splineB
- )
- )
- on btn_spl_base picked spl do
- (
- if spl != undefined do btn_spl_base.text = spl.name
- )
- on btn_spl_add picked spl do
- (
- if spl != undefined do btn_spl_add.text = spl.name
- )
- on btn_start pressed do
- (
- local splineA = btn_spl_base.object
- local splineB = btn_spl_add.object
- FuseSplineKnots splineA splineB thresh:knotsthreshold.value
- )
- )
- createDialog Fuse_knotes
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement