View Issue Details

IDProjectCategoryView StatusLast Update
0004403FreeCADFeaturepublic2021-02-06 06:49
Reporterferdymercury Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Target Version0.20 
Summary0004403: import PRC file or 3D PDF into FreeCAD
DescriptionThis is a follow up the suggestion I made in the forum.

PRC files are commonly used by several vendors to embed 3D models in a PDF file. Unfortunately, these files can only be opened with Adobe PDF reader. For example, Linux does not have a native Adobe viewer, which means it is impossible to view correctly this type of documents. One needs some workarounds (Wine, Virtualbox, or old Adobe versions for Linux).

I thought that in general, not only for Linux users, it would be nice if FreeCAD would be able to import PRC files in the same way it imports STEP files. (Also including nested parts in the tree model).

It is easy to extract the embedded PRC file from the 3D PDF, by just searching for 'stream.PRC' and 'endstream' bytes in a hex editor, so in principle this could be done automatically also by FreeCAD. Everything inbetween is the PRC binary file that can be extracted, and for example included in your own PDF with pdflatex media9 package.

Thinking about a 'far future', if FreeCAD is able to open and import it, this would allow in the future that Linux PDF viewers display inline also 3D models, by embedding a small FreeCAD plugin directly, instead of having to open it in external FreeCAD window. In the same way than Adobe PDF reader has a Flash Player plugin to do that.

To implement this feature, one might reuse some parts of this code: https://github.com/XenonofArcticus/libPRC

The PRC file format is defined [url=https://web.archive.org/web/20091123055411/http://pdf.editme.com/files/PDFE/SC2N570-PRC-WD.pdf]here[/url].

Other posts related to generating PRC files from a FreeCAD model:
https://forum.freecadweb.org/viewtopic.php?t=20224&start=10
https://forum.freecadweb.org/viewtopic.php?f=8&t=18497#p144546
(This is the opposite direction than the feature requested here)
Steps To Reproduce
  • Download https://tetra4d.com/wp-content/uploads/2015/04/3D-PDF-Sample-Outlet.pdf
  • Open it with Bless hex editor or equivalent
  • Search for PRC keyword (search option Text, not Hex).
  • Select and delete in the hex editor from beginning of document until & including line above, containing keyword 'stream', so that first three bytes of the resulting file are 'PRC'.
  • Search for 'endstream' keyword. Delete from (including) this line until the end of the document.
  • Save result as .prc
  • In a Latex document, you can include it with
  • 
    \usepackage{media9}
    ...
    \includemedia[
      %label=dice, % name for referencing 3D object
      width=\linewidth,
      height=0.495\linewidth,
      3Dtoolbar,
      3Dmenu
      %activate=pagevisible,
      %3Dcoo=13.514159202575684 -210.37330627441406 265.50933837890625,
      %3Dc2c=-0.6669085025787354 0.39916229248046875 0.6292078495025635,
      %3Droo=9603.325257430366,
      %3Droll=-110.37121928895962,
      %3Dortho=0.001394091872498393,
      %3Dlights=Cube
      ]{}{result.prc}
    
  • Compile with pdflatex, and open it with Adobe PDF Reader

(Side note: if a 3D PDF file has several 3D models embedded, this has to be done in a for loop. Or the user has to select in the import dialog one among those)
 
%
%
Tagsconversion, file format, import, STEP
FreeCAD InformationOS: Linux Mint 19.3 (MATE/mate)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21775 (Git) AppImage
Build type: Release
Branch: master
Hash: 1f741aa511e898849e46ed14515fce416fe32acb
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)

Activities

ferdymercury

2020-07-08 14:13

reporter   ~0014636

The following link is more updated than the one from libPRC I posted before.
https://github.com/vectorgraphics/asymptote/tree/50fb809fdaf2383385f09884174262964a046156/prc

One could expand the code in asymptote repository and write the functions in the opposite direction (Deserialize, Read) instead of (Serialize, Write). So that Asymptote library could be used as an 'intermediary'. Then, one would 'only' need to convert Asymptote structure to FreeCAD structure.

See also:
https://forum.freecadweb.org/viewtopic.php?t=156

wmayer

2020-12-10 16:49

administrator   ~0015124

https://forum.freecadweb.org/viewtopic.php?f=8&t=53116

ferdymercury

2020-12-10 16:54

reporter   ~0015125

See also: https://github.com/vectorgraphics/asymptote/issues/167

yorik

2022-03-03 13:55

administrator   ~0016923

This ticket has been migrated to GitHub as issue 6090.

Issue History

Date Modified Username Field Change
2020-07-08 13:54 ferdymercury New Issue
2020-07-08 13:57 ferdymercury Tag Attached: STEP
2020-07-08 13:58 ferdymercury Tag Attached: file format
2020-07-08 13:58 ferdymercury Tag Attached: conversion
2020-07-08 14:13 ferdymercury Note Added: 0014636
2020-07-08 15:43 Kunda1 Tag Attached: import
2020-12-10 16:49 wmayer Note Added: 0015124
2020-12-10 16:54 ferdymercury Note Added: 0015125
2021-02-06 06:49 abdullah Target Version => 0.20