Pantograph: ANOTHER vector rendering engine

>Are you running Linux? In theory all of this stuff is portable to OSX and Windows,
> but I haven’t crossed that bridge - I would love to get a cross-platform tester.

Yes Im running linux. Im looking forward to you program. Please post it asap. Im eagger to try it.

One thing to add:
To work further with the outputted vector drawing, I use inkscape. In inkscape there is a Find capability, which find all the xml nodes, which contain certain character.
For example: If you colour all the triangles which forms a face with the same hexa colour, in inkscape you can quickly select all of this, and move for example to an another layer, or union it, change the line width, style, etc.

So I think its essential to identify surfaces of an object.

So I willing to test this process, so looking forward for this exporter. Maybe I will cook up a tutorial about the process.

I d like to encourage the people behind this project !
It is a very interesting idea: i had never thougt of such a rendering engine.

All the best !

khiraly1-

I was looking at the Inkscape “Find” tool, but I wasn’t sure how to make it work.

The biggest problem right now is that things are rendered with the “painter’s algorithm” - layered in the correct order, but still broken up into triangles/ short line segments. This tends to produce unnecessarily bulky vector files… I’m looking at ways of optimizing it for vector output (removing hidden objects, combining lines of the same weight and color), but that’s a little ways off.

RS

can you post some .svg file, what you have exported?
I want to try with inkscape.

The find tool basically works, like finding the xml nodes by the term what you typed into the dialog.

Example:
Here is a simple line definition in xml dialect:


<line
       id="line21989"
 style="fill:none;stroke:#126723;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       y2="281.90201"
       x2="517.90698"
       y1="283.52301"
       x1="513.789" />

This is a line from (x1,y1) to (x2,y2) with a color #126723.
Now if you use the inkscape’s find tool, you can search for:


stroke:#126723

And will find all the lines with the same color. Is it make more sense now rocketship?

If you have a sample .svg file, its really more easier to explain and play with.

(if you have selected all the triangles with the same color, you can union them, and the .svg file is simplyfied! I think the simplification should be done in inkscape. Just separate the face with given colors)

khiraly1,

Here’s a link to an svg file (I hope)…take a look. The line quality is not so good - with the separate line segments, it ends up looking very messy when you zoom in.

http://home.earthlink.net/~severnclay/reprap.svg

RS

The main problem with this file, that it is impossible to distinguish the faces of the object. We NEED different colors for different faces. See my .svg (which was linked in the previous page) for an example.

Can you colorize the faces of the object? I would like to try that one.

Please …

khiraly1,

One could color the faces manually in Blender, but that starts to become a very manual proposition. I think I know how to make it combine faces and line segments together - I just need to code it. Next version!

In the mean time, I’ve finally posted the code:

Give it a spin, but be gentle! Start with pretty simple geometry.

RS

Fixed a bug that was causing ortho view to render in reverse order.

RS

very interesting project…!

It will have many application in design, I mean, not only in cad related design. I’d certainly find it very useful, I guess.

I’m having problems installing cgkit I think. Here’s the error I get when I run Pantograph from the scripts menu…


Traceback (most recent call last):
  File "<string>", line 46, in ?
  File "/home/gary/.blender/scripts/bpymodules/pantographLib.py", line 39, in ?
    from cgkit.cgtypes import vec3,mat3,vec4,mat4,setEpsilon
ImportError: No module named cgkit.cgtypes

secundar,

cgkit is a bear to install; they don’t give you much in the way of guidelines Were you able to successfully compile cgkit? A few other things to check:

-On my system (Ubuntu Feisty), cgkit installs to /usr/lib/python2.5/site-packages, while my Blender install is using python 2.4. I made a link in /usr/lib/python2.4/site-packages to the cgkit lib directory. Try:

locate cgtypes

and see what it says. To make a link, you would do:

ln -s /usr/lib/python2.5/site-packages/cgkit /usr/lib/python2.4/site-packages/cgkit

Getting cgkit to compile is definately the first thing, though - the ‘lite’ version won’t do. If you’re having trouble, make sure you have the ‘dev’ packages for c++, etc installed.

RS

Thanks for your patience. I realize I didn’t bother to detail my system… which happens to be Ubuntu Feisty also. Yeah, cgkit install was pretty vague. I slogged through with just the minimum (not knowing what to edit in the config file).

