[Solved] translate object without GUI

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
rluq
Posts: 14
Joined: Tue Apr 12, 2022 6:24 pm

[Solved] translate object without GUI

Post by rluq »

I am using translate method from DraftTools module.

However when I try to run my script by python interpreter (not from FreeCAD) it gives me the following error:

File "C:my_script.py", line 4, in <module>
from DraftTools import translate
File "C:\FreeCAD 0.19\bin\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
return original_import(name, *args, **kwargs)
File "C:\FreeCAD 0.19\Mod\Draft\DraftTools.py", line 51, in <module>
import DraftGui # Initializes the DraftToolBar class
File "C:\FreeCAD 0.19\bin\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
return original_import(name, *args, **kwargs)
File "C:\FreeCAD 0.19\Mod\Draft\DraftGui.py", line 2231, in <module>
FreeCADGui.draftToolBar = DraftToolBar()
File "C:\FreeCAD 0.19\Mod\Draft\DraftGui.py", line 196, in __init__
self.uiloader = FreeCADGui.UiLoader()
AttributeError: module 'FreeCADGui' has no attribute 'UiLoader

How could I do translate operation without GUI?
Last edited by rluq on Fri May 27, 2022 9:20 pm, edited 1 time in total.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: translate object without GUI

Post by Roy_043 »

Code: Select all

obj.Placement.translate(App.Vector(1, 2, 3))
or

Code: Select all

obj.Placement.Base = App.Vector(1, 2, 3)
rluq
Posts: 14
Joined: Tue Apr 12, 2022 6:24 pm

Re: [Solved] translate object without GUI

Post by rluq »

Thank you for your answer, Roy_043!
Post Reply