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
Viewing list of values associated with an object
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Viewing list of values associated with an object
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']
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']
Re: Viewing list of values associated with an object
I seem to be missing something. I went into Part WB and created a Cube. When I tryTheMarkster 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']
Code: Select all
>>> dir(Cube.Shape.BoundBox)
Code: Select all
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'Cube' is not defined
Re: Viewing list of values associated with an object
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.
Re: Viewing list of values associated with an object
Thanks, PMac. That was what I was looking for.