Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to adapt RealThunders notebook to work here #22

Open
KeithSloan opened this issue Mar 13, 2021 · 1 comment
Open

Trying to adapt RealThunders notebook to work here #22

KeithSloan opened this issue Mar 13, 2021 · 1 comment

Comments

@KeithSloan
Copy link

ln[1] : `import sys, os

#JUPYTER_REPO_PATH = "/opt/jupyter_freecad/"
JUPYTER_REPO_PATH = "/Users/keithsloan/Jupyter_FreeCAD"

#sys.path.append("/opt/freecad/freecad_build/lib")
sys.path.append("/Applications/FreeCAD_0.19-E.app/Contents/Resources/lib/python3.8/site-packages")
sys.path.append(JUPYTER_REPO_PATH + "IPythonFreeCADViewer")

import FreeCAD, FreeCADGui
from pivy import coin
from freecadviewer import render_document, get_document_renderer

FreeCADGui.setupWithoutGUI()
`

ln[2] : `scadstr='''
module example_intersection()
{
intersection() {
difference() {
union() {
cube([30, 30, 30], center = true);
translate([0, 0, -25])
cube([15, 15, 50], center = true);
}
union() {
cube([50, 10, 10], center = true);
cube([10, 50, 10], center = true);
cube([10, 10, 50], center = true);
}
}
translate([0, 0, 5])
cylinder(h = 50, r1 = 20, r2 = 5, center = true);
}
}

example_intersection();
'''
import OpenSCADUtils, importCSG
doc=FreeCAD.activeDocument() or FreeCAD.newDocument()
obj = doc.getObject('OpenSCADPart')
if obj:
for o in App.getDependentObjects(obj.Group, 1):
doc.removeObject(o.Name)
doc.removeObject(obj.Name)

covert the above OpenSCAD script into CSG script

tmpfilename=OpenSCADUtils.callopenscadstring(scadstr,'csg')
try:
# remember the existing objects
objset = set(doc.Objects)
# import CSG file
importCSG.insert(tmpfilename, doc.Name)
# find all new objects
objs = [obj for obj in doc.Objects if obj not in objset]
# create a part contain to hold new objects
group = doc.addObject('App::Part', 'OpenSCADPart')
group.Group = objs
# recompute and adjust the view to include the newly created objects
doc.recompute()
Gui.Selection.addSelection(group)
Gui.runCommand('Std_ViewSelectionExtend')
Gui.Selection.clearSelection()
finally:
os.unlink(tmpfilename)`

Gives error `ModuleNotFoundError Traceback (most recent call last)
in
22 example_intersection();
23 '''
---> 24 import OpenSCADUtils, importCSG
25 doc=FreeCAD.activeDocument() or FreeCAD.newDocument()
26 obj = doc.getObject('OpenSCADPart')

~/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/OpenSCADUtils.py in
31
32 try:
---> 33 from PySide import QtGui
34 _encoding = QtGui.QApplication.UnicodeUTF8
35 def translate(context, text):

/Applications/FreeCAD_0.19-E.app/Contents/Resources/Ext/PySide/init.py in
1 # PySide wrapper
----> 2 from PySide2 import version
3 from PySide2 import version_info

/Applications/FreeCAD_0.19-E.app/Contents/Resources/lib/python3.8/site-packages/PySide2/init.py in
49 os.environ['PATH'] = path
50
---> 51 _setupQtDirectories()

/Applications/FreeCAD_0.19-E.app/Contents/Resources/lib/python3.8/site-packages/PySide2/init.py in _setupQtDirectories()
19 # loads the libraries into the process memory beforehand, and
20 # thus takes care of it for us.
---> 21 import shiboken2
22 # Trigger signature initialization.
23 type.signature

/Applications/FreeCAD_0.19-E.app/Contents/Resources/lib/python3.8/site-packages/shiboken2/init.py in
25 import typing
26
---> 27 from .shiboken2 import *
28
29 # Trigger signature initialization.

ModuleNotFoundError: No module named 'shiboken2.shiboken2'
`

@KeithSloan
Copy link
Author

changing initial block of code to add path to shiboken2 does not seem to fix
i.e.
`import sys, os

#JUPYTER_REPO_PATH = "/opt/jupyter_freecad/"
JUPYTER_REPO_PATH = "/Users/keithsloan/Jupyter_FreeCAD"

#sys.path.append("/opt/freecad/freecad_build/lib")
sys.path.append("/Applications/FreeCAD_0.19-E.app/Contents/Resources/lib")
sys.path.append("/Applications/FreeCAD_0.19-E.app/Contents/Resources/lib/python3.8/site-packages")
sys.path.append("/Applications/FreeCAD_0.19-E.app/Contents/Resources/lib/python3.8/site-packages/shiboken2")
sys.path.append(JUPYTER_REPO_PATH + "IPythonFreeCADViewer")

import FreeCAD, FreeCADGui
from pivy import coin
from freecadviewer import render_document, get_document_renderer

FreeCADGui.setupWithoutGUI()`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant