Image scaling Macro

Need help, or want to share a macro? Post here!
User avatar
Chris_G
Posts: 874
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Image scaling Macro

Postby Chris_G » Tue May 08, 2018 3:01 pm

I replaced the pipe character with __or__()
It should work fine now.
User avatar
sliptonic
Posts: 1272
Joined: Tue Oct 25, 2011 10:46 pm

Re: Image scaling Macro

Postby sliptonic » Tue May 08, 2018 3:39 pm

Awesome. Thank you.
User avatar
easyw-fc
Posts: 2015
Joined: Thu Jul 09, 2015 9:34 am

Re: Image scaling Macro

Postby easyw-fc » Tue May 08, 2018 3:54 pm

this kind of issue could be overcome by this PR, linking long Macro code to GH
https://forum.freecadweb.org/viewtopic. ... 10#p232542
User avatar
easyw-fc
Posts: 2015
Joined: Thu Jul 09, 2015 9:34 am

Re: Image scaling Macro

Postby easyw-fc » Mon May 14, 2018 10:52 am

I was trying to add a Scale Macro button to the Image Workbench, but I noticed it is not a standard Python WB, so I'm stuck at adding a ToolBar to this WB to add the Macro to it..
If I try to add a Menu or a ToolBar in 'InitGui.py'

Code: Select all

    def Initialize(self):
        # load the module
        self.appendToolbar("Image Scale", ["Image_Scale"])
        self.appendMenu("Image Scale", ["Image_Scale"])        
        import ImageGui
I get the following error:
ImageWorkbench instance has no attribute '__Workbench__'
Could someone have an insight?
Thx
User avatar
easyw-fc
Posts: 2015
Joined: Thu Jul 09, 2015 9:34 am

Re: Image scaling Macro

Postby easyw-fc » Tue Jun 26, 2018 3:53 pm

Image Scaling Macro added to Image WB :D
https://github.com/FreeCAD/FreeCAD/pull/1527
chrisb
Posts: 11401
Joined: Tue Mar 17, 2015 9:14 am

Re: Image scaling Macro

Postby chrisb » Tue Jun 26, 2018 9:52 pm

Thanks for this. It is not in master (MacOS) yet, I will test if it is.
User avatar
easyw-fc
Posts: 2015
Joined: Thu Jul 09, 2015 9:34 am

Re: Image scaling Macro

Postby easyw-fc » Tue Jun 26, 2018 10:00 pm

chrisb wrote:
Tue Jun 26, 2018 9:52 pm
Thanks for this. It is not in master (MacOS) yet, I will test if it is.
It will be included after build release 0.18-13987 :)
chrisb
Posts: 11401
Joined: Tue Mar 17, 2015 9:14 am

Re: Image scaling Macro

Postby chrisb » Fri Jun 29, 2018 1:01 am

easyw-fc wrote:
Tue Jun 26, 2018 10:00 pm
It will be included after build release 0.18-13987 :)
Tried in Ubuntu: I'm unsure with the handling, and as it didn't work as expected I canceled the scaling. That made FreeCAD crash. I will try to reproduce tomorrow - here it's 3:00 a.m.
User avatar
easyw-fc
Posts: 2015
Joined: Thu Jul 09, 2015 9:34 am

Re: Image scaling Macro

Postby easyw-fc » Fri Jun 29, 2018 8:04 am

chrisb wrote:
Fri Jun 29, 2018 1:01 am
easyw-fc wrote:
Tue Jun 26, 2018 10:00 pm
It will be included after build release 0.18-13987 :)
Tried in Ubuntu: I'm unsure with the handling, and as it didn't work as expected I canceled the scaling. That made FreeCAD crash. I will try to reproduce tomorrow - here it's 3:00 a.m.
I can reproduce the crash:
1) import an Image Plane
2) launch the scaling tool
3) select first point
4) select last point
5) press cancel on the macro dialog
BUM!
here the error:

Code: Select all

