Edit Bezier Curve

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Edit Bezier Curve

Post by hayasidist »

There was a request for a script that would allow you to grab a curve and drag it about, automatically updating the bezier handles... http://www.lostmarble.com/forum/viewtop ... =5&t=33883


here's an INITIAL version -- use with care .. it has been tested in a benign environment, but I'm fairly sure that active use will find a way to break it...

https://www.mediafire.com/file/vhxz93hn ... r.zip/file

It will run on 12.0 and later -- it is compatible with 13.5 .. only a few hours to go for that now! ;-)


What it does:

- click on a curve segment, then drag the mouse -- the segment arc will follow the mouse and the bezier handles will get updated automatically.

- the segment has six zones:
--- too close to a moho mesh point (and the tool will silently refuse to do anything)
--- in the next 1/6th of the segment - when only the nearest bezier handle will be affected
--- from there to the middle where both handles are (proportionally) affected

and the same three zones on the way to the other end point of the segment...

IOW: too close to a moho point: no action
close to a moho point -- just the one Bezier handle moves
elsewhere -- both handles move

===

I've noticed a couple of "not quite as tidy as I'd have liked" behaviours: sometimes the mouse / pointer will not stay "stuck" to the curve -- the segment still moves in response, but there's a visual gap often when the resulting Bezier handle becomes "very long" ... if this becomes a significant problem let me know please..

Unlike Krita, it does not show the handles moving; and does not give a visual indication that a segment is selected - and I'm planning on leaving it that way unless there's a clamour for such..

As ever - let me know how it works for you / bugs etc / requests for enhancements..
rocken
Posts: 28
Joined: Wed Mar 21, 2018 1:30 am

Re: Edit Bezier Curve

Post by rocken »

I am so honoured and happy you made this script.
wowwww.
this is sooooooo useful.
Thanks a million
testing it out now
hayasidist wrote: Mon Apr 26, 2021 12:08 pm There was a request for a script that would allow you to grab a curve and drag it about, automatically updating the bezier handles... http://www.lostmarble.com/forum/viewtop ... =5&t=33883


here's an INITIAL version -- use with care .. it has been tested in a benign environment, but I'm fairly sure that active use will find a way to break it...

https://www.mediafire.com/file/vhxz93hn ... r.zip/file

It will run on 12.0 and later -- it is compatible with 13.5 .. only a few hours to go for that now! ;-)


What it does:

- click on a curve segment, then drag the mouse -- the segment arc will follow the mouse and the bezier handles will get updated automatically.

- the segment has six zones:
--- too close to a moho mesh point (and the tool will silently refuse to do anything)
--- in the next 1/6th of the segment - when only the nearest bezier handle will be affected
--- from there to the middle where both handles are (proportionally) affected

and the same three zones on the way to the other end point of the segment...

IOW: too close to a moho point: no action
close to a moho point -- just the one Bezier handle moves
elsewhere -- both handles move

===

I've noticed a couple of "not quite as tidy as I'd have liked" behaviours: sometimes the mouse / pointer will not stay "stuck" to the curve -- the segment still moves in response, but there's a visual gap often when the resulting Bezier handle becomes "very long" ... if this becomes a significant problem let me know please..

Unlike Krita, it does not show the handles moving; and does not give a visual indication that a segment is selected - and I'm planning on leaving it that way unless there's a clamour for such..

As ever - let me know how it works for you / bugs etc / requests for enhancements..
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: Edit Bezier Curve

Post by SimplSam »

Good stuff. I had a quick play. It mostly works, but kinda does not feel quite right. I will need to play more...
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
alanthebox
Posts: 214
Joined: Sat Feb 03, 2018 5:31 pm
Contact:

Re: Edit Bezier Curve

Post by alanthebox »

I didn't realize how much I missed this functionality until now! Thanks for putting this together!
User avatar
Lukas
Posts: 1297
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Edit Bezier Curve

Post by Lukas »

Nice 😎
I've bumped into some weird behaviour, but for quickly bending a straight line to a curve this is really userful!
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Edit Bezier Curve

Post by hayasidist »

Lukas wrote: Tue Apr 27, 2021 7:57 am Nice 😎
I've bumped into some weird behaviour, but for quickly bending a straight line to a curve this is really userful!
if you can somehow post / describe the weirds I'll take a look --- one thing I found was that the "just this handle" zone can both cause and remedy odd "peaky" behaviours in the segment...
rocken
Posts: 28
Joined: Wed Mar 21, 2018 1:30 am

Re: Edit Bezier Curve

Post by rocken »

Experimented with the Script on MH 13.5 (Demo Version)
I don't know if this is caused by the script but after making using of it to reshape the curves, I deleted the shape entirely and when I drew another shape (tested with a circle and a rectangle) with the DRAW SHAPE. the BEZIER handles begin to act weirdly.: not responding when i click on them also the bezier handles support on the TRANSFORM POINTS panel disappears entirely.. However, on returning to the reshape curve script, i can still bend curves with ease. You can see in this gif I uploaded.Image
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Edit Bezier Curve

Post by hayasidist »

Demo Version?! In the (factory) Transform points tool, the bezier handles icons are only displayed in the Pro version... I wonder if demo means no pro features??

from a cold start, do you see the Bezier handle icons?
rocken
Posts: 28
Joined: Wed Mar 21, 2018 1:30 am

Re: Edit Bezier Curve

Post by rocken »

Yes...I see the Bezier Handles from a cold start...
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Edit Bezier Curve

Post by hayasidist »

hmm -- I can't yet reproduce that here -- possibly dumb q: you are using the LM version of Transform Points? -- the only way those icons don't appear is if IsMohoPro() is "false". And LM's Shape?

could you install this simple script -- I ran it from Custom Content / Scripts / Menu / script writing, but anywhere sensible will do.

run before and after the weird behaviours please. I'm half expecting it to say both times that it's 13.5 Pro and "show handles" but ...

Code: Select all

ScriptName = "HS_ReportMoho"
HS_ReportMoho = {}
local thisUUT = "D"

function HS_ReportMoho:Test()
	return true
--	return false
end

function HS_ReportMoho:Name()
	return "Report Moho"
end

function HS_ReportMoho:Version()
	return "version 1.02"
end

function HS_ReportMoho:IsBeginnerScript()
	return false
end

function HS_ReportMoho:Description()
	return "Report basic info about Moho"
end

function HS_ReportMoho:Creator()
	return "Hayasidist"
end

function HS_ReportMoho:UILabel()
	return "Report Moho " .. HS_ReportMoho:Version()
end


function HS_ReportMoho:ColorizeIcon()
	return true
end
function HS_ReportMoho:Run(moho, view)
--	HS_Test_harness:diagnosePrint (thisUUT,  self:Name(), self:Version())

	local i, j, k, n, p, q, s

	local err
	print (self:Name() .. " " .. self:Version())
	if type (MOHO.ScriptInterface.AppVersion) == "function" then

		if MOHO.IsMohoPro() then
			s = "Moho Pro"
		else
			s = "Debut"
		end

		if moho:IsPro() ~= MOHO.IsMohoPro() then
			s = "Unclear if " .. s
		end


		q = "show bezier handles"
		if not LM_TransformPoints.showHandles then
			q = "do not " .. q
		end
		print (s .. " version " .. moho:AppVersion() .. ". Transform Points - " .. q)

		print (LM_TransformPoints:Name() .. " version " .. LM_TransformPoints:Version() .. " by " .. LM_TransformPoints:Creator())
		print (LM_Shape:Name() .. " version " .. LM_Shape:Version() .. " by " .. LM_Shape:Creator())

	else
		print ("unsupported version")
	end


end

[EDIT]: code updated to reflect the mediafire version...
Last edited by hayasidist on Sun May 02, 2021 7:00 pm, edited 2 times in total.
rocken
Posts: 28
Joined: Wed Mar 21, 2018 1:30 am

Re: Edit Bezier Curve

Post by rocken »

Do i copy this into a notepad text ?I am a complete noob to scripting
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Edit Bezier Curve

Post by hayasidist »

ah - ok ... sorry - trying to be efficient and skipping an upload - yes - any text editor will do -- and save it as HS_ReportMoho.lua (make sure you get the extension right - Notepad tries hard to make you call it .txt - even after you call it .lua)

If you're struggling, or just plain put off by the idea I'll upload a version to mediafire.

[EDIT] -- here's a link to a slightly newer version - with a couple of extra "this info might just help" fields... https://www.mediafire.com/file/edtivppq ... o.lua/file
User avatar
lucasfranca
Posts: 128
Joined: Sat Oct 07, 2017 11:47 pm

Re: Edit Bezier Curve

Post by lucasfranca »

Too bad it doesn't work on a non-zero frame!
An old guy [since 1983] who was raised in front of the TV.
Passionate about animation, after getting old, he decides to make it his hobby.

I share tutorials, reviews, tips and tricks from this vast world of animation on my channel.

https://youtube.com/animai2D
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Edit Bezier Curve

Post by hayasidist »

lucasfranca wrote: Sun Apr 24, 2022 4:10 pm Too bad it doesn't work on a non-zero frame!
works fine in the timeline here ... win10 Moho 13.5.x

if you have an example file that you can share, I'll take a look
User avatar
lucasfranca
Posts: 128
Joined: Sat Oct 07, 2017 11:47 pm

Re: Edit Bezier Curve

Post by lucasfranca »

hayasidist wrote: Sun Apr 24, 2022 5:08 pm
lucasfranca wrote: Sun Apr 24, 2022 4:10 pm Too bad it doesn't work on a non-zero frame!
works fine in the timeline here ... win10 Moho 13.5.x

if you have an example file that you can share, I'll take a look
The tool does not appear in a non-zero frame. Do I have an old version of it? My version is 1.8.
An old guy [since 1983] who was raised in front of the TV.
Passionate about animation, after getting old, he decides to make it his hobby.

I share tutorials, reviews, tips and tricks from this vast world of animation on my channel.

https://youtube.com/animai2D
Post Reply