TechDraw Template Autocompletion

With the tutorial in the wiki I have now a very nice custom template for drawings which I am very fond of. :smiley:

Now I have looked for ways to automatically fill in some of those fields. Obvious candiates would be

  • sheet number
  • filename
  • scale
  • creation date
  • author

I found this post about changing it from script, but this was for a different use case.

I am looking for those values being filled automatically every time when I load a template for a file. Did anyone achive something like this and can tell how this can be done?

Mod edit: Moved thread to TD subforum

  1. No ETA.

Relatedly I have been looking at trying to simplify the filling in of a template
from a spreadsheet, which inturn is auto filled from defaults, using a Macro. I would like to know if I am
approaching this the correct way or so if someone has already done this, or more probably neater/better way, before?

Some of the problems still to be solved, in no particular order

  1. Ensuring that each page is automatically associated with a specific spreadsheet, without having
    obtain the page number/same in macro.

  2. Is it possible to copy/paste and attach User_info to a page, rather than overall file.

  3. Make spreadsheet more general by Auto loading with system known parareters, e.g. user name, pagesize, part weight but still allow
    included file to be edited

  4. Extend for Assembly drawings

  • plenty of others..


    Many Thanks

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22111 (Git)
Build type: Release
Branch: master
Hash: cb2099aa6bb287a8d7843eb70684cce79bdef26b
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
dut_Drawing_Update_template.FCMacro (2.96 KB)
fitting2_demo.FCStd (691 KB)

interesting approach. How do you generate the spreadsheet in the first place? For example if you need to generate a new part, starting with a blank sheet, where does it take its data from?

Currently working with ‘startparts’, with spreadsheets/associated drawings, material,… etc preset,
so that when you select new part, via a macro, it loads it and then changes the filename etc.
so that you don’t override etc. Thus the basic spreadsheet is pre-loaded, however as noted still not sure how to generate for multiple drawing sheets, although I am thinking as a backup to store the info in the spreadsheet and get the macro to cope with finding the
correct template

Best Wishes

When swapping the template to another one with the property field value Tempalte/Template today all edited filed parameters are lost.
Since the data has been added manually and is stored in TechDraw, is that situation something to not thow away the edited values, so if a new template is loaded (that likely has the same value names) the stored values could be applied?

Use case: Allows to switch format any time.
Description: When “MyFormat_A4” is getting too small, its possible to switch to “MyFormat_A3” without loosing all edited data. This is because its very likely that most people use in all “MyFormat” templates the same fields.

This would be nice. The first obstacle is that there is no guarantee the field names in template A are the same as the field names in Template B.

This could be done via a 2 part macro along these lines:

# part1:  macro to save values
>>> p = App.ActiveDocument.Page
>>> t = p.Template
>>> fieldDict = t.EditableTexts
## save fieldDict somewhere

# change templates

## part2:  macro to replace values
# retrieve fieldDict from somewhere 
>>> fieldDict['AUTHOR_NAME'] = 'James Bond'
>>> t.EditableTexts = fieldDict

That is true, but if some are not present, nothing is lost except a few bytes unused data. If the behaviour is know, however its easy for people doing their own templates to just use the same names. And I guess, most people who are serious about their models are going to customize the default templates anyway.

I’ll check out the code, thanks

Let’s think at the higher level.

Should there be a concept of TechDraw “documents/workbooks”? Could anyone provide a use case where user would want a single TechDraw page, say sheet 19 of 30 designed in FreeCAD?

Are there any standards/file formats of technical drawing documents other than sheet-level graphical symbols like title block, line width, dimensions, etc?

Is it realistic to prepare all technical drawings in FreeCAD?

Depending on the answers, we could design a “workbook” object which would have a single template and guarantee field names to be the same, provide automatic numbering, the title page, legends, consistent scale, and so on

In addition, it’s possible to ship embedded templates, where field names are standardized. Or we could validate templates and force users to design them so that they have predefined fields

Unfortunately, I have a feeling that FreeCAD has a different philosophy - it doesn’t help users with enforcing standards or consistency. Instead, FreeCAD provides some tooling on top of which you build your own software. I think this philosophy sucks

I agree with you here. Damn right, and it’s a pity.

That’s not necessarily because we don’t want to, but because the effort to do so is high. If you want to move towards that direction, your contributions to do so would be appreciated.

Please don’t quote complete posts. We don’t want to read everything twice. Cite only what you are directly referring to. You may elaborate what models you are doing and where exactly it would help.

Good to hear. So, the simplest solution could be:

  • Create a root TechDraw document/workbook class/object
  • Modify getters of TechDraw page fields to check whether they have a document parent and return the fields from parent
  • If there’s a parent, make certain fields of a page read-only/hidden. Possibly with an option to override.
  • Add actions/buttons/menus to rearrange the order of TechDraw pages
  • Display the page number in the object tree

Extra feature: display all the pages in a single MDI tab with Next/Prev page buttons.
After that: print all the pages in a single PDF. Possibly with ability to select page ranges to print
Somewhere in the future: deprecate rootless pages.

Sounds reasonable/doable?

Sorry. I edited the post now.

https://forum.freecadweb.org/viewtopic.php?f=35&t=31681&start=20#p335949