How can I reset the placement properties?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: How can I reset the placement properties?

Post by mario52 »

hi
jmaustpc wrote:then make a duplicate (edit menu duplicate)
that was the idea but with copy

@sangdth
this little macro puts parameter of the selected object to zero

Code: Select all

import FreeCAD,Draft
def zero():
    sel = FreeCADGui.Selection.getSelection()
    try:
        App.ActiveDocument.getObject(sel[0].Name).Placement=App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(0,0,1),0), App.Vector(0,0,0))
    except Exception:
        App.Console.PrintError("Select one object" + "\n")
zero()
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
sangdth
Posts: 8
Joined: Sat Sep 13, 2014 11:25 am
Location: Helsinki
Contact:

Re: How can I reset the placement properties?

Post by sangdth »

Hei, the refine shape feature is enough for me. So I think we can stop here :D

Thank you jmaustpc, wmayer, shoogen, mario52... I saved all your codes, and will read it later when I have time to learn. (I'm not good at coding.)
www.Makr.fi - Makerspace for doers in Helsinki
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: How can I reset the placement properties?

Post by easyw-fc »

wmayer wrote: Sun Sep 14, 2014 1:24 pm The cleanest way is to apply the placement on the children and use the method replaceShape.
I know I'm on an old thread, but the issue has came out only on FC 0.20 releases and above and I discover it only recently...

Importing a multi object STEP model, using the 'Enable STEP compound merge' option, and trying to reset the placement of the imported shape, FC will trig an error in the console.

Here the code and the testing file:

Code: Select all

import ImportGui
ImportGui.open(u"D:/Temp/User Library-LTST-S270KGKT.step")
s=App.ActiveDocument.ActiveObject.Shape
r=[]
t=s.copy()
for i in t.childShapes():
  c=i.copy()
  c.Placement=t.Placement.multiply(c.Placement)
  r.append((i,c))

w=t.replaceShape(r)
w.Placement=App.Placement()
Part.show(w)
User Library-LTST-S270KGKT.step
(143.52 KiB) Downloaded 10 times
and the error in the panel:

Code: Select all

15:49:24  <Part> ViewProviderExt.cpp(1268): Cannot compute Inventor representation for the shape of Unnamed#Shape: BRepAdaptor_Curve::No geometry
15:49:24  <Part> ViewProviderExt.cpp(1268): Cannot compute Inventor representation for the shape of Unnamed#Shape: BRepAdaptor_Curve::No geometry
This behavior is not appearing in FC 0.19.4 or in FC Link Daily 2022.1128.

Here my FC release version info:

Code: Select all

OS: Windows 10 Version 1909
Word size of FreeCAD: 64-bit
Version: 0.21.0.31513 (Git)
Build type: Release
Branch: master
Hash: b2ab8edba4bfd71681e639f8c3f1105066bed4c7
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: How can I reset the placement properties?

Post by wmayer »

Works fine for me with

Code: Select all

OS: Ubuntu 22.04.1 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.0.31567 (Git)
Build type: debug
Branch: master
Hash: 5b1c781b8ddb3c38a8c6121c9aafd590610a0578
Python 3.10.6, Qt 5.15.3, Coin 4.0.0, Vtk 7.1.1, OCC 7.5.1
Locale: German/Germany (de_DE)
I have tested your code with the option Enable STEP compound merge on and off and in both cases it works as expected.

Do your v0.20 and v0.21 use both the same OCC version? Which OCC version does FC Link Daily 2022.1128 use?
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: How can I reset the placement properties?

Post by easyw-fc »

wmayer wrote: Fri Jan 13, 2023 12:42 pm Do your v0.20 and v0.21 use both the same OCC version? Which OCC version does FC Link Daily 2022.1128 use?
here my FC releases info:

FC Link Daily 2022.1128 (no issue)

Code: Select all

OS: Windows 10 Version 1909
Word size of FreeCAD: 64-bit
Version: 2022.1128.26244 +5318 (Git)
Build type: Release
Branch: LinkDaily
Hash: d45d221edcc7a757eb4e4eb638da0db5ed2759aa
Python version: 3.10.8
Qt version: 5.15.4
Coin version: 4.0.1
OCC version: 7.6.3
FC 0.21 31513 -> I have issues

Code: Select all

OS: Windows 10 Version 1909
Word size of FreeCAD: 64-bit
Version: 0.21.0.31513 (Git)
Build type: Release
Branch: master
Hash: b2ab8edba4bfd71681e639f8c3f1105066bed4c7
Python 3.10.8, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
FC 0.19.4 (no issue)

Code: Select all

OS: Windows 10 Version 1909
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +148 (Git)
Build type: Release
Branch: Branch_0.19.4
Hash: 476ecf091941bead59b14e44afa6064d5a66afa3
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
I'm pinging also @Shack who reported this issue for my WB code
Shack wrote: Wed Oct 16, 2019 8:30 pm pinging ...
Shack
Posts: 35
Joined: Thu Jun 22, 2017 6:19 pm

Re: How can I reset the placement properties?

Post by Shack »

As Maui pointed out, it only happens for me when Enable STEP compound merge is on.

Code: Select all

OS: Ubuntu 22.04.1 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.1.
Build type: Release
Branch: unknown
Hash: 22f524c0c755003c12234fab1bad6a9f696b661a
Python 3.10.6, Qt 5.15.3, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.1
Locale: English/United States (en_US)
Installed mods: 
  * Manipulator 1.4.9
  * Defeaturing 1.2.0
  * kicadStepUpMod 10.16.5
Post Reply