The link did the trick. It runs! Pretty nice. Now I just need time to play.

I think it may have already been mentioned but I think grouping or otherwise combining segments would make further editing in Inkscape easier. Excellent work though, thanks for another renderer.

secundar,

Thanks for testing - I’m glad you got it running! I was worried my instructions were unbearably vague.

Yes, some way of optimizing the final vector file is definately needed.

RS

Hi rocketship!

I have downloaded your code, but Im unable to see it in blender.
I have followed your instructions, but surely I miss something. Here is what I have done:

  • downloaded thesource code and unzipped it
  • change the HOMEDIR variable in pantographLib.py
  • copy the pantographLib.py from the installed directory(/home/user/Desktop/down/pantograp) to ~/.blender/scripts/bpymodules/ (needed to be root, because bpymodules directory is a symlink to /usr/lib/blender/scripts/bpymodules directory)

Im unable to see your script (name is pantograph?) in blender. I switched to script window, but there is no pantograph. In which group pantograph supposed to be, Export?

I dont know why ~/.blender/scripts/bpymodules was mentioned by secundar. (is it a symlink to a system installed directory where a user dont have an access).
Please help me out. Im a newbie in blender scripting.

Ok, need to copy the pantograph.py too;)
But I have the same error as secundar.
cgkit2:
http://downloads.sourceforge.net/cgkit/cgkit-2.0.0alpha7.tar.gz?modtime=1160478250&big_mirror=0

Is it a .deb package of it? Or how can I create one? (I never managed to create a .deb package from a python program. (where there is no make, but python setup.py install). )

I know this is abit offtopic, but Im really curious how to do it. Need a .deb package or an instruction to how to create it.

Thank you for the source code (and sorry for the late reply) rocketship!

khiraly1,

No, you have to compile it for your machine…if your’re running Linux, this is an important skill to acquire! You need the full cgkit package, not just the “lite” version.

Take a look at the installation instructions for cgkit - I can sort of walk you through it.

What sort of Linux are you running?

RS

Khiraly1,

This should make you happy:
reprap3.svg

I still have some problems with not all the polylines joining together and a few mysterious random missing segments, but check out the file size! Its about 1/20 of the original non-optimized file.

RS

@rocketship:
I downloaded your script and tried it with Blender 2.45 under win32 & linux, but I don’t get a SVG output, only a file with the svg header, any ideas?

Thomas

automatic-BRAIN,

That’s interesting… what does the svg header say? Do you have Cairo installed (though I don’t think you could run it without)? Are you getting any error messages in the terminal?

On the other hand, you got it to run in win32! That’s fantastic - everything else seems to work (you get a GUI?)

RS

This is the content of the svg file:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="800pt" height="600pt" viewBox="0 0 800 600" version="1.1">
<defs>
<clipPath id="clip0">
  <rect width="800" height="600"/>
</clipPath>
</defs>
<g id="surface0" clip-path="url(#clip0)">
</g>
</svg>

Yes, cairo is installed, this is the output after loading pantograph:

Compiled with Python version 2.5.
Checking for installed Python... got it!
scene.getCurrentCamera() deprecated!
        use scene.objects.camera instead
near:0.100000 far:100.000000 top:-0.033315 bottom:0.03331
0.044420 fovy:36.850757 aspect:1.333333
('Processing mesh Cube',)
scene.link(ob) deprecated!
        use scene.objects.link(ob) instead
('Processing materials...',)
('Triangulating faces...',)
('Processing vertices...',)
('Processing edges...',)
('Processing 12 faces...',)
('Building mesh...',)
('Appending mesh to scene...',)
scene.unlink(ob) deprecated!
        use scene.objects.unlink(ob) instead
('Writing materials to Pen Settings...',)
C:\Blender Foundation\blender-2.45-windows\blender.exe:13

  hè¿ ☼À♦A%♥☺  ├j  tÞä   YY├Uïýâý► u♀ìM*ÞB┘  ïE*⩼   ☺~‼
☼Â♦HâÓ☺Ç}³ tïM°âap²╔├â=êÀ╝  u↕ïD$♦ï
C:\Blender Foundation\blender-2.45-windows\blender.exe:14

  ╗  ├j♦ÞÕ¢  Y├Uïlâ²Ó☼çƒ   Sï↔─┬ù VW3÷95╠Á╝ ï²u↑Þ|½  j▲Þı
u♫;¯t♦ï┼Ù♥3└@PÙ▲â°♥u♂UÞS   ;ãYu↨;¯u♥3 GâÃ☼âþ*WV 5╠Á╝  Ëï*
C:\Blender Foundation\blender-2.45-windows\blender.exe:14

  ïE►;Ãt♠à ♀   ï├Þ ╣  ├UïýQâe³ WìE³P u♀ Þ╩■  ï°â─♀à u↓Vïu
_╔├j►hH7º ÞÅ©  ïà█u♫ u♀Þ┼²  YÚ╠☺  ïu♀à÷u♀SÞs╠  YÚÀ☺  â=ê3
j♦ÞE╝  Yë}³SÞvÞ  YëEÓ;Ã☼ä×   ;5x3Ð wIVSPÞOÝ  â─♀à└t♣ë]õÙ5
ãPS uõÞ!ı  SÞ&Þ  ëEÓSPÞGÞ  â─↑9}õuH;¸u♠3÷Fëu♀âã☼âµ*ëu♀VW 
ãr☻ïãPS uõÞ═È  S uÓÞ·þ  â─¶ÃE³■   Þ.   â}Ó u1à÷u☺Fâã☼âµ*ë
u♀ïj♦Þx║  Y├ï}õà ☼à┐   9=ý║╝ t,VÞ Ã  Yà└☼àÊ■  Þ═╝  9}Óulï
   Þ¿╝  9}Óthà ♀   Ùqà÷u☺FVSj  5╠Á╝  §È└ù ï°à uV9♣ý║╝ t4V
