Messing around with Pencil2d. Exploring the selection tool.

Over the holidays, my daughter had expressed an interest in learning animation.  I did a little googling an I found a open source package called pencil2d.   She downloaded and tried using it and found it too buggy.  I uses C++/QT which is something I’m familiar with my dabbling with freecad so, I figured what the heck and I downloaded the source from git..
My understanding is that the original developer of pencil dropped the project and it basically forked. Pencil2d is a merge and enhancement effort.
I don’t have a lot of open bandwidth these days, but I’m hoping that contribute a bit to this project and get it to a point, where my daughter can make some use full animations.

From late December to today, it seems like things have improved quite a bit with pencil.   One very annoying thing at the moment is the selection tool.. It seems to be misbehaving…

Basically when copy pasting with the selection tool very bizarre things occur.  It’s sort of hard to explain.  At this point I just want to see if can get a 30K foot understanding of how things are supposed to work.
So I think the problem has to do with thinks interacting  with the selection tool versus the selection tool itself. git activity around selecttool.h has been quite.. (last change 25 days ago..) So, need to see how this object is used.
So.. Looking for reference to the SelectTool we get this:


So the selecttool seems to interact with the world with the toolmanager..




So.. It looks like SelectTool object is stored in mToolSetHash.







QHash looks alot to me like a Dictionary in C#  which contains a key and a value.
The key is an enumeration called ToolType and Value is a pointer to the BaseClass definition of the tools..
Ok.. So the enumeration ToolType is defined here:

Ok.. This is very understandable to me… So.. to figure out where the selectTool object is interacting with the rest of pencil2d we need to search on the Enumeration SELECT  (good thing that we’re not doing SQL in this app)
We need to find the references to the enumeration SELECT






This seems like its doing something with rotation? (I’ve heard this mentioned)


