I tried this code, but it segfaults on the qw.setSceneGraph() call:
Code: Select all
import pivy
import pivy.coin
import pivy.quarter
# Create Quarter 3D view
qw = pivy.quarter.QuarterWidget()
qw.setSceneGraph(FreeCADGui.ActiveDocument.ActiveView.getSceneGraph())
qw.show() # might need qw.setGeometry(…) too
Code: Select all
import pivy
import pivy.coin
import pivy.quarter
# Create red cube
col = pivy.coin.SoBaseColor()
col.rgb = (1, 0, 0)
trans = pivy.coin.SoTranslation()
trans.translation.setValue([0, 0, 0])
cub = pivy.coin.SoCube()
myCustomNode = pivy.coin.SoSeparator()
myCustomNode.addChild(col)
myCustomNode.addChild(trans)
myCustomNode.addChild(cub)
# Create Quarter 3D view
qw = pivy.quarter.QuarterWidget()
qw.setSceneGraph(myCustomNode)
qw.show() # might need qw.setGeometry(…) too
Code: Select all
import pivy
import pivy.coin
import pivy.quarter
# Create red cube
col = pivy.coin.SoBaseColor()
col.rgb = (1, 0, 0)
trans = pivy.coin.SoTranslation()
trans.translation.setValue([0, 0, 0])
cub = pivy.coin.SoCube()
myCustomNode = pivy.coin.SoSeparator()
myCustomNode.addChild(col)
myCustomNode.addChild(trans)
myCustomNode.addChild(cub)
# Change scene graph of existing 3D view
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
sg.removeAllChildren()
# This works:
sg.addChild(myCustomNode)