Drawing link object in a page with techdraw

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
DDM
Posts: 88
Joined: Tue Feb 05, 2019 9:06 am

Re: Drawing link object in a page with techdraw

Post by DDM »

Yes, this is my report view after I open the file....

Code: Select all

<PropertyLinks> PropertyLinks.cpp(774): Lost link to TR001_Beam_End_Plate_Drawing_V1 Link001 while loading, maybe an object was not loaded correctly
<PropertyLinks> PropertyLinks.cpp(774): Lost link to TR001_Beam_End_Plate_Drawing_V1 Link001 while loading, maybe an object was not loaded correctly
DVP::execute - No Sources (but document is restoring) - ProjItem002
DVP::execute - No Sources (but document is restoring) - ProjItem002
User avatar
s-light
Posts: 119
Joined: Thu Feb 12, 2015 11:39 am
Location: Germany, Hofheim am Taunus
Contact:

Re: Drawing link object in a page with techdraw

Post by s-light »

hey i just found out about the
<PropertyLinks> PropertyLinks.cpp(773): Lost link to export Link while loading, maybe an object was not loaded correctly
DVP::execute - No Sources (but document is restoring) - View
thing the hard way today ;-)
27 views all fine during alignment of the page - and all gone after lunch (closed FreeCAD) :lol:

to check what went wrong i created a minimal test case (in the attachment)
its just 3 files:
each linking on step more..
mypart.FCStd
assembly.FCStd
export.FCStd
Screenshot_20200404_222801.png
Screenshot_20200404_222801.png (368.13 KiB) Viewed 1209 times
the 'View001' is just freshly created - so the linked object is still there...
the source for this one is shown as 'assembly#Link (myPart)'

the view on the page in the assembly file does work.
but in the export file shows exactly the described behavior. (= Lost Link)
i think the problem is that it does read the linked object early enough and therefore the sub-objects are not available...?!


Code: Select all

>>> FreeCAD.Version()
['0', '19', '', 'https://code.launchpad.net/~vcs-imports/freecad/trunk', '2020/04/04 15:19:57']

OS: Ubuntu 19.10 (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.7.5
Qt version: 5.12.4
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
Attachments
mypart.FCStd
(19.45 KiB) Downloaded 54 times
export.FCStd
(18.86 KiB) Downloaded 49 times
assembly.FCStd
(19.3 KiB) Downloaded 52 times
User avatar
s-light
Posts: 119
Joined: Thu Feb 12, 2015 11:39 am
Location: Germany, Hofheim am Taunus
Contact:

Re: Drawing link object in a page with techdraw

Post by s-light »

i played a bit with python scripting and got a WorkAround:
i have the Labels of the sources used in my Labels of the Views -
and with a bit of magic i created a Macro that can read back this source Label and searches for the correct object in all linked objects and re-assings it..
its a hacky thing but for everyone that find it usefull i also added it as attachment - in combination with the script that does the 'source label view naming magic' ;-)
(time to setup a repository...)

maybe this scripts are helpfull...

sunny greetings
stefan
Attachments
slight_techdraw_relink_view_source.FCMacro
(2.51 KiB) Downloaded 56 times
slight_techdraw_auto_rename_views.FCMacro
(1.56 KiB) Downloaded 53 times
User avatar
wandererfan
Veteran
Posts: 6324
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Drawing link object in a page with techdraw

Post by wandererfan »

s-light wrote: Sat Apr 04, 2020 10:02 pm maybe this scripts are helpfull...
Maybe I am not using the macros correctly. I loaded document(s), ran "slight_techdraw_relink_view_source", then "slight_techdraw_auto_rename_views".

ProjItem003/Front002 still has no Source.

Code: Select all

<PropertyLinks> PropertyLinks.cpp(774): Lost link to TR001_Beam_End_Plate_Drawing Link001 while loading, maybe an object was not loaded correctly
<PropertyLinks> PropertyLinks.cpp(774): Lost link to TR001_Beam_End_Plate_Drawing Link001 while loading, maybe an object was not loaded correctly
5.6e-08 <App> Document.cpp(2718): Reload partial document Beam_End_Plate
DVP::execute - No Sources (but document is restoring) - ProjItem003
DVP::execute - No Sources (but document is restoring) - ProjItem003

------------------------------------------
doc: Beam+End_Plate
doc: TR001_Beam+End_Plate_Drawing
0.000587 <relink_empty_source> slight_techdraw_relink_view_source.FCMacro(64): found '3' objects
0.000163 <relink_empty_source> slight_techdraw_relink_view_source.FCMacro(75): no source for view 'Front002' found.

auto rename views:  0
Attachments
TR001_Beam+End_Plate_Drawing.FCStd
(11.22 KiB) Downloaded 52 times
Beam+End_Plate.FCStd
(27.48 KiB) Downloaded 50 times
DDM
Posts: 88
Joined: Tue Feb 05, 2019 9:06 am

Re: Drawing link object in a page with techdraw

Post by DDM »

I can confirm...
I tried also with the file "export" you posted...

My steps and messages from report view are:

1) open "export", message:
<PropertyLinks> PropertyLinks.cpp(774): Lost link to export Link while loading, maybe an object was not loaded correctly
111.774 <App> Document.cpp(2800): assembly#Link.LinkedObject: Time stamp changed on link mypart#Part
111.774 <App> Document.cpp(2718): Reload partial document assembly
DVP::execute - No Sources (but document is restoring) - View
DVP::execute - No Sources (but document is restoring) - View001
DVP::execute - No Sources (but document is restoring) - View
DVP::execute - No Sources (but document is restoring) - View001
2) execute "slight_techdraw_relink_view_source", message:
------------------------------------------
doc: mypart
doc: assembly
doc: export
0.000998 <relink_empty_source> slight_techdraw_relink_view_source.FCMacro(64): found '3' objects
0.000999 <relink_empty_source> slight_techdraw_relink_view_source.FCMacro(75): no source for view 'View001' found.
The mypart was updated, but view001 was not....

