Poly Object to Script

Hi

Has anyone got a script that will take a custon polygon mesh and output the code to build it in a max script. ie save out all the point and polygon data?
I am trying to make my own custom helper objects.

Thanks

Gram

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Garp's picture

Nice! You might want to

Nice!

You might want to update the script before going any further though. The bug you found has been fixed (and in the Primitive Maker too).

gramx's picture

Ah ha - All fixed in one

Ah ha - All fixed in one line, well done!
on clone orig do buildTriMesh()
cheers

g

gramx's picture

Cam Rig with custom helpers

Hi Just wanted to say thanks again for all your help :) I have finished my first camera Rig:-

I have attched the Max scene file and the helper plugins. Have a play, your welcome to use it also! It uses a Vray camera. I am going to make a crane Rig next. Always wanted one for creating realistic camera moves. I will be able to create some cool crane helper objects now :)

camrig2: bug fix - Updated helpers

Cheers

Gram

 

AttachmentSize
camrig2.rar 31.01 KB
Garp's picture

This one

This one then:
http://www.scriptspot.com/3ds-max/scripts/helper-maker

Before looking at the script itself, run it and look at the plugin file it outputs.
What the maker scrip does is just write the plugin code to disk. The rest is essentially building the UI and checking if the plugin name and/or the plugin file are already defined.

If you look at the example code in the doc, you can see that the 'on getDisplayMesh' block returns a trimesh. So you just need to give the trimesh definition to the plugin.
Since you need to define it only once, don't put it in the block but outside in a function that is called by the 'on create' and 'on load' handlers.

To pass the data from the maker script to the plugin file, you do something like

local theVerts = for v = 1 to getNumVerts myObject collect getVert myObject v
format "v_arr = %\n" theVerts to:output_file

Same principle for the faces and edge visibility. The primitive version passes a few more things but it's basically the same code.
Hope that clarifies a few points.

And of course, Happy New Year guys! :)

gramx's picture

Ha Ha

Cant beleive I missed that one! lol

Problem solved, Its been a very good learning exercise anyway.

Many thanks

g

Graph's picture

yeah and usually you'd use

yeah and usually you'd use the createInstance function to do that but i tried it here and it didnt work with the mesh

better use a TriMesh() to do that, have a look in the help how to build that, cant help atm, way fuked up

happy new year

edit: not at all garp, he's just learning some maxScript, your plugin is still cool

Raphael 'Insanto' Steves
http://Graph.Net84.Net

gramx's picture

Sounds like you've had a good

Sounds like you've had a good night!

Yes I have been trying the createInstance function without any success! I have also been looking at TriMesh and it looks like you have to use the .mesh function to define it, which I am already doing:- theMesh = copy meshObj.mesh. Cant find anyway round it ;(

Hope your feeling better soon!

g

gramx's picture

Allmost done!

Hi

What I am trying to do is different as I am trying to define Helper Objects directly without building a mesh in the viewport and the passing it to the helper. With help(thanks) I have got the converting mesh to code working fine! What I am trying to do now is to define this mesh in memory and then pass this to the display mesh of the helper. At the moment what ever I try builds a mesh in the viewport which then needs deleting after being passed to the diplay mesh. I have put the code for a simple helper below.

plugin Helper Helper_Test
name:"Helper Test" 
classID:#(0x1e6a3439, 0x18067b16)
category:"Standard" 
extends:dummy 
( 
	local  meshObj, theMesh
 
	on getDisplayMesh do 
	(
		if meshObj == undefined then
		(
 
			meshObj = execute "(mesh vertices:#([0,0,50], [-40,-40,0], [40,-40,0], [40,40,0], [-40,40,0], [0,0,0]) faces:#([1,2,3], [1,3,4], [1,4,5], [1,5,2], [2,6,3], [3,6,4], [4,6,5], [5,6,2]));"
			theMesh = copy meshObj.mesh
                        delete meshObj
 
		)
		theMesh
	)
 
	tool create
	(
		on mousePoint click do
		case click of
		(
			1: nodeTM.translation = gridPoint
			2: #stop
		)
	)
)

I am trying too pass a tri mesh to theMesh directly so I dont create geometry in the max scene and then have to delete meshObj. Cant figure it out!

Cheers!

Happy New Year!

Garp's picture

"a script that will take a

"a script that will take a custon polygon mesh and output the code to build it in a max script. ie save out all the point and polygon data"

Did I miss something?

Graph's picture

by simply returning the var

by simply returning the var that holds the mesh at the end of the string to execute as it turns out ^^

local test = execute "#simple"
print test

Raphael 'Insanto' Steves
http://Graph.Net84.Net

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.