Viewing list of values associated with an object

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!
Post Reply
TedM
Posts: 142
Joined: Fri Apr 17, 2020 6:30 pm

Viewing list of values associated with an object

Post by TedM »

Note: this is probably a duplicate but I'm having trouble finding anything in a search, possibly because I don't know the right terminology.

I'm wanting to view a list of values associated with an object. For example, I have learned the xxx.Shape.BoundBox.XLimit gavies the width of an object (or maybe the width plus the X axis base). I'd like to be able to see what all there is below Shape, below BoundBox, etc.

I'm suspecting this is a Python snippet for the console or perhaps there is already a macro in the Addons Manager?

Any help or a pointer to an existing thread or page would be appreciated. Thanks
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Viewing list of values associated with an object

Post by TheMarkster »

You could use dir() in the python console.

dir(xxx.Shape.BoundBox)

['Center', 'DiagonalLength', 'XLength', 'XMax', 'XMin', 'YLength', 'YMax', 'YMin', 'ZLength', 'ZMax', 'ZMin', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'add', 'closestPoint', 'enlarge', 'getEdge', 'getIntersectionPoint', 'getPoint', 'intersect', 'intersected', 'isCutPlane', 'isInside', 'isValid', 'move', 'scale', 'setVoid', 'transformed', 'united']
TedM
Posts: 142
Joined: Fri Apr 17, 2020 6:30 pm

Re: Viewing list of values associated with an object

Post by TedM »

TheMarkster wrote: Wed Oct 21, 2020 7:34 pm You could use dir() in the python console.

dir(xxx.Shape.BoundBox)

['Center', 'DiagonalLength', 'XLength', 'XMax', 'XMin', 'YLength', 'YMax', 'YMin', 'ZLength', 'ZMax', 'ZMin', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'add', 'closestPoint', 'enlarge', 'getEdge', 'getIntersectionPoint', 'getPoint', 'intersect', 'intersected', 'isCutPlane', 'isInside', 'isValid', 'move', 'scale', 'setVoid', 'transformed', 'united']
I seem to be missing something. I went into Part WB and created a Cube. When I try

Code: Select all

>>> dir(Cube.Shape.BoundBox)
I get

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name 'Cube' is not defined
PMac
Posts: 135
Joined: Sat Sep 02, 2017 10:44 pm

Re: Viewing list of values associated with an object

Post by PMac »

TedM wrote: Wed Oct 21, 2020 10:01 pm NameError: name 'Cube' is not defined
Hi TedM,
Use the object FullName rather than the Label that shows in the treeview.
Note that a single Cube is actually a Part::PartFeature with an internal name of 'Box' - watch the bottom left corner of your FreeCAD window to see the internal name as you select an object in the treeview.

so we could use the following to see all properties:
box = App.ActiveDocument.getObject('Box')
dir(box)

also try the following to look at the internal name vs the screen label:
box = App.ActiveDocument.getObject('Box')
print(box.Label)
print(box.FullName)

another useful one for property values is the following (produces an XML listing)
box = App.ActiveDocument.getObject('Box')
print(box.Content)

Hope this helps.
Cheers.
TedM
Posts: 142
Joined: Fri Apr 17, 2020 6:30 pm

Re: Viewing list of values associated with an object

Post by TedM »

Thanks, PMac. That was what I was looking for.
Post Reply