[Closed] align verts to spline
I’m scripting a primitive object. method is by adding verts by vert_array[1] = [-u/2, v/2/0] like this.
A certain number of verts out of tis vert_array, i want to allign to a given spline.
How do i select those verts from a trimesh :s Can somebody help me out this misery
problem is when i would convertToMesh, afterwards i wouldn’t be able to edit my parameters of the primitive.
Next questions is the creation of a bounding box around the organic primitive. The primitive is scripted in a uvw coordsys. The bbox in xyz, where the measure of the box is variabel by the distance between the extents of the organic form. Is it correct when i define those extents by float_limitter
plugin simpleObject Proefvlak
name:"Proefvlak"
category:"Davy F-Objects"
classID: #(5123456, 07)
(
parameters main rollout:params
(
u type:#float ui:u default:1
v type:#float ui:v default:1
w type:#float ui:w default:1
-- in future adding parameter height and volume
)
rollout params "Proefvlak Parameters"
(
spinner u "Width" range:[0,1000,1] align:#right fieldwidth:60
spinner v "Length" range:[0,1000,1] align:#right fieldwidth:60
spinner w "Heigth" range:[0,1000,1] align:#right fieldwidth:60
-- in future adding spinner of height and volume
)
on buildMesh do
(
--
vert_array = #()
face_array = #()
--- Bodem
--
--
--
vert_array[1]= [-u/2, v/2, 0]
vert_array[2]= [-3*u/8, v/2, 0]
vert_array[3]= [-u/4, v/2, 0]
vert_array[4]= [-u/8, v/2, 0]
vert_array[5]= [0, v/2, 0]
vert_array[6]= [u/8, v/2, 0]
vert_array[7]= [u/4, v/2, 0]
vert_array[8]= [3*u/8, v/2, 0]
vert_array[9]= [u/2, v/2, 0]
-- tweede rij
vert_array[10]= [-u/2, 3*v/8, 0]
vert_array[11]= [-3*u/8, 3*v/8, 0]
vert_array[12]= [-u/4, 3*v/8, 0]
vert_array[13]= [-u/8, 3*v/8, 0]
vert_array[14]= [0, 3*v/8, 0]
vert_array[15]= [u/8, 3*v/8, 0]
vert_array[16]= [u/4, 3*v/8, 0]
vert_array[17]= [3*u/8, 3*v/8, 0]
vert_array[18]= [u/2, 3*v/8, 0]
-- derde rij
vert_array[19]= [-u/2, v/4, 0]
vert_array[20]= [-3*u/8, v/4, 0]
vert_array[21]= [-u/4, v/4, 0]
vert_array[22]= [-u/8, v/4, 0]
vert_array[23]= [0, v/4, 0]
vert_array[24]= [u/8, v/4, 0]
vert_array[25]= [u/4, v/4, 0]
vert_array[26]= [3*u/8, v/4, 0]
vert_array[27]= [u/2, v/4, 0]
-- vierde rij
vert_array[28]= [-u/2, v/8, 0]
vert_array[29]= [-3*u/8, v/8, 0]
vert_array[30]= [-u/4, v/8, 0]
vert_array[31]= [-u/8, v/8, 0]
vert_array[32]= [0, v/8, 0]
vert_array[33]= [u/8, v/8, 0]
vert_array[34]= [u/4, v/8, 0]
vert_array[35]= [3*u/8, v/8, 0]
vert_array[36]= [u/2, v/8, 0]
-- vijfde rij
vert_array[37]= [-u/2, 0, 0]
vert_array[38]= [-3*u/8, 0, 0]
vert_array[39]= [-u/4, 0, 0]
vert_array[40]= [-u/8, 0, 0]
vert_array[41]= [0, 0, 0]
vert_array[42]= [u/8, 0, 0]
vert_array[43]= [u/4, 0, 0]
vert_array[44]= [3*u/8, 0, 0]
vert_array[45]= [u/2, 0, 0]
-- zesde rij
vert_array[46]= [-u/2, -v/8, 0]
vert_array[47]= [-3*u/8, -v/8, 0]
vert_array[48]= [-u/4, -v/8, 0]
vert_array[49]= [-u/8, -v/8, 0]
vert_array[50]= [0, -v/8, 0]
vert_array[51]= [u/8, -v/8, 0]
vert_array[52]= [u/4, -v/8, 0]
vert_array[53]= [3*u/8, -v/8, 0]
vert_array[54]= [u/2, -v/8, 0]
-- zevende rij
vert_array[55]= [-u/2, -v/4, 0]
vert_array[56]= [-3*u/8, -v/4, 0]
vert_array[57]= [-u/4, -v/4, 0]
vert_array[58]= [-u/8, -v/4, 0]
vert_array[59]= [0, -v/4, 0]
vert_array[60]= [u/8, -v/4, 0]
vert_array[61]= [u/4, -v/4, 0]
vert_array[62]= [3*u/8, -v/4, 0]
vert_array[63]= [u/2, -v/4, 0]
-- achtste rij
vert_array[64]= [-u/2, -3*v/8, 0]
vert_array[65]= [-3*u/8, -3*v/8, 0]
vert_array[66]= [-u/4, -3*v/8, 0]
vert_array[67]= [-u/8, -3*v/8, 0]
vert_array[68]= [0, -3*v/8, 0]
vert_array[69]= [u/8, -3*v/8, 0]
vert_array[70]= [u/4, -3*v/8, 0]
vert_array[71]= [3*u/8, -3*v/8, 0]
vert_array[72]= [u/2, -3*v/8, 0]
-- negende rij
vert_array[73]= [-u/2, -v/2, 0]
vert_array[74]= [-3*u/8, -v/2, 0]
vert_array[75]= [-u/4, -v/2, 0]
vert_array[76]= [-u/8, -v/2, 0]
vert_array[77]= [0, -v/2, 0]
vert_array[78]= [u/8, -v/2, 0]
vert_array[79]= [u/4, -v/2, 0]
vert_array[80]= [3*u/8, -v/2, 0]
vert_array[81]= [u/2, -v/2, 0]
-- lus01
vert_array[82]= [-u/2, v/2, w/10]
vert_array[83]= [-3*u/8, v/2, w/10]
vert_array[84]= [-u/4, v/2, w/10]
vert_array[85]= [-u/8, v/2, w/10]
vert_array[86]= [0, v/2, w/10]
vert_array[87]= [u/8, v/2, w/10]
vert_array[88]= [u/4, v/2, w/10]
vert_array[89]= [3*u/8, v/2, w/10]
vert_array[90]= [u/2, v/2, w/10]
--
vert_array[106]= [-u/2, -v/2, w/10]
vert_array[105]= [-3*u/8, -v/2, w/10]
vert_array[104]= [-u/4, -v/2, w/10]
vert_array[103]= [-u/8, -v/2, w/10]
vert_array[102]= [0, -v/2, w/10]
vert_array[101]= [u/8, -v/2, w/10]
vert_array[100]= [u/4, -v/2, w/10]
vert_array[99]= [3*u/8, -v/2, w/10]
vert_array[98]= [u/2, -v/2, w/10]
--
vert_array[113]= [-u/2, 3*v/8, w/10]
vert_array[112]= [-u/2, v/4, w/10]
vert_array[111]= [-u/2, v/8, w/10]
vert_array[110]= [-u/2, 0, w/10]
vert_array[109]= [-u/2, -v/8, w/10]
vert_array[108]= [-u/2, -v/4, w/10]
vert_array[107]= [-u/2, -3*v/8, w/10]
--
vert_array[91]= [u/2, 3*v/8, w/10]
vert_array[92]= [u/2, v/4, w/10]
vert_array[93]= [u/2, v/8, w/10]
vert_array[94]= [u/2, 0, w/10]
vert_array[95]= [u/2, -v/8, w/10]
vert_array[96]= [u/2, -v/4, w/10]
vert_array[97]= [u/2, -3*v/8, w/10]
--lus02
--lus03
--lus04
--lus05
--lus06
--lus07
--lus08
--lus09
--lus10
-- build faces
-- upper faces
append face_array[1,2,10]
append face_array[2,11,10]
--
append face_array[2,3,12]
append face_array[2,11,12]
--
append face_array[3,4,12]
append face_array[4,13,12]
--
append face_array[4,5,14]
append face_array[4,13,14]
--
append face_array[5,6,14]
append face_array[6,14,15]
--
append face_array[6,7,16]
append face_array[7,8,16]
--
append face_array[8,17,16]
append face_array[6,15,16]
--
append face_array[8,17,18]
append face_array[8,9,18]
-- second row faces
append face_array[10,19,20]
append face_array[10,11,20]
--
append face_array[11,12,20]
append face_array[12,21,20]
--
append face_array[12,21,22]
append face_array[12,13,22]
--
append face_array[13,14,22]
append face_array[14,23,22]
--
append face_array[14,24,23]
append face_array[14,15,24]
--
append face_array[15,16,24]
append face_array[16,25,24]
--
append face_array[16,17,26]
append face_array[16,26,23]
--
append face_array[17,18,26]
append face_array[18,27,26]
-- third row faces
append face_array[19,20,28]
append face_array[20,29,28]
--
append face_array[20,30,29]
append face_array[20,21,30]
--
append face_array[21,22,30]
append face_array[22,30,31]
--
append face_array[22,32,31]
append face_array[22,23,32]
--
append face_array[23,24,32]
append face_array[24,33,32]
--
append face_array[24,25,34]
append face_array[24,33,34]
--
append face_array[25,26,34]
append face_array[26,35,34]
--
append face_array[26,27,36]
append face_array[26,35,36]
-- fourth row faces
append face_array[28,29,38]
append face_array[28,38,37]
--
append face_array[29,30,38]
append face_array[30,39,38]
--
append face_array[30,31,40]
append face_array[30,40,39]
--
append face_array[31,32,40]
append face_array[32,41,40]
--
append face_array[32,42,41]
append face_array[32,33,42]
--
append face_array[33,34,42]
append face_array[34,43,42]
--
append face_array[34,44,43]
append face_array[34,35,44]
--
append face_array[35,36,44]
append face_array[36,45,44]
-- fifth row faces
append face_array[37,38,46]
append face_array[38,47,46]
--
append face_array[38,39,48]
append face_array[38,48,47]
--
append face_array[39,40,48]
append face_array[40,48,49]
--
append face_array[40,41,50]
append face_array[40,50,49]
--
append face_array[41,42,50]
append face_array[42,51,50]
--
append face_array[42,43,52]
append face_array[42,52,51]
--
append face_array[43,44,52]
append face_array[44,53,52]
--
append face_array[44,45,54]
append face_array[44,54,53]
-- sixth row faces
append face_array[46,47,56]
append face_array[46,56,55]
--
append face_array[47,48,56]
append face_array[48,57,56]
--
append face_array[48,49,58]
append face_array[48,58,57]
--
append face_array[49,50,58]
append face_array[50,59,58]
--
append face_array[50,51,60]
append face_array[50,60,59]
--
append face_array[51,52,60]
append face_array[52,61,60]
--
append face_array[52,53,62]
append face_array[52,62,61]
--
append face_array[53,54,62]
append face_array[54,63,62]
-- seventh row faces
append face_array[55,56,64]
append face_array[56,65,64]
--
append face_array[56,57,66]
append face_array[56,66,65]
--
append face_array[57,58,66]
append face_array[58,67,66]
--
append face_array[58,59,68]
append face_array[58,68,67]
--
append face_array[59,60,68]
append face_array[60,69,68]
--
append face_array[60,61,70]
append face_array[60,70,69]
--
append face_array[61,62,70]
append face_array[62,71,70]
--
append face_array[62,63,72]
append face_array[62,72,71]
-- eight row faces
append face_array[64,74,73]
append face_array[64,65,74]
--
append face_array[65,66,74]
append face_array[66,75,74]
--
append face_array[66,67,76]
append face_array[66,76,75]
--
append face_array[67,68,76]
append face_array[68,77,76]
--
append face_array[68,69,78]
append face_array[68,78,77]
--
append face_array[69,70,78]
append face_array[70,79,78]
--
append face_array[70,80,79]
append face_array[70,71,80]
--
append face_array[71,72,80]
append face_array[72,81,80]
--
-- HIGHT W= W/10
append face_array[1,2,82]
append face_array[2,82,83]
--
append face_array[2,3,83]
append face_array[3,83,84]
--
append face_array[3,4,84]
append face_array[4,84,85]
--
append face_array[4,5,85]
append face_array[5,86,85]
--
append face_array[5,6 ,86]
append face_array[6,86,87]
--
append face_array[6,7,87]
append face_array[7,88,87]
--
append face_array[7,8,88]
append face_array[8,89,88]
--
append face_array[8,9,89]
append face_array[9,90,89]
-- second row faces
append face_array[9,18,90]
append face_array[18,91,90]
-- -- -- --
append face_array[18,27,91]
append face_array[27,92,91]
--
append face_array[27,36,92]
append face_array[36,93,92]
--
append face_array[36,45,93]
append face_array[45,94,93]
--
append face_array[45,54,94]
append face_array[54,95,94]
--
append face_array[54,63,95]
append face_array[63,96,95]
--
append face_array[63,72,96]
append face_array[72,97,96]
--
append face_array[72,81,97]
append face_array[81,98,97]
-- second row faces
append face_array[81,80,98]
append face_array[80,99,98]
-- -- -- --
append face_array[80,79,99]
append face_array[79,100,99]
--
append face_array[79,78,100]
append face_array[78,101,100]
--
append face_array[78,77,101]
append face_array[77,102,101]
--
append face_array[77,76,102]
append face_array[76,103,102]
--
append face_array[76,75,103]
append face_array[75,104,103]
--
append face_array[75,74,104]
append face_array[74,105,104]
--
append face_array[74,73,105]
append face_array[73,106,105]
-- second row faces
append face_array[73,64,106]
append face_array[64,107,106]
-- -- --
append face_array[64,55,107]
append face_array[55,108,107]
--
append face_array[55,46,108]
append face_array[46,109,108]
--
append face_array[46,37,109]
append face_array[37,110,109]
--
append face_array[37,28,110]
append face_array[28,111,110]
--
append face_array[28,19,111]
append face_array[19,112,111]
--
append face_array[19,10,112]
append face_array[10,113,112]
--
append face_array[10,1,113]
append face_array[1,113,82]
-- finished building faces
--
-- create mesh with all these vertices and faces
setMesh mesh name: theMesh verts:vert_array faces:face_array
for i = 1 to mesh.numfaces do setFaceSmoothGroup mesh i 0
-- Set diagonal edges invisible so we have proper quads
for i = 1 to (12*8) by 2 do
(
setEdgeVis mesh i 2 false
setEdgeVis mesh (i+1) 1 false
) -- end for
for i=1 to mesh.Numverts do print i -- ------------------------------------------------------------------------------------------
) -- end build mesh
-- hierachter een bounding box die de build mesh omgeeft
tool create
(
on mousePoint click do
(
case click of
(
1: nodeTM.translation = worldPoint
)
)
on mouseMove click do
(
case click of
(
2:
(
u = v = sqrt ((gridDist.y)^2+(gridDist.x)^2)
)
3: #stop
)
) -- en on mouseMove
) -- end create tool
) -- end plugin
C&C are welcome!
fn createLus01Shape =
(
ln = line();
splIdx = addNewSpline ln;
addKnot ln splIdx #bezier #curve [15.4389,55.1293,-1.90735e-005] [19.6605,54.7896,-1.90735e-005] [10.7276,55.5083,-1.90735e-005];
addKnot ln splIdx #bezier #curve [1.25,55.1306,-1.90735e-005] [5.97975,55.1306,-1.90735e-005] [-3.47975,55.1306,-1.90735e-005];
addKnot ln splIdx #bezier #curve [-12.9389,55.1293,-1.90735e-005] [-8.22759,55.5083,-1.90735e-005] [-17.1605,54.7896,-1.90735e-005];
addKnot ln splIdx #bezier #curve [-25.4249,52.9845,-1.71661e-005] [-21.4308,54.3788,-1.90735e-005] [-30.8614,51.0868,-1.71661e-005];
addKnot ln splIdx #bezier #curve [-40.9415,45.3541,-1.52588e-005] [-35.8342,48.0343,-1.71661e-005] [-45.8518,42.7772,-1.52588e-005];
addKnot ln splIdx #bezier #curve [-55.4178,37.2447,-1.33514e-005] [-51.164,40.8016,-1.33514e-005] [-58.1967,34.9209,-1.14441e-005];
addKnot ln splIdx #bezier #curve [-61.4347,28.2177,-9.53674e-006] [-59.7385,31.4095,-1.14441e-005] [-62.9497,25.3667,-9.53674e-006];
addKnot ln splIdx #bezier #curve [-64.9981,19.2164,-7.62939e-006] [-64.1059,22.3253,-7.62939e-006] [-66.0899,15.4118,-5.72205e-006];
addKnot ln splIdx #bezier #curve [-67.3597,7.57197,-3.8147e-006] [-66.954,11.5116,-3.8147e-006] [-67.7412,3.86757,-1.90735e-006];
addKnot ln splIdx #bezier #curve [-67.3478,-3.59999,0] [-67.7571,0.101431,0] [-66.9396,-7.29059,1.90735e-006];
addKnot ln splIdx #bezier #curve [-64.9219,-14.4719,3.8147e-006] [-65.943,-10.902,3.8147e-006] [-63.7937,-18.4164,5.72205e-006];
addKnot ln splIdx #bezier #curve [-60.9101,-26.1074,7.62939e-006] [-62.6398,-22.3896,5.72205e-006] [-59.4035,-29.3459,9.53674e-006];
addKnot ln splIdx #bezier #curve [-55.2812,-35.1941,1.14441e-005] [-57.482,-32.3984,9.53674e-006] [-52.5164,-38.7062,1.14441e-005];
addKnot ln splIdx #bezier #curve [-46.0888,-44.9348,1.33514e-005] [-49.848,-42.4986,1.33514e-005] [-41.5697,-47.8635,1.52588e-005];
addKnot ln splIdx #bezier #curve [-31.0452,-50.9005,1.52588e-005] [-36.1163,-49.0552,1.52588e-005] [-26.4346,-52.5781,1.71661e-005];
addKnot ln splIdx #bezier #curve [-17.0604,-55.4975,1.71661e-005] [-21.7595,-54.0842,1.71661e-005] [-12.7336,-56.7988,1.71661e-005];
addKnot ln splIdx #bezier #curve [-3.97707,-59.0413,1.90735e-005] [-8.3897,-58.07,1.90735e-005] [-2.26809,-59.4175,1.90735e-005];
addKnot ln splIdx #bezier #curve [1.25,-59.5279,1.90735e-005] [-0.499887,-59.5279,1.90735e-005] [2.99989,-59.5279,1.90735e-005];
addKnot ln splIdx #bezier #curve [6.47707,-59.0413,1.90735e-005] [4.76809,-59.4175,1.90735e-005] [10.8897,-58.07,1.90735e-005];
addKnot ln splIdx #bezier #curve [19.5604,-55.4975,1.71661e-005] [15.2336,-56.7988,1.71661e-005] [24.2595,-54.0842,1.71661e-005];
addKnot ln splIdx #bezier #curve [33.5452,-50.9005,1.52588e-005] [28.9346,-52.5781,1.71661e-005] [38.6163,-49.0552,1.52588e-005];
addKnot ln splIdx #bezier #curve [48.5888,-44.9348,1.33514e-005] [44.0697,-47.8635,1.52588e-005] [52.348,-42.4986,1.33514e-005];
addKnot ln splIdx #bezier #curve [57.7812,-35.1941,1.14441e-005] [55.0164,-38.7062,1.14441e-005] [59.982,-32.3984,9.53674e-006];
addKnot ln splIdx #bezier #curve [63.4101,-26.1074,7.62939e-006] [61.9035,-29.3459,9.53674e-006] [65.1398,-22.3896,5.72205e-006];
addKnot ln splIdx #bezier #curve [67.4219,-14.4719,3.8147e-006] [66.2937,-18.4164,5.72205e-006] [68.443,-10.902,3.8147e-006];
addKnot ln splIdx #bezier #curve [69.8477,-3.59999,0] [69.4396,-7.29059,1.90735e-006] [70.2571,0.101432,0];
addKnot ln splIdx #bezier #curve [69.8597,7.57197,-3.8147e-006] [70.2412,3.86757,-1.90735e-006] [69.454,11.5116,-3.8147e-006];
addKnot ln splIdx #bezier #curve [67.4981,19.2164,-7.62939e-006] [68.5899,15.4118,-5.72205e-006] [66.6059,22.3253,-7.62939e-006];
addKnot ln splIdx #bezier #curve [63.9347,28.2177,-9.53674e-006] [65.4497,25.3667,-9.53674e-006] [62.2385,31.4095,-1.14441e-005];
addKnot ln splIdx #bezier #curve [57.9178,37.2447,-1.33514e-005] [60.6967,34.9209,-1.14441e-005] [53.664,40.8016,-1.33514e-005];
addKnot ln splIdx #bezier #curve [43.4415,45.3541,-1.52588e-005] [48.3518,42.7772,-1.52588e-005] [38.3342,48.0343,-1.71661e-005];
addKnot ln splIdx #bezier #curve [27.9249,52.9845,-1.71661e-005] [33.3614,51.0868,-1.71661e-005] [23.9308,54.3788,-1.90735e-005];
close ln splIdx;
updateShape ln;
convertToSplineShape ln;
ln.wireColor = (color 177 88 27);
ln.name = uniqueName "Lus01";
select ln;
return ln;
)
createLus01Shape()
script of a given spline
srry voor my bad english.
–Jazz_arch–
I don’t know if this will help, but I wrote a script a while ago that would conform a series of selected verts to a spline shape.
May be you can dig some ideas out of it…
macroScript AlignVerts category:"KaiZen Tools" buttonText:"Conform to shape" toolTip:"Conform selected verticies to specified shaep" (
-- Function to get a list of the selected verts
fn getSelectedVerts = (
lstVerts = #();
lstSelection = polyOp.getVertSelection $;
for index = 1 to lstSelection.count do (
if lstSelection[index] then (
append lstVerts index;
)
)
return lstVerts;
)
-- Simple object filter
fn shapeFilter o = (superclassof o == Shape)
local lstVerts = getSelectedVerts()
if lstVerts.count > 0 then (
-- ASk the user to select the shape to use...
local oShape = pickObject message:"Pick shape to confirm to" filter:shapeFilter rubberBand:$.pivot
if oShape != undefined then (
-- Loop through the lest of verts...
for iVert = 1 to lstVerts.count do (
--local pPoint = getKnotPoint oShape iSpline iKnot
local pVert = polyOp.getVert $ lstVerts[iVert]
-- Find the closes vert on the spline
local pPoint = pathInterp oShape (nearestPathParam oShape pVert)
)
)
)
)
thank you!
But that’s the problem. My mesh isn’t a editable poly but a trimesh.
Because I want to make a primitive. And i don’t want to see editable mesh or poly in the modifier tab afterwards.
Has somebody some advise how to solve this problem?
How to select vertices of a trimesh and align them to a spline?
Should it help to use point_helpers?
Regards.
–D.