Python ShellTest scene is giving a weird behavior #4895
Replies: 2 comments 1 reply
-
Hey @julien-siguenza Using the script scn2Python3, I got this scene which behaves the same way than the XML example of the Shell plugin: """
ShellTestPython file is based on the scene:
b'/data/Softwares/sofa/src/master'/../plugins/Shell/examples/xml/ShellTest.scn
. It has been converted into a python script compatible with the SofaPython3 plugin.
"""
import sys
import Sofa
import SofaRuntime
def main():
rootNode=Sofa.Core.Node("rootNode")
createScene(rootNode)
Sofa.Simulation.init(rootNode)
Sofa.Gui.GUIManager.Init("myscene", "qglviewer")
Sofa.Gui.GUIManager.createGUI(rootNode, __file__)
Sofa.Gui.GUIManager.SetDimension(1080, 1080)
Sofa.Gui.GUIManager.MainLoop(rootNode)
Sofa.Gui.GUIManager.closeGUI()
if __name__ == '__main__':
main()
def createScene(rootNode):
# rootNode
# rootNode/plugins
plugins = rootNode.addChild('plugins')
plugins.addObject('RequiredPlugin', name='Shell')
plugins.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective')
plugins.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select')
plugins.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh')
plugins.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct')
plugins.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear')
plugins.addObject('RequiredPlugin', name='Sofa.Component.Mass')
plugins.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward')
plugins.addObject('RequiredPlugin', name='Sofa.Component.StateContainer')
plugins.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant')
plugins.addObject('RequiredPlugin', name='Sofa.Component.Visual')
plugins.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D')
plugins.addObject('RequiredPlugin', name='Sofa.GUI.Component')
rootNode.addObject('AttachBodyButtonSetting', stiffness='0.1')
rootNode.addObject('DefaultAnimationLoop')
rootNode.addObject('VisualStyle', displayFlags='hideVisualModels hideBehaviorModels showMappings showForceFields')
# rootNode/Square
Square = rootNode.addChild('Square')
Square.addObject('EulerImplicitSolver')
Square.addObject('SparseLDLSolver', template='CompressedRowSparseMatrixMat3x3d')
Square.addObject('MeshOBJLoader', name='loader', filename='mesh/square1.obj')
Square.addObject('MeshTopology', name='topology', src='@loader')
Square.addObject('MechanicalObject', template='Rigid3')
Square.addObject('UniformMass', totalMass='0.005')
Square.addObject('BoxROI', name='box', box='0 0.9 -0.1 1 1 0.1', drawBoxes='1')
Square.addObject('FixedConstraint', indices='@box.indices')
Square.addObject('TriangularBendingFEMForceField', youngModulus='1.7e3', poissonRatio='0.3', thickness='0.01')
# rootNode/Square/Visu
Visu = Square.addChild('Visu')
Visu.addObject('OglModel', src='@../topology')
Visu.addObject('IdentityMapping')
return Note that the MouseInteractions define a spring (with a specific stiffness, see in Let me know if this helps |
Beta Was this translation helpful? Give feedback.
-
Hi @hugtalbot, Thank you for your feedback! The python script you shared with me is pretty identical to the one I shared in my previous message.
These being fixed in the script you provided, I am able to run the scene and it gives me exactly the same problematic behavior that I was talking about previously. But maybe I was not clear enough about the so-called problematic behavior I am observing here. What I am pointing out here is the behavior observed when I use the SHIFT+click interaction to deform the shell:
Can you please confirm me that you properly tested from your side both xml and python scenes with the SHIFT+click interaction, and that it didn't give the crash I am talking about for the python scene? From my side, I will prepare a completely new test scene (both in xml and python) applying a bending force at the extremity of a rectangular shell, and compare the behavior observed for both scenes. Note for you: I am using python version 3.10.14, please let me know if I should use another one. Many thanks for your time 🙏 |
Beta Was this translation helpful? Give feedback.
-
Hi there!
It seems that I experience something very weird when I try to run the ShellTest scene using the python API.
I tried to replicate the xml ShellTest scene within a python file that can be found here.
When I run this python script, the scene is launched correctly, but I then animate it and try to sollicitate the plate using the SHIFT+click interaction, and the deformation of the plate is completely crashing.
Can anyone please try to run this python script and tell me what's happening?
Maybe I am missing something obvious there 😣
FYI: @hugtalbot @bakpaul @alxbilger
Beta Was this translation helpful? Give feedback.
All reactions