Exploring the pencil2d F6

So one of thing I’m starting to  taking a look at this: https://github.com/pencil2d/pencil/issues/414

Playing around with the app, it looks like the F6 duplicate frame in combination with a pencil draw, F6 is yielded correct results.  (I’m thinking it might be worth understanding what’s happening on something that’s working correctly, for when I deal with the stuff that’s broke.
So… I wanted follow the trail on what’s going on with the F6 key..  I was thinking it was going to be sometype of keypress event, but I think I found the link here:

I guess  kb.ini file is some type of initialization file.
Anyway it’s referenced here:



So the magic search term at the moment is

I think we’re getting close

Okkk… Now I think I found it.


I just did some testing and everything within this routine is functioning properly.

(This seemed like more work than it should have been)
My think the next step is to see where pasting is occuring.   The critters are laying in there some where.
(Well the morning is blown and nothing really fixed yet.)
I think my next steps are probably to isolate the wacko behavior and put a break point on paste() so I can see what’s going on.


Posted in Uncategorized | Tagged | Leave a comment

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. https://github.com/pencil2d/pencil/blob/master/core_lib/tool/selecttool.h 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/studio.sh

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: http://stackoverflow.com/questions/17474963/android-studio-tools-jar-file-is-not-present-in-classpath

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:http://arwankhoiruddin.blogspot.co.il/2014/01/android-studio-in-ubuntu-problem.html

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 studio.sh

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, http://www.aliexpress.com/item/Velocimetry-sensors-sensor-module-encoder-barrowload-speed-robot/1266192518.html

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.  http://www.alldatasheet.com/datasheet-pdf/pdf/53870/FAIRCHILD/MOC70P3.html 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 http://www.nxp.com/documents/data_sheet/74HC_HCT14.pdf 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) http://forum.arduino.cc/index.php?topic=8652.0
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. http://playground.arduino.cc/Code/Interrupts   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. http://web.csulb.edu/~hill/ee444/Lectures/08_PID%20Control.pdf

As well as here: http://www.csimn.com/CSI_pages/PIDforDummies.html

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. https://en.wikipedia.org/wiki/H_bridge

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: https://forum.arduino.cc/index.php?topic=211225.0
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) https://apps.ubuntu.com/cat/applications/key-mon/ 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. http://www.freecadweb.org/wiki/index.php?title=Draft_Wire

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 😉http://forum.freecadweb.org/viewtopic.php?f=10&t=3380&start=40#p26606

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