[Closed] help specific Spline Knots
Hi there,
I’m writing a script which imports a sequence of illustrator files and extrudes them. So far everything is working great except illustrator gives me a box around my shape meaning the shape becomes a hole in a box when extruded.
I thought I had solved this problem as most times the spline index of the box was 1, so i could automatically delete this spline. However this seems to vary every so often. Therefore I can’t use splineOps.delete
I have noticed however that the knots that make up this box are always 1,2,3,4,5 however given that the spline ID is changing I’m also unable to use setKnotSelection and delete them as this command also requires the spline ID.
Anyone any ideas how to get rid of this box, even something like a volume select that’ll work for splines would be good.
cheers !
ben
Ok I’ve pretty much worked around the problem by adding another box 10% bigger than the illustrator one, which when extruded reverses the hole.
However I’d still love to know of a spline based method that’d help me.
As is often the case, writing out the problem helps you figure it out in your head !
thanks
If I had this problem, I would have done the following:
Take all the splines and scan their vertices – find out which splines have 5 vertices, then if there is more than one, find out whose vertices lie the farthest from the commong center (thus being at the OUTSIDE of the shape). Once you find these things out, chances are it will be the spline you want to delete…
A very smart solution Bobo, thanks for that.
I’m chugging along with the extra border for now, I’m going to need to use a volume select and scale the gizmo and then use Deletemesh to remove that border.
Bobo I take it the gizmo for volume select has the same issues as you describe for the UVW gizmo in your ‘HOW TO … FIT THE UVW MAPPING GIZMO’ article. So I’ll need to study your code to get the gizmo to scale about my object’s center ?
Currently this code :
ImportedShape.modifiers[1].Gizmo.scale = [0.9,0.9,0.9]
causes the scale to be slightly offset from the object centre.
A belated followup.
My idea didn’t work at all so I went with BoBo’s suggestion.
Should anyone be interested here’s the code segment. It will find the border spline within the selected shape. It does this by finding all the five pointed shapes and then sorting them into order based on their distance from the centre.
If anyone has any feedback or a more elegent coding idea then I’d be keen to hear about it.
position_array = #()
spline_array = #()
spline_score = #()
my_object = $
i = 0
function compare_score v1 v2 =
(
local d = (v1[2]-v2[2]) -- compare vector lengths
case of
(
(d < 0): -1
(d > -0): 1
default: 0
)
)
for s = 1 to (numSplines my_object) do
(
if (numKnots my_object s) == 5 then
(
i = i + 1
spline_array[i] = #()
spline_array[i][1] = s
spline_array[i][2] = ( length(getKnotPoint my_object s 1) +
length(getKnotPoint my_object s 2) +
length(getKnotPoint my_object s 3) +
length(getKnotPoint my_object s 4) +
length(getKnotPoint my_object s 5) )
)
)
qsort spline_array compare_score
print (spline_array[spline_array.count][1] as string)
deleteSpline my_object (spline_array[spline_array.count][1])