3) execute "slight_techdraw_auto_rename_views", message:
auto rename views: 2
Traceback (most recent call last):
File "C:/Users/didom/AppData/Roaming/FreeCAD/Macro/slight_techdraw_auto_rename_views.FCMacro", line 65, in <module>
rename_views()
File "C:/Users/didom/AppData/Roaming/FreeCAD/Macro/slight_techdraw_auto_rename_views.FCMacro", line 58, in rename_views
auto_rename_views(views)
File "C:/Users/didom/AppData/Roaming/FreeCAD/Macro/slight_techdraw_auto_rename_views.FCMacro", line 29, in auto_rename_views
label = view_get_source_label(view)
File "C:/Users/didom/AppData/Roaming/FreeCAD/Macro/slight_techdraw_auto_rename_views.FCMacro", line 23, in view_get_source_label
return view.Source[0].Label
<class 'IndexError'>: list index out of range
User avatar
s-light
Posts: 119
Joined: Thu Feb 12, 2015 11:39 am
Location: Germany, Hofheim am Taunus
Contact:

Re: Drawing link object in a page with techdraw

Post by s-light »

hm sorry i think i was not clear in my description..
the macro 'slight_techdraw_auto_rename_views.FCMacro' has to be used as long as all views are correctly displaying its sources.
it just renames the views Label to '(source.Label)_View'

and then if you repoen the file you can use the second macro 'slight_techdraw_relink_view_source.FCMacro'
- it gets the original source name from the view label - and searches for a object with the same label and then relinks it as source.

so in my example file 'export.FCStd' the second macro is working for the mypart_View but not for the View001 (as this has no sourceLabel in the Label...)

(and yes its a quick and dirty script with no error checking ;-))

hope the usage is now a bit clearer?!
DDM
Posts: 88
Joined: Tue Feb 05, 2019 9:06 am

Re: Drawing link object in a page with techdraw

Post by DDM »

Thanks Stefan for the explanation...
Now I can run the macro using your example "export" and the "Mypart" view is correctly updated...
I tried also to insert another view of "Mypart" and, after I rename the views, and tun the macro "relink" I can update the two views...

The problem is still in my example...I saw that you have two files, one for the Assembly and one for the Mypart...in my example I have all the parts in a single file and I think that the problem is in it....
Also you used a part container to collect the Assembly and the Mypart, while I used the LinkGroup to collect the parts...
Maybe this can be another reason...

I need to try other examples with your macros....

Many thanks to share the files...

Cheers,
Marco
User avatar
wandererfan
Veteran
Posts: 6324
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Drawing link object in a page with techdraw

Post by wandererfan »

Found a problem with the way the view Source items are saved/restored. May take a while to sort out.
DDM
Posts: 88
Joined: Tue Feb 05, 2019 9:06 am

Re: Drawing link object in a page with techdraw

Post by DDM »

I tried another example using Assembly4 workbench...
It is the same beam with two end plates.
In this example I created four file:

1) for the HEA beam (the part object must be in a part container for assembly4)
2) for the end plate (the part objcet must be in a part container for assembly4)
3) for the assembly (TR001)
4) for the drawing of the assembly TR001 and the single parts (HEA200 and EndPlates)

The macros of Stefan works fine....It can be possible to update the views when you reopen the file because the link of the TR001, HEA200 and PLT_200x180 are each in a single files, and the macro can reload the path of each file....

The problem remain if more links are in a single file (as the previous examples where TR001, HEA200 and Endplate were in the same file)..

Her attached the four files if you want to check....
Found a problem with the way the view Source items are saved/restored. May take a while to sort out.
Thanks Wandererfan...I could test all the examples when an update is ready...

Cheers, Marco
Attachments
Assembly4_HEA200+PLT_200x180.FCStd
(11.61 KiB) Downloaded 50 times
TR_HEA200.FCStd
(8.88 KiB) Downloaded 51 times
PLT_200x180.FCStd
(8.64 KiB) Downloaded 51 times
TR001_Assembly4_Test.FCStd
(9.66 KiB) Downloaded 49 times
User avatar
wandererfan
Veteran
Posts: 6324
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Drawing link object in a page with techdraw

Post by wandererfan »

DDM wrote: Mon Apr 13, 2020 3:43 pm Her attached the four files if you want to check....
This based on the last four files you provided and my current development version....

starting from Beam+End_Plate.FCStd
new page
new view PLT_200x180_Part
new view PLT_200x180_Part001
new view TR_HEA200_Part
new view TR001
save file
restore file
gives this:
BeamPlatePrintTest_restore.png
BeamPlatePrintTest_restore.png (37.25 KiB) Viewed 1052 times
This looks right to me, please advise.


TR001_Assembly4_Test will not work as the link info for the views has been lost when saved as
PropertyLinkList instead of PropertyXLinkList.

This is repairable by updating the Source and XSource properties of the various ProjGroups
and ProjItems. The TR001 ProjGroup required Python to reset Source property. The other
ProjGroups were updated by the property editor without issue. The result after repair, save and
restore looks like this:
TR001_Assembly4_Repaired_restored.png
TR001_Assembly4_Repaired_restored.png (29.55 KiB) Viewed 1052 times
This also looks right to me.

Now to try with the original test files.
Post Reply