[Skencil-users] Scripted, command-line drawing example for Skencil 1.0alpha

sdaau sd at imi.aau.dk
Sun Dec 26 19:27:23 CET 2010


Hi all,

Just a small update - here is a more proper example script:

http://sdaaubckp.svn.sourceforge.net/viewvc/sdaaubckp/single-scripts/cmdl-blockdiag-fig-skencil.py?view=markup

.. which generates the following diagram:

http://sdaaubckp.sourceforge.net/post/img/cmdl-blockdiag-fig-skencil-r157.py.ps.png
http://sdaaubckp.sourceforge.net/post/img/cmdl-blockdiag-fig-skencil-r157.py.ps


While the block generation code can be a bit of a hassle to read, all I 
care for, is that I can issue commands like these to generate the "node" 
blocks:

	structNodeA = getStructBoxnode(
		"struct1",	# title label
		("*pnt1", "*pointer2", "*point3"),
		("var1", "variable2", "Varib3")
	)
	structNodeB = getStructBoxnode(
		"str2",		# title label
		("*pnt1", "*pnt2", "*pnt3", "*pnt4", "*pnt5", ),
		("var1", "var2", "var3", "var4", "var5", "var6", )
	)

... and the code will automatically resize and arrange a "node" block so 
it matches the text; and also, that I can issue commands like these:

  	tconnline = getStdConnLine(
		structNodeA[1]['ptfl_1'], # from (startpoint - moveto)
		structNodeB[1]['box'],	  # to (endpoint)
		({'-':30}, {'|':-50}, {'-':-40}, {'|':-50})
	)
	doc.Insert(tconnline)

... to connect the "node" blocks.


In any case - thanks again for making Skencil so versatile :)

Cheers!



PS: As a note, I also put a link to this thread on this post:
"Scripted, command-line drawing example for Skencil 1.0alpha - on 
[Skencil-users]"
http://sk1project.org/forum/viewthread.php?thread_id=172





On 2010-12-26 00:34, sdaau wrote:
> Hi all,
>
> I have just posted a basic example script - demonstrating scripted,
> command line, drawing - here:
>
> http://sdaaubckp.svn.sourceforge.net/viewvc/sdaaubckp/single-scripts/cmdline_draw_skencil_script.py?view=markup
>
> (you can also find a modified sk2ps in the same directory, that runs
> with 1.0alpha)
>
> The kind of use shown there is similar to how one would use 'tikz' in
> 'LaTeX' - i.e. you code your figure in a text file, and then you run
> some software on your figure code and get a vector output (pdf, ps) of
> your figure in the end.
>
> The code there just shows placement and styling of textfield, line (with
> arrows for head/tail, one of the arrows being a circle), and rectangle -
> where the positioning is done based on the transformed properties of
> objects (such as the text field width for a given font). And that
> demonstrates it could possibly be used for more complex
> illustrations/figures.
>
> Btw tikz is awesome, as long as you don't start putting things in groups
> that rotate, and then trying to calculate bounding box sizes..
>
> I guess what I often lack is the possibility to make graphic object
> classes, like often done in Actionscript [which I also considered - but
> in the end, I'd need to convert swf to pdf/ps, and with all the
> different versions and VMs, that can turn out to be problematic]
>
> I was *very* surprised not to find any examples of how one goes about
> this in Skencil - it is certainly one area people could be interested
> in... Luckily, it was not impossible to dig through the Python source,
> in order to put a basic example together - although not trival either;
> which is why I thought I'd post on the list about it. (don't know if
> anyone intended to write documentation about this kind of a workflow -
> if not, the developers are welcome to use it as such, or improved, as
> distribution examples or on the webpage).
>
> In any case - thanks for the awesome software; and thanks for the
> 'resurrection'; I certainly am glad for it!
>
> Cheers!
>
>
>
> (PS: Btw, couple of bugs for the ubuntu deb:
>
> * after install, skencil didn't want to start, until I changed:
> /usr/lib/python2.6/dist-packages/skencil/Sketch/Base/gtkutils.py
> line 73:
> -font_size = int(vals[-1])
> +font_size = int(float(vals[-1]))
>
> * In the GUI, I can place text - but cannot type; when started from
> command line, stderr reports:
>
> EditSelection.GetObjectMethod: editor
> <Sketch.Graphics.selection.EditorWrapper instance at 0x95453ac>  is not
> compatible with class skencil.Sketch.Graphics.text.CommonTextEditor
>
> ... but, as I hinted above, I don't necessarily need the GUI all that
> much these days :)
> )
> _______________________________________________
> Skencil-users mailing list
> Skencil-users at wald.intevation.org
> http://lists.wald.intevation.org/mailman/listinfo/skencil-users


More information about the Skencil-users mailing list