Ok.. I think this is fired to select the gui tool (this might be worth looking at later

Ok.. it looks like we’re just selecting the  Selection tool to be the default object here.


I can see putting some break points to get a look at the call stack at a few stops at some point


Can’t see anything be an issue here with what I’m working on.


This is interesting and I think will need disection at some point.


This is a virtual functions defined in the baseclasstool and overwritten in


The enumeration which defines SELECT.

Basically.. I just want to how the select object is use… I’m not trying to fix anything yet.

There’s a lot going on here and hopefully this will save me a little time later on.
One thing that I need to study is the copy paste mechanism…
(One thing that I notice is the duplicate frame F6 has a behavior that is weird at first but essenetially correct when you think about it.(Well maybe) When you hit f6 you get the image put into the new frame with the selection box around it.   If you draw on the frame and hit F6 the new stuff you just drew doesn’t copy over…  you need to hit escape and then F6… (I’m thinking this will come in handy at some point)


Posted in Uncategorized | Tagged | Leave a comment

Nice little git reference.

I seem to gotten back on the git thing..  Anyway, I found this nice concise guide on forking and pushing changes…   Kind of nice so I wanting to leave myself a note….

Posted in Uncategorized | Tagged | Leave a comment

First dabbles with Android-Studio

A while back I was dabbling with App-Inventor to get my hexy the hexapod working on my Nexus tablet.  It was a fun project.   Poor hexy is in pieces now, stripped for her servo’s.    So.. for a variety of reasons, I sort of have an itch for looking at android programming again.

Doing a fair amount of googling, It looks like the thing to try is Android- Studio…  Ok.
So I ran across setting up a android-studio on ubuntu via a PPA here:

It took me a few minutes to figure out how to fire the darn thing up.

jonasthomas@JTLapTop:~$ /opt/android-studio/bin/

So you think I be ready to fly….. nope.

JDK Required: ‘tools.jar’ seems to be not in Studio classpath.
Please ensure JAVA_HOME points to JDK rather than JRE.

Ok…  So an interesting post on here
JDK = JRE + Development tools.

JRE = JVM + Libraries

JDK = {JVM + Libraries} + Development tools.

On the Tools.Jar I found a nice post here:

jonasthomas@JTLapTop:~$ java -version
java version “1.7.0_79”
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
jonasthomas@JTLapTop:~$ java -version
java version “1.7.0_79”
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

Ok.. I have OpenJDK installed (Possibly when I installed Eclipse-Arduino)  This seems to be working ok.. So I don’t want to hose that up.
Soo.. The previous post pointed me to here:

jonasthomas@JTLapTop:~$ update-alternatives –config java
There are 3 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
1            /usr/bin/gij-4.8                                 1048      manual mode
2            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
3            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode

Press enter to keep the current choice[*], or type selection number:

Ok.. I think all I need to do is to a Path to

Soo.. I added this to the top:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

Well that didn’t work.
Some talked about just doing this.

Ok… So that did it…
Its a bit strange that seems to have worked.  I thought that I had the jdk already installed, but when I did the installed it didn’t give me a message back that it was installed already and libraries started loading up.. Go figure.

Posted in Uncategorized | Leave a comment

More Fooling speed encoder with my little robot.

The little robot I picked up a Musecon came supplied with an optical encoder disks but lacked the transmissive optical sensor with phototransistor output, photo sensor, or whatever you call those things.  Dwayne had a sensor for paired robot wheels that I got from him, but they were not wide enough to fit the laser cut plastic of the kit.   I had a heck of time finding the magic search terms for Ali-Express to potentially find an exact match to the kit.  I did manage to find the magic incantation eventually,

For now, I think I’m going to just doing to 3d print a new platform to match the photosensor sensor span I have  and well as optimized it to  the mission of my bot. Its mission basically to swiffer my wood floors and drag the stuff to one end of the floor to be picked up by something else.  At this point, I think I want my bot to drag a swiffer pad behind it and have a ping sensor in front of it connected to a hobby servo to perform a sweeping scan.

I think I need the speed sensors to help keep the bot moving on a straight line. When it reaches one end of the floor, I want to lift the swiffer off the floor so the dust stays at one end.. (At this point I’ll either just pick it up with a dust pan, or have a Rhomba just focus on that).  One thing, I haven’t worked out is how to map objects in the room, and to map a path.. (The ping I think can avoid crashes, but I don’t think it’s enough)

Anyway this is the velocimetry I got to play with at the moment.  It was labeled as KeyesEye.  I did a fair amount of googling to find a spec sheet but came up dry.





The photosensor is labeled as MOC70T3..  I couldn’t get a match on the T3 but I think this is close enough. so… it guess the correct term is to describe the sensors is PHOTOTRANSISTOR OPTICAL INTERRUPTER SWITCH.
The main chip on the board is labeled:
I got a hit on the first number Hex inverting Schmitt trigger.  So basically at then end of all this, I should basically just be able to plug this into an arduino and it should just work.

So I’m interested in figuring out how to setup some type of PID for controlling two DC motors using my arduino,  googling I came up with a really cool link for a diy baby segway (which is way more complicated that what I’m interested in doing (at this point anyway)
So.. I think for my little project, I’m going to be generating some interupts from the Optical interrupters to keep this puppy driving in a straight line.
So the project at this point, is going to be using a bluetooth module, 2 dcmotors, two servos, one ping sensor, and photo sensors.
I’m thinking about generating a hardware interupt with the encoders to keep track of speed control… Some quick googling gave me this.   So on a Uno 2 external interupts  IntO, Int1 are available on Arduino pins 2&3  Ok.. let me check. Dang, pin 2 is apparently being used by the bluetooth module, so that life slightly more complicated.  Although, I have pin change interrupts available.
So I think my next steps are to map out what pins are being used what’s still available, do a little more research on interupts, and PID for DC motor control and try to get a hold of the source that’s currently driving the little bot.  After that or before, I should layout my new base for my bot and print it out.

(Interesting link here on PID stuff.

As well as here:

And there is this here…

And there is this fun little video which I keep coming back to.

Posted in Uncategorized | Leave a comment

Fooling around with my Musecon robot.

I just got done attending Musecon this year.  I had a great time but scheduling didn’t let attend all three days.  When I  visited Dale and Dwayne of 2DKits and I saw they had some robot kits that they where trying out for the first time.  It’s been something I’ve been thinking about so I got one.

It’s a basic setup but it was pretty easy to get going so that was fun.  Components from China,  the motors and frame where in shipped as one sub-kit and the Arduino uno and Adafruit motor shields where clones as well as the blue tooth adapter came was added by 2dkits.

basic robot setup Bluetooth A








The blue tooth module needed a small hack with a voltage divider to get the signal down from 5 to 3.3 volts.

We also hacked up the motor shield clone to add some pins for the blue tooth module..

The motor shield appears to be a clone of the adafruit v1 motor shield with some details that can be found here.

I want to slowly add a bunch of stuff to this system to create a swiffer bot.   Basically, I have alot hardwood floor in my house and having a roomba do it all seems somewhat inefficient.  What I’m thinking about is having this bot, drag a swiffer pad behind it. When it reaches one end of the house it would lift the swiffer slightly to deposit the dirt where it could either be roomba’d or done by hand.

So… I’m thinking I want to 3d print out a nicer fitting base, and add motor encoders(just because) a servo to lift the swiffer to start.   If I don’t get bored or distracted by life, I won’t mind mounting a ping sensor on a another servo..  That’s a ways away though..

For now I just wanted to understand the motor board layout and how it worked.  Basically has 4-H-bridges (via 2 L293D chips) driven by a 74HC595N Serial to parallel output latch.
When reviewing how the latch worked, I ran across this video which I thought really explained it well:

So now, as far as a basic function on a basic motor control using an h-bridge, I thought wiki-pedia explained it pretty clearly.

I’m still a little fuzzy on how the L293D physically works as an H-bridge, but as far as hooking it up, it’s pretty wheel explained here.

Ok.. Now what I’m curious about is how the 74HC595N Serial to parallel output latch relates hooks up to the L293D’s..  I pulled this from here:
So basically the 74HC595N is sending is sending out the 2 bits to each motor control 2*4 = 8 bits. Ok. That makes sense.  I’m out of fun time, but I  think I  need to take a closer look to figure this all out as far as how this the arduino pins all get assigned out.
I’m thinking my next step is to figure out how the pins get assigned out and then figure out how the optical encoder works.

Posted in Linistepper, Uncategorized | Leave a comment

Something I’ ve been working on.

This tube only cuts properly if there is a no radius in the Dline.



Posted in Uncategorized | Leave a comment

Messing around with Pipe bending in freeCAD

I’ve had the need for bending pipe in freeCAD.  I had mentioned this on the IRC as well as the freecad forum.   NormandC  had posted a video on youtube on how to do this using Dwires.

I’m not sure what Navigation styles he’s using. I’ve been studying his video and I’m trying replicate what he’s doing. Basically, I’ve been recording a Macro and trying to figure out underlying python code that’s occurring under the hood. I’ve been having some challenges, replicating his key/mouse clicks with my marblemouse. (Which by the way he uses’s an application called keymon which is sort of cool) I just downloaded keymon and it’s pretty cool. I think my issue is he’s using a middle mouse click which I haven’t mapped yet on my marble mouse. (I’m think that’s allowing him to enter coordinates into the z-axis. I don’t want to get distracted by remapping my marble mouse so I’m going to work around that for now. I don’t know this for sure but it appears that shift-enter works.)

So. For my first experiment, I to replicated NormandC’s video as best I could. Initially, I was working in inch as my default units and I could get the radius to draw out. When I switched to metric the radius would draw out… Soo… I suspect there might be a critter somewhere in the FreeCAD code with Radius and Inch… Anyway….

First experiment was to create a 50 X 50 X 100 cube and draw a DWire around it.
InitialTestThis is rather amusing .. I was just doing this by eye and it looked liked I was drawing a Dwire to run along the edges of the Cube, but alas it was a delusion errrr..illusion.

So here’s some python code that I got from the macro recording.

# Macro Begin: /home/jonasthomas/FreecadMacros/tubeBendingTest2.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
import FreeCAD

FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘1 mm’
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘2 mm’
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘3 mm’
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘4 mm’

So it looks like points is a list of freecad vectors which goes into Draft.makeWire. There seems to be some magic that’s occuring prior to the python commands being sent. It seems like there are some fake lines(for a lack of a better term) prior to the python scripts creating the object for real.
From Gui behavior it appears that  Dwire can be appended.. So I found a little documentation on makeWire here

Method.png makeWire ( list or Part.Wire, [closed], [placement], [facemode] )

Description: Creates a DWire object from the given list of vectors or from the given Wire. If closed is True or if first and last points are identical, the wire is closed. If facemode is True (and wire is closed), the wire will appear filled. The current line width and color from the Draft toolbar will be used.

Returns: A new Draft DWire (not a Part Wire).

Ok…… So what’s the difference between a DWire and Part Wire??
A little more info here.

Ok.. Experiment#2.. I want to try to record a macro where I create a Dwire, do something else and then try to append points to the Dwire.. Lets see what it looks like.
# Macro Begin: /home/jonasthomas/FreecadMacros/tubetestC.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
import FreeCAD
import Part

App.ActiveDocument.ActiveObject.Label = “Cube”
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).Closed = False
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘2 mm’
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘1 mm’
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘0 mm’
FreeCAD.getDocument(“Unnamed”).getObject(“DWire”).FilletRadius = ‘0.1 mm’
# Macro End: /home/jonasthomas/FreecadMacros/tubetestC.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++/

Ok… This is getting more curious.. Apparent the macro recorder is recording everything… The dwire can be appended… Ok.. Now the question is how to do that programatically…
It’s been a year or so since I’ve messed with this stuff… time to google myself 😉

I think I need to poke around this code for a while. So it looks like draft.Makewire is defined here:


def makeWire(pointslist,closed=False,placement=None,face=True,support=None):
”’makeWire(pointslist,[closed],[placement]): Creates a Wire object
from the given list of vectors. If closed is True or first
and last points are identical, the wire is closed. If face is
true (and wire is closed), the wire will appear filled. Instead of
a pointslist, you can also pass a Part Wire.”’
import DraftGeomUtils, Part
if not isinstance(pointslist,list):
e = pointslist.Wires[0].Edges
pointslist = Part.Wire(DraftGeomUtils.sortEdges(e))
nlist = []
for v in pointslist.Vertexes:
if DraftGeomUtils.isReallyClosed(pointslist):
closed = True
pointslist = nlist
if len(pointslist) == 0:
print(Invalid input points: ,pointslist)
if placement: typecheck([(placement,FreeCAD.Placement)], makeWire)
if len(pointslist) == 2: fname = Line
else: fname = DWire
obj = FreeCAD.ActiveDocument.addObject(Part::Part2DObjectPython,fname)
obj.Points = pointslist
obj.Closed = closed
obj.Support = support
#obj.MakeFace = face
if placement: obj.Placement = placement
if gui:
return obj

Ok..It looks like the wire magic occurs in _wire
which is define  line 4078
So there is some interesting stuff going on with the fillet radius here which takes you to to filletwire

Ok… this is making my head ache.   I think I have my trail of breadcrumbs to follow… What I want to do next if figure out how to append a point to an existing DWire object.

Posted in Uncategorized | Tagged | Leave a comment

Converting Images to printable templates.

I was googling for a way to import a image into freecad and I ran into this page.

This wasn’t what I was looking for but this is pretty cool… Basically takes a 2d gray scale image and converts it to 3d..  Here the link to the Macro FCtexture

So, I thought I give this a try..  My wife had gotten me these for me on for my birthday.


This is just quick experiment… .I need to convert this to grey scale… Which I found away todo  here


rosesALooksLikeRosesIf you zoom in on this you can see the roses wth 3d
I guess I can see roses in there.  This requires a bit more research and experimentation.

So I was interested in finding out a little more about bmp file formats.
There’s a nice little blurb on wikipedia as well and some snippet  from stackoverflow

To play around with this macro, I snipped the 4 roses in the upper left hand corner to reduce the computation time.

So I tried a few different settings:
At this point, I’m just playing around on my P-4 laptop with doesn’t seem to have the processing power to handle the image.  Either that or something is locking up..
I it find annoying that I can’t tell if the macro is hangging or just it takes some time to crunch.
One of the things that I thought would be cool if I could take this image and turn it into a solid and 3d print this.. I could see all kinds of interesting things that I can do with this.
At this point, I’ve been trying to brush up on my python,  Refactoring/disceting this code would be a fun excersise for me  Perhaps, read the bitmap data in first before rendering it into freecad…  Also, I think it would be interesting to have this process run in a separate thread and update freecad, so image processing would appear a little more interactive.

(Down the rabbit hole we go.)







Posted in Uncategorized | Leave a comment

Some notes on creating a workbench

With all the other stuff I have going on, I don’t know if how much time I have to devote this project but the idea intrigues me and is fun to think about…

If you want to create a workbench in freecad here’s how to get you started.

Also there is an assembly2 workbench that looks sort of interesting..

The code behind all this magic is located here… Something definately worth looking at.

Posted in Uncategorized | Leave a comment

Problems reading dwg for freecad in 64 bit ubuntu.

Just a quick note here.   I was trying to get a DWG to load in freecad…

I’m running 64 ubuntu and I seem to be having the same problem was far as what was occurring here.

It was the weirdess thing.  I would try executing the program in the folder in which it resides and I’d get a message back.

jonasthomas@JTLapTop:/usr/bin/TeighaFileConverter_4.00.0$ TeighaFileConverter
/usr/bin/TeighaFileConverter: 4: /usr/bin/TeighaFileConverter: /usr/bin/TeighaFileConverter_4.00.0/TeighaFileConverter: not found

I ran across this which talked about installing ia32-libs and things seem to get much better.

Before I installed this… I didn’t get anything when I did this.

jonasthomas@JTLapTop:/$ ldd /usr/bin/TeighaFileConverter_4.00.0/TeighaFileConverter =>  (0xf7779000) => not found => not found => not found => not found => not found => not found => not found => not found => not found => /usr/lib/i386-linux-gnu/ (0xf6c81000) => /lib/i386-linux-gnu/ (0xf6c57000) => /usr/lib/i386-linux-gnu/ (0xf6c45000) => /usr/lib/i386-linux-gnu/ (0xf6b10000) => /usr/lib/i386-linux-gnu/ (0xf6833000) => /lib/i386-linux-gnu/ (0xf681d000) => /lib/i386-linux-gnu/ (0xf6814000) => /lib/i386-linux-gnu/ (0xf680f000) => /lib/i386-linux-gnu/ (0xf67f3000) => /usr/lib/i386-linux-gnu/ (0xf670e000) => /lib/i386-linux-gnu/ (0xf66e2000) => /lib/i386-linux-gnu/ (0xf66c4000) => /lib/i386-linux-gnu/ (0xf651a000) => /usr/lib/i386-linux-gnu/ (0xf64e5000) => /usr/lib/i386-linux-gnu/ (0xf64cc000) => /lib/i386-linux-gnu/ (0xf63d3000) => /usr/lib/i386-linux-gnu/ (0xf6339000) => /usr/lib/i386-linux-gnu/ (0xf62ea000) => /usr/lib/i386-linux-gnu/ (0xf62e0000) => /usr/lib/i386-linux-gnu/ (0xf62c6000) => /usr/lib/i386-linux-gnu/ (0xf62b5000) => /usr/lib/i386-linux-gnu/ (0xf62ab000) => /usr/lib/i386-linux-gnu/ (0xf628a000)
/lib/ (0xf777a000) => /lib/i386-linux-gnu/ (0xf625f000) => /usr/lib/i386-linux-gnu/ (0xf6203000) => /usr/lib/i386-linux-gnu/ (0xf61ff000) => /lib/i386-linux-gnu/ (0xf61c3000) => /usr/lib/i386-linux-gnu/ (0xf61bc000) => /lib/i386-linux-gnu/ (0xf61b5000) => /usr/lib/i386-linux-gnu/ (0xf61ae000)


Seems to have some issues here: => not found => not found => not found

Ok.. When I run from the terminal I get this.

jonasthomas@JTLapTop:/$ TeighaFileConverter
Unable to load library icui18n “Cannot load library icui18n: ( wrong ELF class: ELFCLASS64)”
menu_proxy_module_load': /usr/bin/TeighaFileConverter_4.00.0/TeighaFileConverter: undefined symbol: menu_proxy_module_load

(TeighaFileConverter:14626): Gtk-WARNING **: Failed to load type module: (null)

menu_proxy_module_load’: /usr/bin/TeighaFileConverter_4.00.0/TeighaFileConverter: undefined symbol: menu_proxy_module_load

(TeighaFileConverter:14626): Gtk-WARNING **: Failed to load type module: (null)

menu_proxy_module_load': /usr/bin/TeighaFileConverter_4.00.0/TeighaFileConverter: undefined symbol: menu_proxy_module_load

(TeighaFileConverter:14626): Gtk-WARNING **: Failed to load type module: (null)

menu_proxy_module_load’: /usr/bin/TeighaFileConverter_4.00.0/TeighaFileConverter: undefined symbol: menu_proxy_module_load

(TeighaFileConverter:14626): Gtk-WARNING **: Failed to load type module: (null)

So google leads me here:

Sooo… It’s late and I’ve managed to manually fire up TeigaFileConvertor and it seems like I managed to convert Dwg into Dxf…
I loaded the Python scripts according to this manually.

DXF libraries not found. Downloading…
The DXF import/export libraries needed by FreeCAD to handle the DXF format
were not found on this system. Please either enable FreeCAD to download these
libraries (menu Edit > Preferences > Import-Export > DXF > Enable downloads) or download
these libraries manually, as explained on

Still no joy… I give up..







Posted in Uncategorized | Leave a comment