\╝  à ♀   3└ޯ  ├ÞI╝  Ú|   à u▬Þ;╝  ï* §É┬ù PÞ‗╗  ë♠YïÃÙ
Þ       ╝  VVVVVà ♀   Þè╗  â─¶3└^├☼»L$►Q t$♀Þó²  YY^├Uïýâ
ï±u8SS3 GWhl┘ù h ☺  S §*└ù à└ë=©À╝ Ù§ §É┬ù â°xu
C:\Blender Foundation\blender-2.45-windows\blender.exe:15

  Ö[¸¹ï▼Ç┬0 E³ê¶▲Nâ■ uÚïE³☺)☺Ù☻ë◄^[╔├UïýQS☼¥└â°YVWï┘ï‗☼Å«
 âÞ♦☼ä×♥  âÞ    ☼äò♥  âÞ↑tpâÞ∟tIHt$âÞ♠☼àÅ☻  ï3 ;Ã☼îj☻  â°
  â■♂☼ÅF☻  ïU►ïT▓hÚ:♥  ïv↑3 ;¸☼î-☻  â■♠☼Å$☻  ïU►ïT▓∟Ú↑♥
  â°↨☼ű☺  Öj♀Y¸¨ï┬;Ã☼àP☺  QXÚI☺  âÞM☼äú   j♠Y+┴☼ää   HHt
ïF↑3 ;Ã☼îƒ☺  ;┴☼Åù☺  ;Ãt∟ìH Ù↨ïF↑3 ;Ã☼îü☺  ;┴☼Åy☺  ï╚ïF∟;
Ú┼   jÖ^¸■;Ð☼îÀ   @Ú▒   ï♠3 ;Ã☼î6☺  â°;ÚÃ■  ïF♦ÙÚ3 9~¶☼î▲
♥┬Ùzâ°m☼Å=☺  ☼ä!☺  âÞZ☼äE☺  âÞ☼äÎ   H☼ä   Ht`Ht,âÞ♠☼àþ
    u¶ìF☺j♥Ù ïv♀â■☺|♣â■▼~♀Þ<ó  3 Úÿ   ïã u¶j☻ZïM♀ï¹Þ=²  Y
Þr☺  â─↑à└tsïE♀98tlï♥ u►ã  ïE♀ ♥PSVj☻ÞH☺  â─↑à└☼à5☺  ÙCWÙ
♫☺  ïv↑3 ;¸|♣â■♠~▼ÞØí  WWWWWà ▬   Þ▲í  â─¶3└Úý   ïU►ï¶▓ÚÍ
  âÞp☼äï   âÞteHtFHt&Hu┴Þx9  Þï2  ïð3└9F ï╦☼ò└ïÏï¶ÜëE³Úå
¨ï┬Ú█■   u►3 9}¶ u♀SVtj☺Ú‼   WÚ
C:\Blender Foundation\blender-2.45-windows\blender.exe:16

  └t&:a☺u%
C:\Blender Foundation\blender-2.45-windows\blender.exe:16

  └t◄:a♥u►â┴♦â┬♦
C:\Blender Foundation\blender-2.45-windows\blender.exe:17

  â♦ë~∟ë~↑ï┴Þ☻¸ðâÓ☺ïM³_3═^Þ▬╠  ╔┬♦ Uïýâý|íêè¿ 3┼ëE³VjxìEä
C:\Blender Foundation\blender-2.45-windows\blender.exe:18

  +¾t§3█à÷☼ƒ├ì\← ï¾à÷☼à♥  ☼Âp♂☼ÂY♂+¾t◄3█à÷☼ƒ├ì\← ï¾Ù☻3÷à÷
¾t§3█à÷☼ƒ├ì\← ï¾à÷☼à╣☻  ☼Âp
C:\Blender Foundation\blender-2.45-windows\blender.exe:18

  +¾t§3█à÷☼ƒ├ì\← ï¾à÷☼àÿ☻  ☼Âp♫☼ÂY♫+¾t§3█à÷☼ƒ├ì\← ï¾à÷☼àw
\← ï¾Ù☻3÷à÷☼àR☻  ïp►;q►t~☼ÂY►☼Âp►+¾t§3█à÷☼ƒ├ì\← ï¾à÷☼à)☻
 ï¾à÷☼☻  ☼Âp↕☼ÂY↕+¾t§3█à÷☼ƒ├ì\← ï¾à÷☼àþ☺  ☼Âp‼☼ÂY‼+¾t◄3█à
p¶;q¶t~☼Âp¶☼ÂY¶+¾t§3█à÷☼ƒ├ì\← ï¾à÷☼àÖ☺  ☼Âp§☼ÂY§+¾t§3█à÷☼
▬+¾t§3█à÷☼ƒ├ì\← ï¾à÷☼àW☺  ☼Âp↨☼ÂY↨+¾t◄3█à÷☼ƒ├ì\← ï¾Ù☻3÷à÷
¾t§3█à÷☼ƒ├ì\← ï¾à÷☼à    ☺  ☼Âp↓☼ÂY↓+¾t§3█à÷☼ƒ├ì\← ï¾à÷☼àÞ
\← ï¾à÷☼àà   ☼Âp←☼ÂY←+¾t◄3█à÷☼ƒ├ì\← ï¾Ù☻3÷à÷☼àó   ïp∟;q∟t
 ï¾à÷u}☼Âp↔☼ÂY↔+¾t◄3█à÷☼ƒ├ì\← ï¾à÷u`☼Âp▲☼ÂY▲+¾t◄3█à÷☼ƒ├ì\
÷☼ƒ├ì\← ï¾Ù☻3÷à÷u"♥┬♥╩+·;·☼âå¹  ♥Ã♥¤â ▼☼ç┌♥   $¢à░@ ïãÚ╬♥
à÷☼ƒ┬ìT↕ ï‗à÷uı☼ÂpÕ☼ÂQÕ+‗t◄3Êà÷☼ƒ┬ìT↕ ï‗à÷u©☼Âpµ☼ÂQµ+‗t◄3
þ+‗t◄3Êà÷☼ƒ┬ìT↕ ï‗Ù☻3÷à÷☼àv   ïPÞ;QÞt}☼Â‗☼ÂQÞ+‗t§3Êà÷☼ƒ┬ì
t§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼à-   ☼ÂpÛ☼ÂQÛ+‗t§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼à♀   ☼
‗Ù☻3÷à÷☼àþ■  ïPý;Qýt}☼Â‗☼ÂQý+‗t§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼à┐■  ☼ÂpÝ
☼à×■  ☼Âp¯☼ÂQ¯+‗t§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼à}■  ☼Âp´☼ÂQ´+‗t◄3Êà÷☼ƒ
Q*t}☼Â‗☼ÂQ*+‗t§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼à0■  ☼Âp±☼ÂQ±+‗t§3Êà÷☼ƒ┬ìT
§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼௲  ☼Âp¾☼ÂQ¾+‗t◄3Êà÷☼ƒ┬ìT↕ ï‗Ù☻3÷à÷☼à╔²
Êà÷☼ƒ┬ìT↕ ï‗à÷☼àá²  ☼Âp§☼ÂQ§+‗t§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼à⌂²  ☼Âp÷
☼à^²  ☼Âp¸☼ÂQ¸+‗t◄3Êà÷☼ƒ┬ìT↕ ï‗Ù☻3÷à÷☼à9²  ïP°;Q°t}☼Â‗☼ÂQ
²  ☼Âp¨☼ÂQ¨+‗t§3Êà÷☼ƒ┬ìT↕ ï‗à÷☼à*³  ☼Âp·☼ÂQ·+‗t§3Êà÷☼ƒ┬ìT
◄3Êà÷☼ƒ┬ìT↕ ï‗Ù☻3÷à÷☼ଳ  ïP³;Q³to☼Â‗☼ÂQ³+‗t☼3Êà÷☼ƒ┬ìT↕ à
T↕ àÊu←☼Âp■☼ÂQ■+‗t‼3Êà÷☼ƒ┬ìT↕ àÊt♦ï┬Ù↔☼Â@ ☼ÂI +┴t◄3╔à└☼ƒ┴

