A Tip on how to view data during development
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
A Tip on how to view data during development
We are always looking for good ways to view data, here is a way using Add properties. Make a new add property of string data and view it in the Properties panel, have your code update the property.
See pic; I update my new "Copy_camera" property with getcamera() data in realtime. It's really nice to see all the data easily as I rotate an object, zoom in/out and change views. I didn't format the data at all, it comes out this way from getcamera().
Obviously this could be used in many ways to view lots of string data without much effort. Could add a switch just for debug. The properties could be deleted after usage.
See pic; I update my new "Copy_camera" property with getcamera() data in realtime. It's really nice to see all the data easily as I rotate an object, zoom in/out and change views. I didn't format the data at all, it comes out this way from getcamera().
Obviously this could be used in many ways to view lots of string data without much effort. Could add a switch just for debug. The properties could be deleted after usage.
- Attachments
-
- y1.JPG (40.54 KiB) Viewed 3033 times
Last edited by freedman on Sun Aug 01, 2021 2:34 am, edited 1 time in total.
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: A Tip on how to view data during development
Nice! Does it update in realtime?
Edit: Sorry, skimmed over the point where you said it does
Edit2:
Edit3:
Edit: Sorry, skimmed over the point where you said it does
Edit2:
CC @marja1marja1 wrote:Heads up
Edit3:
HakanSeven12 wrote:Heads up
Joel_graff wrote:Heads up
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
- HakanSeven12
- Veteran
- Posts: 1481
- Joined: Wed Feb 06, 2019 10:30 pm
Re: A Tip on how to view data during development
Im using same method for Trails alignments. It saves ailgnment model dictionary as string then I can use it by using eval() function. Its very useful.
Support me: Hakan Seven on Patreon
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: A Tip on how to view data during development
That is pretty clever.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
-
- Posts: 436
- Joined: Wed Sep 15, 2010 9:38 am
Re: A Tip on how to view data during development
Thanks for the tip. Can you explain how you set the property? Do you use the expression engine? I tried but neither getcamera() nor eval are valid expressions for the expression engine.
Thanks,
Gaël
Thanks,
Gaël
Re: A Tip on how to view data during development
With an open document this will create the added property in the first valid object found. I don't use the expression engine so I don't have much feedback.
Code: Select all
doc = FreeCAD.ActiveDocument
if doc != None:
for obj in doc.Objects:
if obj.TypeId[:4] == 'Part':
####### to view the data
obj.addProperty("App::PropertyString","Camera_view_1")
obj.Camera_view_1 = Gui.ActiveDocument.ActiveView.getCamera()
####### or if you want to store the camera view without using a bunch of property view space
obj.addProperty("App::PropertyPythonObject","Camera_view_2")
obj.Camera_view_2 = Gui.ActiveDocument.ActiveView.getCamera()
break
-
- Posts: 436
- Joined: Wed Sep 15, 2010 9:38 am
Re: A Tip on how to view data during development
Thanks for the explanation but I'm still missing something: the properties do not update.
Re: A Tip on how to view data during development
The property needs to be updated by software.
If your interested here is a macro that uses the Properties panel as a display and an input device.
It creates two new properties in the first object/Body. The property called "Camera status" is read by the macro on a timer, if set to a "1" the camera property will be updated every 100 milliseconds, if set to "2" the properties are deleted and the timer stopped.
If your interested here is a macro that uses the Properties panel as a display and an input device.
It creates two new properties in the first object/Body. The property called "Camera status" is read by the macro on a timer, if set to a "1" the camera property will be updated every 100 milliseconds, if set to "2" the properties are deleted and the timer stopped.
- Attachments
-
- camera_prop1.FCMacro
- (1001 Bytes) Downloaded 56 times