[RF] Look out for parents!
Realflow, Scripts July 27th, 2010
Small tip for coders and TD’s – always check if there is no parent! ![]()
This might be quite obvious but in fact, this is very common mistake.
If you allow user to use bounding box, bounding sphere to control your code or you need to get a position information from object, check if it is not parented! otherwise you will get wrong data!.
Below You can find few useful functions like getNode(str) that is unfortunately missing in Realflow. I have also attached sample scene describing this common problem.
Sample file:
parenting

No matter what position has this object, for RF it is 0,0,0. Position is affected by its parent – Null in this case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | cube = scene.getObject("Cube01") null = scene.getObject("Null01") def matrix(obj): pos = obj.getParameter("Position") rot = obj.getParameter("Rotation") scl = obj.getParameter("Scale") shr = obj.getParameter("Shear") piv = obj.getParameter("Pivot") scene.message("\n\n" +"position: " + str(pos.x) +" " + str(pos.y) + " " + str(pos.z) + "\n" + "rotation: " + str(rot.x) +" " + str(rot.y) + " " + str(rot.z) + "\n" + "scale: " + str(scl.x) +" " + str(scl.y) + " " + str(scl.z) + "\n" + "shear: " + str(shr.x) +" " + str(shr.y) + " " + str(shr.z) + "\n" + "pivot: " + str(piv.x) +" " + str(piv.y) + " " + str(piv.z) + "\n\n") def getParent(obj): par = obj.getParameter("Parent to") if len(par)==1: return par[0] else: return False def getNode(node): nodes = scene.getNodes() for n in nodes: name = str(n.getName()) if name == node: return n else: pass #sample usage: parent = getParent(cube) if parent: scene.message("parent found: " + str( parent )) node = getNode(parent) scene.message("type: " + str( node.getType() )) matrix(node) else: scene.message("object has no parent") parent = getParent(null) if parent: scene.message("parent found: " + str( parent )) node = getNode(parent) scene.message("type: " + str( node.getType() )) matrix(node) else: scene.message("object null has no parent") |