Tag Archives: References

Select Instance of Object (Max Script)

Select instances of object
This function is select to instances of any object:

fn selectAllInstanceObj obj=
(
	if(obj == undefined) then
	(
		return format"Object undefined" 
	)
	result = #()	
	instanceMgr.getInstances obj &instances	
	instCount = instances.count 
	
	for i = 1 to instCount do
	(
		areRef = ((obj != instances[i]) and not (areNodesInstances obj instances[i]) )
		if( not areRef) then
		(
			join result  #(instances[i])
		)
	)
	
	select result
)

Max Find Only Instance (C++)

Max SDK and C++

Find any object instance using Max SDK and C++
This code block is returned only instance of objects. IInstanceMgr::GetInstanceMgr()->GetInstances functions is finding any object references and instance.But This functions return only instance.

INodeTab MaxSDK::GetInstances(INode *node)
{
    Object *obj = node->GetObjectRef();
    INodeTab instanceAndRef;
    IInstanceMgr::GetInstanceMgr()->GetInstances(*node, instanceAndRef);
    INodeTab onlyInstance;

    for (int k=0; k < instanceAndRef.Count(); k++)
    {
        if (obj == instanceAndRef[k]->GetObjectRef())
		{
			onlyInstance.AppendNode(instanceAndRef[k]);
		}
    }
    return onlyInstance;
}