App::PropertyFileIncluded : edit this file with an external app

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

App::PropertyFileIncluded : edit this file with an external app

Post by flachyjoe »

Hi,
for my FCPD workbench, I include a Pure-Data file in a App::FeaturePython object (in order to have Pure-Data-controllable properties) but at document load this file is restored read-only.
Could exists a process to let user edit the file within PD and save change then FreeCAD store changed file :?:
- Flachy Joe -
Image
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: App::PropertyFileIncluded : edit this file with an external app

Post by openBrain »

Could you use a Std TextDocument for your purpose ?
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: App::PropertyFileIncluded : edit this file with an external app

Post by flachyjoe »

openBrain wrote: Wed Jun 23, 2021 9:10 am Could you use a Std TextDocument for your purpose ?
No I can't, even if it's a full text file, the edition have to be done with Pure-Data.

Code: Select all

#N canvas 390 209 890 581 12;
#X floatatom 230 490 5 0 0 0 - - -, f 5;
#X obj 230 550 fc_recompute;
#X obj 230 220 fc_translatePlacement;
#X msg 340 100 set \$1;
#X obj 230 10 bng 15 250 50 0 empty empty New\ Sketch 17 7 0 10 #fcfcfc
#000000 #000000;
#X obj 340 70 list;
#X obj 230 520 fc_setSketchConstraint diameter;
#X obj 230 309 fc_rotatePlacement;
#X obj 490 210 list cat;
#X obj 230 100 t a a a a a;
#X obj 460 240 list;
#X obj 460 10 bng 15 250 50 0 empty empty make\ Loft 17 7 0 10 #fcfcfc
#000000 #000000;
#X obj 230 130 fc_getObjectProperty Placement;
#X obj 230 340 fc_setObjectProperty Placement;
#X obj 640 10 bng 15 250 50 0 empty empty reset 17 7 0 10 #fcfcfc #000000
#000000;
#X msg 640 70 set Sketch;
#X msg 540 180 clear;
#X obj 230 70 fc_copy;
#X obj 710 300 list cat;
#X text 500 240 Sketches to loft;
#X text 720 330 All PD created objects;
#X obj 680 330 list;
#X msg 760 270 clear;
#X obj 640 34 t b b b b;
#X text 50 70 copy last created sketch;
#X text 90 190 translation vector;
#X text 110 280 rotation vector;
#X obj 310 280 fc_rotation 30 0 0;
#X obj 300 190 fc_vector 0 0 10;
#X text 280 490 new diameter;
#X obj 680 359 fc_delete;
#X obj 290 371 loadbang;
#X obj 290 400 timer;
#X msg 290 430 seed \$1;
#X obj 230 370 t b;
#X obj 230 459 random 50;
#X obj 460 331 fc_object Part Loft;
#X obj 460 300 list prepend Sections;
#X obj 460 270 fc_list;
#X obj 230 160 t a b;
#X obj 230 250 t a b;
#X msg 230 40 Sketch;
#X connect 0 0 6 0;
#X connect 2 0 40 0;
#X connect 3 0 41 0;
#X connect 4 0 41 0;
#X connect 5 0 3 0;
#X connect 6 0 1 0;
#X connect 7 0 13 0;
#X connect 8 0 10 1;
#X connect 9 0 12 0;
#X connect 9 1 13 1;
#X connect 9 2 5 0;
#X connect 9 3 6 1;
#X connect 9 4 8 0;
#X connect 9 4 18 0;
#X connect 10 0 38 0;
#X connect 11 0 10 0;
#X connect 12 0 39 0;
#X connect 13 0 34 0;
#X connect 14 0 23 0;
#X connect 15 0 41 0;
#X connect 16 0 8 1;
#X connect 17 0 9 0;
#X connect 18 0 21 1;
#X connect 21 0 30 0;
#X connect 22 0 18 1;
#X connect 23 0 15 0;
#X connect 23 1 16 0;
#X connect 23 2 22 0;
#X connect 23 3 21 0;
#X connect 27 0 7 1;
#X connect 28 0 2 1;
#X connect 31 0 32 0;
#X connect 32 0 33 0;
#X connect 33 0 35 0;
#X connect 34 0 35 0;
#X connect 35 0 0 0;
#X connect 36 0 18 0;
#X connect 37 0 36 0;
#X connect 38 0 37 0;
#X connect 39 0 2 0;
#X connect 39 1 28 0;
#X connect 40 0 7 0;
#X connect 40 1 27 0;
#X connect 41 0 17 0;
Capture d’écran_2021-06-23_11-58-30.png
Capture d’écran_2021-06-23_11-58-30.png (66.08 KiB) Viewed 1157 times
- Flachy Joe -
Image
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: App::PropertyFileIncluded : edit this file with an external app

Post by flachyjoe »

I think I've found a workaround:
  1. copy the temp file to a writable one
  2. watch for file changes with watchdog (external dependency, uh :? )
  3. when file change set the object property to the file created at 1. which cause FC to store it back
Time to code !

A question is still in suspend : where can I put a button to open the external editor?
- Flachy Joe -
Image
Post Reply