View Issue Details

IDProjectCategoryView StatusLast Update
0000535FreeCADFeaturepublic2011-12-16 23:45
Reporterdanielfalck Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Fixed in Version0.13 
Summary0000535: request for python editible Properties panels
DescriptionIt would be nice to be able to alter the Properties view/data panels through python, such that one could remove some of the default entries.
For instance, if one wants to add a Point class in python, 'Line Color' is not needed and it would be nice to be able to remove it.

Thanks
TagsNo tags attached.
FreeCAD Information

Activities

yorik

2011-12-11 12:23

administrator   ~0001463

Actually you have the "Line Color" if you use a Part::FeaturePython object, which already comes with several properties such as LineColor, but also with a couple of handy builtin mechanisms such as auto view representation. If you start from an App::FeaturePython, you will have a totally empty object, with no default properties. But you will also need to build up your own coin representation.

See the Draft _Dimension and _ViewProviderDimension classes in Draft.py for example, they use the App::FeaturePython.

danielfalck

2011-12-11 14:54

reporter   ~0001464

That's exactly what I needed- thanks!

Let's close this issue.

wmayer

2011-12-11 20:23

administrator   ~0001465

Implementing from scratch is also possible but not so easy and a lot of work. I have added a method to set the type of a property.

To hide a property you can do this with:
ViewObject.setTypeOfProperty("LineColor",4)

wmayer

2011-12-11 20:23

administrator   ~0001466

Done in rev 5271

wmayer

2011-12-11 23:07

administrator   ~0001467

Too bad. The solution in rev 5271 has an ugly side-effect. Hiding an element causes to hide this attribute of ALL instances of this class. But this is not acceptable so I had to revert this commit.

So, the best solution is to follow Yorik's suggestion.

wmayer

2011-12-12 11:43

administrator   ~0001468

I found a better way out of this dilemma:

ViewObject.setEditorMode("LineColor",mode)

mode is a short int and meaning is:
0 -- default mode
1 -- read-only
2 -- hidden

This now works per object.

NOTE: The changes you made are not persistent. If you want it to be persistent you have to adjust your python wrapper class accordingly.

yorik

2011-12-12 12:49

administrator   ~0001469

Great addition Werner! thanks!

danielfalck

2011-12-16 21:38

reporter   ~0001487

Sorry to reopen this, but I can't get this one to work:
import Part,FreeCAD
from FreeCAD import Base
def makePoint(x=0.0,y=0.0,z=0.0, name= "Point",size = 7,color =(0.0,1.0,0.0)):
    obj = FreeCAD.ActiveDocument.addObject("Part::Vertex",name)
    obj.X=x
    obj.Y=y
    obj.Z=z
    obj.Placement=Base.Placement(Base.Vector(0.00,0.00,0.00),Base.Rotation(0.00,0.00,0.00,1.00))
    vp = obj.ViewObject
    mode = 2
    vp.setEditorMode("LineColor",mode)
    vp.setEditorMode('LineWidth',mode)
    vp.PointColor = (float(color[0]),float(color[1]),float(color[2]))
    vp.PointSize = size
    FreeCAD.ActiveDocument.recompute()
    return obj

p1 = makePoint()

wmayer

2011-12-16 23:45

administrator   ~0001488

Last edited: 2011-12-16 23:45

Oops, forgot to make the change also for the View tab. Fixed in rev 5317

Issue History

Date Modified Username Field Change
2011-12-11 00:33 danielfalck New Issue
2011-12-11 12:23 yorik Note Added: 0001463
2011-12-11 14:54 danielfalck Note Added: 0001464
2011-12-11 20:23 wmayer Note Added: 0001465
2011-12-11 20:23 wmayer Note Added: 0001466
2011-12-11 20:23 wmayer Status new => closed
2011-12-11 20:23 wmayer Resolution open => fixed
2011-12-11 20:23 wmayer Fixed in Version => 0.13
2011-12-11 23:07 wmayer Note Added: 0001467
2011-12-12 11:43 wmayer Note Added: 0001468
2011-12-12 12:49 yorik Note Added: 0001469
2011-12-16 21:38 danielfalck Note Added: 0001487
2011-12-16 21:38 danielfalck Status closed => feedback
2011-12-16 21:38 danielfalck Resolution fixed => reopened
2011-12-16 23:45 wmayer Note Added: 0001488
2011-12-16 23:45 wmayer Status feedback => closed
2011-12-16 23:45 wmayer Resolution reopened => fixed
2011-12-16 23:45 wmayer Note Edited: 0001488