MultiJoints + Scripting

Post Reply
User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

MultiJoints + Scripting

Post by tsn » Tue Aug 03, 2010 10:00 am

Is there a certain reason why MultiJoints aren't supported by RF's Python interface? It's not even possible to switch "Simulation" from "Inactive" to "Active".
Thomas Schlick | Next Limit Technologies

User avatar
FlorianK
Posts: 238
Joined: Fri Jun 11, 2010 9:56 am
Location: Cologne, Germany

Re: MultiJoints + Scripting

Post by FlorianK » Tue Aug 03, 2010 11:56 am

Hi Thomas,

just an advice- recently, I had some troubles keying/ switching "Simulation" (thus not by script but by hand) but everything was working fine when doing this on "Dyn Motion", intead,

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: MultiJoints + Scripting

Post by tsn » Tue Aug 03, 2010 4:18 pm

Thanks for the tip. Unfortunately this won't help with MultiJoints, since they're obviously not implemented in the Python API, but I hope this will be changed with the next patch.
Thomas Schlick | Next Limit Technologies

User avatar
Alex
Site Admin
Posts: 143
Joined: Mon Jun 14, 2010 9:35 am

Re: MultiJoints + Scripting

Post by Alex » Mon Aug 09, 2010 1:07 pm

Hi Thomas,

for that specific purpose, you can use an XML import workaround:

Code: Select all

import os
import tempfile

def setMultiJointSimulation( mjname, status ):
	# Compose XML code
	xmlcode = '<?xml version="1.0" encoding="UTF-8"?>'
	xmlcode += '<!DOCTYPE rfxml><rfxml version="0.2">'
	xmlcode += '<nodes>'

	xmlcode += '<node name="'
	xmlcode += mjname
	xmlcode += '" class="MultiJoint"><parameters>'
	
	xmlcode += '<param name="Simulation"><enum_val><string>'
	xmlcode += status
	xmlcode += '</string></enum_val></param>'
	
	xmlcode += '</parameters></node></nodes></rfxml>'

	# Save to temporary file and import
	tmp = tempfile.NamedTemporaryFile(suffix=".xml", delete=False)
	tmp.write( xmlcode )
	tmp.close()

	scene.importFromXML(tmp.name,False,True)

	os.remove(tmp.name)
	scene.paint()


# Example
setMultiJointSimulation( "MultiJoint01", "Inactive" )
Hope that helps until MultiJoints are finally added for scripting.
Alex Ribao
RealFlow Team
Next Limit Technologies

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: MultiJoints + Scripting

Post by tsn » Mon Aug 09, 2010 1:59 pm

Hi Alex,

Many thanks for this clever workaround. I've tested it and it works great.

8-)
Thomas Schlick | Next Limit Technologies

Post Reply