SOLVED Retrieving particle positions for Multi-Instance


I need to retrieve the particle positions from the object used in INSTANCEOBJECT_MULTIPOSITIONINPUT parameter of Multi-Instance.

The documentation says it supports Mograph Matrix, Emitter and Thinking Particles.
I retrieve the positions from Mograph Matrix using ID_MOTAGDATA tag.

How can I do the same with Emitter and Thinking Particles ?

Thank you for your time !


so you want to retrieve the positions of particles (from particles object or TP) ?

About Thinking Particles you have information here, don't forget to use InitThinkingParticles before using it.

For Particles Object you have this page and this is pretty straight forward.

For example :

        // Retrieves Particles Object

	BaseObject *selObj = doc->GetActiveObject();
	if (selObj == nullptr || !selObj->IsInstanceOf(Oparticle))
		MessageDialog("Need to select a particle object"_s);
		return maxon::OK;

	// cast object to ParticleObject
	ParticleObject* partObj = static_cast<ParticleObject*>(selObj);
	if (partObj == nullptr)
		return maxon::NullptrError(MAXON_SOURCE_LOCATION);

	const maxon::Int32 cnt = partObj->GetParticleCount();

	// Retrieves the particle tag that is invisible.
	ParticleTag* partTag = static_cast<ParticleTag*>(partObj->GetTag(Tparticle));

	for (maxon::Int32 i = 0; i < cnt; i++)
		const Particle* myParticle = partObj->GetParticleR(partTag, i );
		// Check particle's age before output position
		if (myParticle->t > 0)
			DiagnosticOutput("particle position @ have age @", myParticle->off, myParticle->t);

	// Creates particles in TP

	// Retrieves the TP Master
	BaseSceneHook* hook = doc->FindSceneHook(ID_THINKINGPARTICLES);
	if (hook == nullptr || hook->GetType() != ID_THINKINGPARTICLES)
		return maxon::NullptrError(MAXON_SOURCE_LOCATION);

	TP_MasterSystem* tpmaster = static_cast<TP_MasterSystem*>(hook);

	if (tpmaster == nullptr)
		return maxon::NullptrError(MAXON_SOURCE_LOCATION);

	// Alloc 10 particles 
	maxon::Int32 ids[10];

	if (tpmaster->AllocParticles(10, ids) == NOTOK)
		return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);

	// Changes position of particles and retrieves it to output it.
	for (auto pid : ids)
		tpmaster->SetPosition(pid, Vector(pid * 50));
		Vector pos = tpmaster->Position(pid);
		DiagnosticOutput("position of particle @ is @", pid, pos);



Thank you for your help !