[Closed] Getting SPLINE ID based on KNOT selection
Heya,
dudes, I have trouble getting a SPLINE ID based on what KNOT I’ve selected.
This is sort of reversed from what you’d want to do usually using
getKnotSelection $Spline01 1 1 – selects the first knot in the first shape
I need to know which spline the knot I’ve selected lies on.
Anyone…?
thanks in advance!
If you use “getknotselection” then you’re already specifying which spline to work on,
so
getknotselection $ 2
will return the selected knots on spline 2. Maybe little more information about what you’re trying to do or a snippet of code will help.
J.
Heya j-man,
thanks for your reply, but I was asking about how to get a SPLINE ID from a selected KNOT.
So, let’s say you attach many splines together, so that the splines are indexed from 1 – 5 let’s say and each has, let’s say, 5 knots.
So, when I select a knot on spline 3 its index is 3, but if I select a knot on spline 2 its index can also be 3.
How do I know which knot lies on which spline? Based on knot selection?
hi loocas,
can´t understand your problem too. every knot method, that i know, goes trough the spline index first, so how can you reach a situation where you don´t know the spline index?
can´t you post some part of your code with this situation?
Sure,
I wrote a very simple script for changing KNOT interpolation (bezier, corner etc…), so I don’t know which spline the user has selected, that’s why I can’t address it.
I need a code that would know which spline the user is working on (he selects a KNOT on a spline) so that I can address it in the script:
macroScript set_corner_knot_interpolation
category:"duber's tools"
buttonText:"Corner Int."
tooltip: "Corner Int."
(
on isEnabled return
(
selection.count == 1 and \
(classof selection[1] == SplineShape or \
classof selection[1] == Line) \
and selection[1].modifiers.count == 0
)
on execute do
(
knotIndex = getKnotSelection $ 1
for i = 1 to knotIndex.count do
(
setKnotType $ 1 knotIndex[i] #corner
updateShape $
)
)
)
One solution could be loop through all the shape splines and find out the first spline with some knot selected. This is the function:
fn getFirstSelectedKnotOwner theShape = (
for nSpline = 1 to theShape.numSplines do
if (getKnotSelection theShape nSpline).count > 0 do
return nSpline
return 0
)
The function returns the index of the first spline with some knot selected. Else, returns 0.
Keep in mind that if you have more than one knot selected, this function will return the first spline with some knot selected.
Now that you have the spline index, you can use it in your macroscript.
Hope that helps.
Thank you very much HalfVector
I’ll build on that script you posted in my script.
Thanks again, much appretiated!
now i see. adding some lines to halfvector´s code and you could get all spline´s indexes:
fn getSelectedKnotOwner theShape =
(
spline_indexes = #()
for nSpline = 1 to theShape.numSplines do
if (getKnotSelection theShape nSpline).count > 0 do
append spline_indexes nspline
return spline_indexes
)