[solved] Showing Part.Plane

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

[solved] Showing Part.Plane

Post by stefankorisnik3 »

Given the code:

Code: Select all

plane = Part.Plane(p1, p2, p3)
Part.show(plane, "plane123")
error follows:

Code: Select all

 Part.show(plane, "plane123")
<class 'TypeError'>: argument 1 must be Part.Shape, not Part.Plane
Can you let me know how to solve this?
Tried this:

Code: Select all

planeObj = App.ActiveDocument.addObject('Part::Plane', "planeObj")
planeObj.Shape = plane
but error follows:

Code: Select all

<class 'TypeError'>: type must be 'Shape', not Part.Plane

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * CurvedShapes 1.0.3
  * Curves 0.5.2
Last edited by stefankorisnik3 on Sun Aug 07, 2022 4:22 pm, edited 2 times in total.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Showing Part.Plane

Post by onekk »

stefankorisnik3 wrote: Sun Aug 07, 2022 4:09 pm...
Simply Part.Plane has no Shape to be shown see this example code:

Code: Select all

import Part
from FreeCAD import Placement, Rotation, Vector  # noqa


p1 = Vector(-5, -5, 0)
p2 = Vector(5, 5, 0)
p3 = Vector(10,20,0)

plane = Part.Plane(p1, p2, p3)

print(plane.TypeId)

plane_ts = plane.toShape()

print(plane_ts.TypeId)

plane_do = Part.show(plane_ts, "Plane")

print(plane_do.TypeId)

The point is that Plane is as print(plane.TypeId) will show is Part::GeomPlane

Part.show() has to be feed with a Part::TopoShape so you have to transform it using .toShape()

Hope it helps.

Regards

Carlo D.


tested on:

Code: Select all

OS: Artix Linux (openbox)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: Italian/Italy (it_IT)
Installed mods: 
  * Curves 0.5.2
Last edited by onekk on Sun Aug 07, 2022 4:21 pm, edited 1 time in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: Showing Part.Plane

Post by stefankorisnik3 »

Thanks :)
Post Reply