C:\Blender Foundation\blender-2.45-windows\blender.exe:19

    à└YYt↕èj☻êE°ê]¨ãE· YÙ
C:\Blender Foundation\blender-2.45-windows\blender.exe:21
integer argument expected, got float
  Xî¿ Ù↓© \&♣9♣\î¿ |♀)♣\î¿  ♣Xî¿ ë=Tî¿ _^[╔├UïýQVìE³3÷Pëu
C:\Blender Foundation\blender-2.45-windows\blender.exe:21
lled_window_add(): cannot add non scrollable widget use g
with_viewport() instead
  VVVVVÞ´g  â─¶9u³u3└Ú2☺  ïW¶S3█C;§Hî¿ u♀;§Tî¿ ☼ä‗   95£╗
À
('Setting up drawing...',)
('Faces to be sorted:', 12)
('8.33%',)
('***Inserting face 8 in the tree***',)
('Making new tree...',)
('Adding a new tree:', [&lt;pantographLib.Face instance at 0
('16.67%',)
('***Inserting face 5 in the tree***',)
('Comparing with Face 8',)
('Adding a new tree:', [&lt;pantographLib.Face instance at 0
('Face 5 is in back:',)
('25.0%',)
('***Inserting face 1 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Adding a new tree:', [&lt;pantographLib.Face instance at 0
('Face 1 is in back:',)
('33.33%',)
('***Inserting face 4 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Face 4 is coplanar:',)
('41.67%',)
('***Inserting face 10 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Comparing with Face 1',)
('Adding a new tree:', [&lt;pantographLib.Face instance at 0
('Face 10 is in front:',)
('50.0%',)
('***Inserting face 2 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Comparing with Face 1',)
('Comparing with Face 10',)
('Adding a new tree:', [&lt;pantographLib.Face instance at 0
('Face 2 is in front:',)
('58.33%',)
('***Inserting face 6 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Comparing with Face 1',)
('Comparing with Face 10',)
('Comparing with Face 2',)
('Adding a new tree:', [&lt;pantographLib.Face instance at 0
('Face 6 is in front:',)
('66.67%',)
('***Inserting face 9 in the tree***',)
('Comparing with Face 8',)
('Face 9 is coplanar:',)
('75.0%',)
('***Inserting face 7 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Comparing with Face 1',)
('Comparing with Face 10',)
('Comparing with Face 2',)
('Comparing with Face 6',)
('Face 7 is coplanar:',)
('83.33%',)
('***Inserting face 0 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Comparing with Face 1',)
('Face 0 is coplanar:',)
('91.67%',)
('***Inserting face 11 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Comparing with Face 1',)
('Comparing with Face 10',)
('Face 11 is coplanar:',)
('100.0%',)
('***Inserting face 3 in the tree***',)
('Comparing with Face 8',)
('Comparing with Face 5',)
('Comparing with Face 1',)
('Comparing with Face 10',)
('Comparing with Face 2',)
('Face 3 is coplanar:',)
('Sorting took 0.001 minutes',)

When saving the console only says:

('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)
('Setting up drawing...',)

Yes everything else seems to work fine :wink: