Notifications
Clear all

[Closed] String to new file

 lo1

your problem was a lack of brackets. Your original code is like writing:

for v = 1 to num_verts do (local coord = getVert tmesh v)
 format "%,%,%
" coord.x coord.y coord.z  to:out_file

the second line has no idea what coord is because it was local to the scope of the for loop. Not only that, it will only run once because it’s outside of the loop.

1 Reply
(@gazybara)
Joined: 2 years ago

Posts: 0

lo, thanks for the explanations.
I just post working code to dellis to see by yourself where he is wrong.
But your comment is a bonus.
Cheers!

Thank you guys so much! And i appologize if its stupid…but i can’t get the brackets off the coordinates in the face index. I looked in the help file but i can’t seem to find what i am looking for. My mistake that you corrected above works perfect and i understand that you used this because each vertex has a a number and an x,y,z…just not sure what i should use for a face to get rid of the square brackets since i’m not looking for coords…

This is what i’m getting for output right now which is really, really close!


  DEF BODY0 Separator 
  	{
  		Coordinate3
  		{
  			point [
  2.68518,-62.1888,0.0
  47.9616,-62.1888,0.0
  2.68518,-25.3717,0.0
  47.9616,-25.3717,0.0
  2.68518,-62.1888,29.7604
  47.9616,-62.1888,29.7604
  2.68518,-25.3717,29.7604
  47.9616,-25.3717,29.7604
  	]
  		}
  
  USE BODY		
  		IndexedFaceSet		
  		{		
  			coordIndex [
  [1,3,4]
  [4,2,1]
  [5,6,8]
  [8,7,5]
  [1,2,6]
  [6,5,1]
  [2,4,8]
  [8,6,2]
  [4,3,7]
  [7,8,4]
  [3,1,5]
  [5,7,3]
  ]	
  		}		
  				
  	}
  

I just have to get rid of the orange guys…

Again…thanks for all your help! Maxscript is awesome…lots to learn though!!

 lo1

Faces are represented as Point3 values as well, and therefore also have .x .y .z properties (or alternatively, can be indexed using [1] [2] [3]. The fact that the .x .y .z properties don’t actually represent cartesian coordinates, but vertex indices, is of no importance.

face = getFace tmesh f 
format "%, %, %
" (face.x as integer) (face.y as integer) (face.z as integer) to:out_file

I am casting to integer because Point3 values are always stored as float, and would result in

1.0, 3.0, 4.0

instead of

1, 3, 4

Thank you so much for the help! I really appreciate it. Worked perfectly.

lo,

how would you write it the other way that you mentioned here:

Faces are represented as Point3 values as well, and therefore also have .x .y .z properties (or alternatively, can be indexed using [1] [2] [3].

I tried this:


(
   local face = getFace tmesh f  
      format "%, %, %
" (face[1] as integer) (face[2] as integer) (face[3] as integer) --to:out_file
 )

…and it is still giving me the same output.

1 Reply
 lo1
(@lo1)
Joined: 2 years ago

Posts: 0

Sorry, I dont understand what you mean. What output are you getting and what output do you want to get?

Page 2 / 2