Notifications
Clear all

[Closed] Useful mxs sdk extension functions

the part is missed in this extension is making a toolbar (frame) floating. i couldn’t find a good and correct way to do it yet. if anyone is interested be free to play.


def_visible_primitive(BaseTriObject, "BaseTriObject");
Value* BaseTriObject_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(BaseTriObject, 0, count);
	
	Object* obj = (Object*)CreateInstance(GEOMOBJECT_CLASS_ID, Class_ID(EDITTRIOBJ_CLASS_ID, 0));
	if (is_mesh(key_arg(mesh)))
	{
		BOOL copy = key_arg_or_default(copy, &true_value)->to_bool();
		Mesh* mesh = (copy) ? new Mesh(*(key_arg(mesh)->to_mesh())) : key_arg(mesh)->to_mesh();
		((TriObject*)obj)->mesh = *mesh;
	}
	return MAXClass::make_wrapper_for(obj);
}

it makes Editable Mesh object (base object for editable mesh) which is not creatable with built-in mxs. It doesn’t create any node with it.

this object can be stored in parameter block as MaxObject. also it can be used for replacing of baseobject of another node, or a replacing instances.

by default it makes empty Editable Mesh, with extra ‘mesh’ argument you can specify a mesh for the object.

So many great extension functions in this thread… but I can’t see the trees for the forest– need to have an index list & brief description for all the extensions herein.

Thanks for sharing them all!

…, compact but clear help with simple search, and several examples of using for every method :):)

I’ve become all “autodesk” and now I feel dirty and ashamed

in addition to BaseTriObject here is BaseSplineShape:

def_visible_primitive(BaseSplineShape, "BaseSplineShape");
Value* BaseSplineShape_cf(Value** arg_list, int count)
{
	check_arg_count_with_keys(BaseSplineShape, 0, count);
	
	Object* obj = (Object*)CreateInstance(SHAPE_CLASS_ID, Class_ID(SPLINESHAPE_CLASS_ID, 0));
	Object* ref = NULL;
	
	if (key_arg(shape) != &unsupplied) ref = (Object*)(key_arg(shape)->to_reftarg());
	if (ref && ref->CanConvertToType(Class_ID(SPLINESHAPE_CLASS_ID, 0))) 
	{ 
		TimeValue t = MAXScript_time();
		SplineShape* spline = (SplineShape*)ref->ConvertToType(t, Class_ID(SPLINESHAPE_CLASS_ID,0));
		return object_wrapper(new SplineShape(*spline));
	}
	return object_wrapper(obj);
}

brute force on tri index to polyface

Is there any way with a MXS extension to get the viewport statistics in full?

Polys, Tris, Edges, Verts. Total + Selection for all of these?

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

i’m sure the system gets all geometry data on-the-fly using callbacks. the only thing is probably hidden for mxs is FPS. but it seems available via sdk

(@davewortley)
Joined: 11 months ago

Posts: 0

You can get the FPS…
viewport.GetFPS()
(well not the true one but the one that max thinks it has).

I worked on a script with Daniel Santana to update the viewport statistic to something far more useful. But there was slowdown getting the total number of polys in a scene/selection and this didn’t work well for animated objects. The viewport has the method to return this in real-time, but it doesn’t have any maxscript exposure.

maybe i’ve missed anything but i couldn’t find a way using mxs to get a default name of a specified class instance…

def_visible_primitive(getInitNodeName, "getInitNodeName");
Value* getInitNodeName_cf(Value** arg_list, int count)
{
	check_arg_count(getInitNodeName, 1, count);
	Object* ref = (Object*)arg_list[0]->to_reftarg();
	MSTR name;
	ref->InitNodeName(name);
	return new String(name);
}

@DenisT, @Klvnk:

Is it possible to write an extension that would expose grabbing the user moving, rotation, scaling commands/manipulations for the Transform Script Controller?

If you enable the MacroRecorder in the Listener and then assign a Transform Script Controller to a helper node, then when you try to manipulate the transform gizmo– you see the move/rotate/scale commands responding in the Listener… but there’s no way to get at (capture) these signals… to use within the script.

It would open up possibilities for scripting transform controller if these signals could be accessed/grabbed by its owning transform script controller.

Or could they somehow be grabbed/intercepted from the Listener (since they appear to leave a trail)?

Page 16 / 18