To embed in Other Application
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
To embed in Other Application
I do not find the lib folder in stable release for FreeCAD.dll.
Please let me know if I am missing something here.
Please let me know if I am missing something here.
Re: To embed in Other Application
Do you want to integrate FreeCAD over its C++ interface or via Python? For the latter one you can use FreeCAD.pyd and/or FreeCADGui.pyd or any of the modules' .pyd files.
However, if want to go for C++ then you have to build FreeCAD on your own to have all the .lib files because they're not deployed with the MSI installer.
However, if want to go for C++ then you have to build FreeCAD on your own to have all the .lib files because they're not deployed with the MSI installer.
Re: To embed in Other Application
Thanks for quick reply!
I wanted to go for Python.....
Please let me know which of these path should work :
1). FREECADPATH = 'C:/Program Files (x86)/FreeCAD0.11/bin/'
or
2). FREECADPATH = 'C:/Program Files (x86)/FreeCAD0.11/bin/FreeCADGui.pyd'
sys.path.append(FREECADPATH)
import FreeCADGui
Thanks,
Manoj
I wanted to go for Python.....
Please let me know which of these path should work :
1). FREECADPATH = 'C:/Program Files (x86)/FreeCAD0.11/bin/'
or
2). FREECADPATH = 'C:/Program Files (x86)/FreeCAD0.11/bin/FreeCADGui.pyd'
sys.path.append(FREECADPATH)
import FreeCADGui
Thanks,
Manoj
Re: To embed in Other Application
Code: Select all
import sys,os,platform
if platform.architecture()[0] == '32bit':
# for 32-bit version
sys.path.append(os.environ["PROGRAMFILES"]+"/FreeCAD0.11/bin")
elif platform.architecture()[0] == '64bit':
# for 64-bit version
sys.path.append(os.environ["ProgramW6432"]+"/FreeCAD0.11/bin")
else:
raise Exception("Unsupported platform %s" % (platform.architecture()[0]))
import FreeCADGui
Re: To embed in Other Application
Thanks !!
However when I added last line to this code and tried:
I do not see anything coming up, just the messages:
and program terminates.
And I am not sure what to expect coming up on the screen.
Please let me know if I am moving in right direction .
However when I added last line to this code and tried:
Code: Select all
import sys,os,platform
if platform.architecture()[0] == '32bit':
# for 32-bit version
sys.path.append(os.environ["PROGRAMFILES"]+"/FreeCAD0.11/bin")
elif platform.architecture()[0] == '64bit':
# for 64-bit version
sys.path.append(os.environ["ProgramW6432"]+"/FreeCAD0.11/bin")
else:
raise Exception("Unsupported platform %s" % (platform.architecture()[0]))
import FreeCADGui
FreeCADGui.showMainWindow()
Code: Select all
FreeCAD 0.11, Libs 0.11r4206
Main Window Restored
Show Main Window
Toolbars Restored
And I am not sure what to expect coming up on the screen.
Please let me know if I am moving in right direction .
Re: To embed in Other Application
This works for me
The last line is needed to run the event loop which is needed for all applications using FreeCADGui that isn't based on the GTK, wxWidgets, Win32 or MFC toolkit. If the target application is based on one of these toolkits Qt is able to create a hook to the host application and gets its events from there.
Note:
When running exec_loop() the host application might be blocked. In case this happens to you and you don't want try running the exec_loop() function from a thread.
Code: Select all
import FreeCADGui
FreeCADGui.showMainWindow()
FreeCADGui.exec_loop()
Note:
When running exec_loop() the host application might be blocked. In case this happens to you and you don't want try running the exec_loop() function from a thread.
Re: To embed in Other Application
Thanks again!!!!
It worked!! of-course it had too
As I read through the tutorials, it is possible to embed the components into the wxWidgets(Python)...what I actually meant suppose I just want to pull the 3D parts only and hide all other components, even the File menu and the workbenches? Basically all the operations in background and show the Geometry only...much like an animation video...with custom controls realtime!
Thanks,
Manoj
It worked!! of-course it had too
As I read through the tutorials, it is possible to embed the components into the wxWidgets(Python)...what I actually meant suppose I just want to pull the 3D parts only and hide all other components, even the File menu and the workbenches? Basically all the operations in background and show the Geometry only...much like an animation video...with custom controls realtime!
Thanks,
Manoj
Re: To embed in Other Application
The best in this case is to make your own custom workbench in python. I this workbench you can remove all
menus and toolbars. This way you can have a complete empty FreeCAD.
menus and toolbars. This way you can have a complete empty FreeCAD.
Stop whining - start coding!
Re: To embed in Other Application
Thanks for the Idea...I do not know to add new workbench either
.....actually I intend to add it to the wxWidgets..it is more like testing the flexibility of FreeCAD.
Thanks,
Manoj
.....actually I intend to add it to the wxWidgets..it is more like testing the flexibility of FreeCAD.
Thanks,
Manoj
Re: To embed in Other Application
Create a new module directory under Mod and add a file InitGui.py with this content:
Code: Select all
class BlankWorkbench (Workbench):
MenuText = "Blank"
ToolTip = "Blank workbench"
def getMainWindow(self):
from PyQt4 import QtGui
toplevel = QtGui.qApp.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
def Initialize(self):
# Just a small test
import FreeCAD
FreeCAD.newDocument()
return
def GetClassName(self):
return "Gui::NonekWorkbench"
def Activated(self):
from PyQt4 import QtGui
mw = self.getMainWindow()
dw = mw.findChildren(QtGui.QDockWidget)
for i in dw:
i.toggleViewAction().setVisible(False)
mb = mw.findChildren(QtGui.QMenuBar)
for i in mb:
i.setVisible(False)
mw.statusBar().setVisible(False)
def Deactivated(self):
from PyQt4 import QtGui
mw = self.getMainWindow()
mb = mw.findChildren(QtGui.QMenuBar)
for i in mb:
i.setVisible(True)
mw.statusBar().setVisible(True)
Gui.addWorkbench(BlankWorkbench)