Notifications
Clear all

[Closed] Shape Scripted Plugin

Hello Everyone,
I am trying to make a custom scripted plugin which would be a line or editable spline.

What I want to do is :

  1. on 1st click, define first vertex of the spline.
  2. on second vertex, define second vertex of the spline.
  3. on third click, make two verts with the x and y values of the 1st and 2nd vertex respectively and adjust the height…

what I have tried is not working, instead, it creates a freehand spline…



plugin shape mySpline

name:"cust Spline"

classID:#(0x133067, 0x54375)

category:"Splines"

( 
local startPoint, endPoint, height
local sp = splineShape(); 

tool create

(


on mousePoint click do

case click of

(

1: ((addnewSpline sp); startPoint = nodeTM.translation = gridPoint; (addKnot sp 1 #corner #line startPoint); )

3: #stop

)

on mouseMove click do

case click of

(

2: (
	endPoint = gridPoint
	(addKnot sp 1 #corner #line endPoint)
	close sp 1
	updateShape sp
)



)

)

)

 

Please Help!!!

1 Reply

I got a error when running it, so I modified it a little bit.
I also did some changes to the clicking code.

Click and hold, drag to second point, then click again for 3’rd click.
this is where you then need to add your last step.

I do not know the exact solution, but I would guess you can use getknot function to get knot 1 and 2, then get position, then do what you need etc.


plugin shape mySpline 
name:"cust Spline"
classID:#(0x133067, 0x54375)
category:"Splines"
extends:SplineShape
( 
local startPoint, endPoint, height
local sp = splineShape(); 

	tool create
	(
		on mousePoint click do
		case click of
		(
			
		1: (
			print "first click"
			addnewSpline sp
			startPoint = nodeTM.translation = gridPoint
			addKnot sp 1 #corner #line startPoint

			)
		2: (
			print "second click"
				endPoint = gridPoint
				addKnot sp 1 #corner #line endPoint
				close sp 1
				updateShape sp
			)
		3: (
			print "third click"

			updateShape sp
			#stop
			)
		)
	)
)