Coin error in SoGroup::removeChild(): tried to remove non-existent child 0x5628f0a3fc50 (Switch)
Coin warning in SoEventCallback::removeEventCallback(): tried to remove non-existent callback function
Coin warning in SoEventCallback::removeEventCallback(): tried to remove non-existent callback function
('[Draft.todo.tasks] Unexpected error:', <type 'exceptions.TypeError'>, 'in ', <bound method SoCoordinate3.<lambda> of <bound method SoSFInt32.setValue of <bound method SoType.<lambda> of <bound method SoSFInt32.<lambda> of <bound method SoSFInt32.setValue of <bound method SoSeparator.<lambda> of <bound method OrderedDict.__setitem__ of <bound method WeakSet.__contains__ of <bound method WeakSet.add of <bound method WeakSet.add of <bound method WeakSet._commit_removals of <bound method Tokenizer.get of <bound method SubPattern.append of <bound method SubPattern.__setitem__ of <bound method SubPattern.__init__ of <bound method Tokenizer.get of <bound method SubPattern.append of <bound method Tokenizer.__next of <unbound method SubPattern.__init__>>>>>>>>>>>>>>>>>>>, '(', <pivy.coin.SoSwitch; proxy of <Swig Object of type 'SoSwitch *' at 0x7fb72b117d80> >, ')')Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7fb76e7daf20]
#1  /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x1aacef) [0x7fb7704c4cef]
#2  /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x16631c) [0x7fb77048031c]
#3  /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x1b3) [0x7fb7704f8c53]
#4  /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x1645f9) [0x7fb77047e5f9]
#5  /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_Call+0x43) [0x7fb77036e333]
#6  /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_CallObjectWithKeywords+0x47) [0x7fb7704f87a7]
#7  0x7fb74016f793 in PySide::SignalManager::callPythonMetaMethod(QMetaMethod const&, void**, _object*, bool) from /usr/lib/x86_64-linux-gnu/libpyside-python2.7.so.1.2+0x83
#8  /usr/lib/x86_64-linux-gnu/libpyside-python2.7.so.1.2(+0x15454) [0x7fb740176454]
#9  0x7fb76f2d20c6 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x626
#10  /usr/lib/python2.7/dist-packages/PySide/QtCore.so(+0x19c9cb) [0x7fb737bc89cb]
#11  0x7fb76f2d7be3 in QObject::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0xa3
#12  /usr/lib/python2.7/dist-packages/PySide/QtCore.so(+0x19c593) [0x7fb737bc8593]
#13  0x7fb76f7ea03c in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x8c
#14  0x7fb76f7f0f76 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2b6
#15  0x7fb77145c678 in Gui::GUIApplication::notify(QObject*, QEvent*) from /home/user/freecad-build/lib/libFreeCADGui.so+0x88
#16  0x7fb76f2bd8ad in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x8d
#17  /usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x1bd6e0) [0x7fb76f2f06e0]
#18  /usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x1ba851) [0x7fb76f2ed851]
#19  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2e7) [0x7fb768092287]
#20  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4c4c0) [0x7fb7680924c0]
#21  /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7fb76809254c]
#22  0x7fb76f2ee20e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x7e
#23  /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x272666) [0x7fb76f897666]
#24  0x7fb76f2bc12f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x3f
#25  0x7fb76f2bc495 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x1b5
#26  0x7fb76f2c2459 in QCoreApplication::exec() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x99
#27  0x7fb77140e5ac in Gui::Application::runApplication() from /home/user/freecad-build/lib/libFreeCADGui.so+0x15bc
#28  bin/FreeCAD(main+0x6db) [0x5628e90eb3cb]
#29  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7fb76e7bdb97]
#30  bin/FreeCAD(_start+0x2a) [0x5628e90ec57a]
I tried to add a try-except switch at the macro reject code, but no lucky...
yorik wrote:
Tue Jun 19, 2018 1:29 am
THe Image WB ...
@yorik, would you please have a look at?
Btw in windows FreeCAD_0.18.13990_x64_dev_win I get this error:

Code: Select all

Features from ImageTools package cannot be loaded. No module named ImageTools._CommandImageScaling
sgrogan wrote:
Thu Jun 28, 2018 9:29 pm
..ping
I think the 'ImageTools' folder should be copied to 'FreeCAD\Mod\Image' WB folder.

On win builds, after copying the folder, I can reproduce the same issue without a FC crash but with:

Code: Select all

Unhandled unknown exception caught in GUIApplication::notify.
Thx
chrisb
Posts: 11401
Joined: Tue Mar 17, 2015 9:14 am

Re: Image scaling Macro

Postby chrisb » Fri Jun 29, 2018 8:11 am

- new file
- change to Image workbench
- create image in 3D space, select a png, choose XY plane, offset 0mm (i.e. leave the defaults)
- zoom fit all
- click Scaling icon
- having no idea what Distance is asked for, enter 3mm anyway
- click in the image, a red line appears
- click outside of the image, the red line follows
- click cancel

FreeCAD crashes

OS: Ubuntu 16.04.4 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13990 (Git)
Build type: None
Branch: master
Hash: efdef0f6369ac207a2c748f01cd6e7e8ef7db3f0
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)

Edit: it took a bit of time, so my post is a bit late.