Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Maxunderground news unavailable

MAXscript saving object in variable
show user profile  Danilo
Hello, this is my first post.

I started learning Maxscript, and i am currently trying to implement 3d function of illustrators blend to 3ds max design.

[for anyone who dont know is , you have 2 splines in different shapes , and this functions blends them creating several versions in distance of those two elements and than makes new element which gradually transforms from 1 element to another]

[note] this program has no limits, if you select 2 it works with two, if you seect 3 it works from 1 to 2, and from 2 to 3 and than welds it, for 4 and more it works in same fashion as for 3.

Now i know that learning new programing language should be done on small tasks like print something on the screen , create object etc, but i felt confident enough to try on something i need because i have somewhat programing experiences [ c++, javascript, php ... ]
but , i stumbles when i tried to make a array of structs in which every structure has name and array of points appointed to it.
as you can see this program is in it infancy , i just started to make reading part of the program and bumped into a problem :P

so i figured it out that is the long way to go, and that is better to ask smarter people for help.

is there any better way to store each element in selection as one part of array with all of its vertexes?

as said before i tried making some code similar to this

struct OBJ (name, vertexes=#() )
--so i could make, something like this

items = #()
for i = 0 in $ do
items[i] name:( as string)
end_count = i.GetNumVertices()
for vID = 0 in end_count do
append vertexes polyOp.getVert i vID

but i fail constantly adding points to vertexes. I cant find any way on any forum that supplies that kind of implementation
read 610 times
12/13/2015 4:55:42 PM (last edit: 12/13/2015 4:55:42 PM)
show user profile  Garp

A few points:
- the code retrieves the point positions only of the first subspline, other subsplines (if any) are ignored.
- the for... collect... version of the for loop is convenient when building arrays.
- the where clause in the first for loop is a filter, in case you also selected a mesh or camera.

read 597 times
12/13/2015 6:30:22 PM (last edit: 12/13/2015 6:35:43 PM)
show user profile  Danilo
ok, this is the far i have understood .

you have defined struct with name and vertices
than you stored collected data from for loop in local variable called data,
put that in struct and than checked for result.

if i am wrong please correct me.

i have several questions... why splines ?
it is maybe somewhat philosofical question, but i whougt that vertices can be more suficient... becasue any spline and any egde, poly is made from vertices... i thought that is best to start from begining.
Could you elaborate more please?
read 555 times
12/14/2015 6:40:58 PM (last edit: 12/14/2015 6:40:58 PM)
show user profile  Danilo
also at the end i succeeded... findled here and there and i came up with this.

if $ == undefined do
messageBox "sorry nothing selected"
spn_itteration.value = 0

if $ != undefined do

--pharsing selection
for i in $ do
--storing inital position and name of every selected object
el = selected -- generating element structure to be stored in array
el.position = i.pos -- storing position of element in element structure to be stored in array

--converting it to editable poly and counting and storing vertices
sItem = convertToPoly(i) --converting element to editable poly
vCount = sItem.GetNumVertices() --geting nubmer of vertices in such poly

-- for loop for every vertex in such poly
for ivID = 1 to vCount do
--v variable , aka vertex
vertex = eVert vID:ivID -- storing vertexid in struct in v variable
vertex.pos = polyOp.getVert sItem ivID
eVertic_array[ivID] = vertex

print("stored vertex no " + (ivID as string) )

print "stored vertices"
el.vertexes = eVertic_array

elements[icount] = el -- storing struct in elements array
print elements[icount] -- print for loggin and proofing
icount += 1 -- icrementing counter
sleep 1
print ( "stored everything for element" + )

print "conversion complete"

read 553 times
12/14/2015 6:44:50 PM (last edit: 12/14/2015 6:51:09 PM)
show user profile  Garp
Why splines? That's what I understood from 'you have 2 splines in different shapes'.

You do know that morphing is actually implemented in max, right?

read 547 times
12/14/2015 7:14:37 PM (last edit: 12/14/2015 7:14:37 PM)
show user profile  Danilo
noo... as i said i just started learning maxscript... could you please give an example?

well splines were examples ... it was supposed to use any shape... primitive, box, spline, poly, mesh ... etc.
read 535 times
12/15/2015 2:43:22 PM (last edit: 12/15/2015 2:43:22 PM)
#Maxforums IRC
Open chat window